I am trying to run a simple "Hello World" project in Q#, following this tutorial. I have completed the following steps (Step #s from tutorial link):
- Step 1: Installed the latest version of Visual Studio 2019 (16.11.4 Preview 1.0)
- Step 2: Installed Microsoft Quantum Development Kit
- Step 3: Created a Q# Project using the Q# Application Template
The resulting Program.qs file appears in vs:
namespace Quantum.QSharpHelloWorld {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
@EntryPoint()
operation HelloQ () : Unit {
Message("Hello quantum world!");
}
}
The two namespaces I am trying to open show the red squiggly line, with the errors
QS6104: No namespace with the name "Microsoft.Quantum.Canon" exists.
QS6104: No namespace with the name "Microsoft.Quantum.Intrinsic" exists.
Additionally and likely the same root cause, the @EntryPoint annotation and Message() call fail:
QS6005: No type with the name "EntryPoint" exists in any of the open namespaces.
QS5022: No identifier with the name "Message" exists.
In the solution explorer for my projet QSharpHelloWorld, the Dependencies, Packages, and each of five packages (Microsoft.Quantum.CSharpGeneration, .EntryPointDriver, .QSharp.Core, .Runtime.Core, and .Standard) all have the yellow triangle warning indicating a problem.
The error is similar to the one in this question, except I'm not using Python so the accepted answer is irrelevant. I attempted to use the command suggested in another answer:
dotnet add QSharpHelloWorld.csproj package Microsoft.Quantum.CSharpGeneration
However, this failed with the following error, suggesting this is the wrong solution:
error: Error while performing Update for package 'Microsoft.Quantum.CSharpGeneration'. Cannot edit items in imported files -
error: Item 'PackageReference' for 'Microsoft.Quantum.CSharpGeneration' in Imported file 'C:\[...]\.nuget\packages\microsoft.quantum.sdk\0.19.2109165653\Sdk\Sdk.props'.
I can't find any other obvious/easy menu options or fixes for this. Other questions I've found here on SE all seem to be related to Python integration, not using Visual Studio. I have the feeling I'm missing something trivial and obvious. Can anyone suggest additional steps I can take?