riju/langs/qsharp.yaml

53 lines
1.4 KiB
YAML

id: "qsharp"
aliases:
- "q"
- "qs"
name: "Q#"
install:
# Apparently, the Q# project template is hardcoded to use version
# 3.x of the .NET SDK. Not sure why.
prepare:
apt:
- $(grep-aptavail -wF Package "dotnet-sdk-3\.[0-9.]+" -s Package -n | sort -Vr | head -n1)
apt:
- $(grep-aptavail -wF Package "dotnet-sdk-3\.[0-9.]+" -s Package -n | sort -Vr | head -n1)
# We should cache the .dotnet directory to avoid a .NET banner being
# printed, and we should cache the main directory because there is a
# generated main.csproj file that is needed by .NET. Finally we
# should cache the .nuget directory as well as the build artifacts
# inside main to avoid a 30s initial compile time.
#
# We could optimize further but I don't feel like it right now.
manual: |
install -d "${pkg}/opt/qsharp/skel"
dotnet new -i Microsoft.Quantum.ProjectTemplates
dotnet new console -lang Q# -o main
dotnet run --project main
shopt -s dotglob
cp -R * "${HOME}/.dotnet" "${HOME}/.nuget" "${pkg}/opt/qsharp/skel/"
rm "${pkg}/opt/qsharp/skel/main/Program.qs"
chmod -R a=u,go-w "${pkg}/opt/qsharp/skel"
setup: |
shopt -s dotglob
cp -R /opt/qsharp/skel/* ./
main: "main/Main.qs"
template: |
namespace main {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
@EntryPoint()
operation Main() : Unit {
Message("Hello, world!");
}
}
run: |
dotnet run --project main