microsoft / Quantum

Microsoft Quantum Development Kit Samples
https://docs.microsoft.com/quantum
MIT License
3.88k stars 920 forks source link

State-Visualizer: 'QsMain' does not exist in the current context #316

Closed isaac-gs closed 4 years ago

isaac-gs commented 4 years ago

Describe the bug Operations in .qs files are not recognized in the project. If I place the quantum code in a project where the sdk is set to Microsoft.Quantum.Sdk/0.10.2001.2831 (in the csproj file) it works fine. All other projects under "samples" build fine, so I think it's related to the use of "Microsoft.NET.Sdk.Web". When it does fail, the following is what I get.

*Program.cs(21,32): error CS0103: The name 'QsMain' does not exist in the current context [\Quantum\samples\runtime\state-visualizer\StateVisualizer.csproj]**

This very well could be something I've done wrong, as I've checked multiple versions of this code (back until one in January - Commit d516ef97) and the same thing happens.

To Reproduce Steps to reproduce the behavior:

  1. Follow setup instructions for Q# development (I did Visual Studio and VS Code). Q# + C# Instructions
  2. Verify setup is correct as in the instructions with a few simple programs from the Quantum Katas or other samples.
  3. Follow instructions here

Expected behavior Expect for the code to run and for me to be able to access the visualizer at localhost:5000.

System information

bamarsha commented 4 years ago

Hi @isaac-gs, just wanted to confirm some more information about the bug:

  1. Does it happen in a freshly cloned copy of the repository, with no changes to the files before running npm install, npm run release, and dotnet run?
  2. What version of .NET Core are you using? You can see it with dotnet --version.
  3. Could you save the output of dotnet build --verbosity detailed to a file and attach it here?

Thanks!

isaac-gs commented 4 years ago

Yeah it still happens on a fresh clone with no changes.

.NET Core Version: 3.1.101

verbose_build.txt

bamarsha commented 4 years ago

Thanks for the build log! I can reproduce the bug now, and I think it's caused by the path to the repository having a space in it. (In this case, your username contains a space.) Could you try moving the repository somewhere that doesn't have a space in the path and see if it works?

cgranade commented 4 years ago

We just saw another example yesterday of problems arising from spaces in folder names, perhaps this is related to https://github.com/microsoft/qsharp-compiler/issues/333?

cgranade commented 4 years ago

@isaac-gs: I just wanted to quickly confirm if moving the same to another folder helped resolve the issue. Thanks!

isaac-gs commented 4 years ago

@cgranade yes, it works. Sorry for the late reply, I've been busy. Thank you both for the help.

bamarsha commented 4 years ago

I found the cause of microsoft/qsharp-compiler#333, and I think that this bug is actually separate from that, so I'm reopening this.

bamarsha commented 4 years ago

The bug should be fixed by microsoft/qsharp-runtime#268, but the package references here will need to be updated to use the new version of Microsoft.Quantum.Development.Kit.

bamarsha commented 4 years ago

StateVisualizer.csproj no longer uses the Microsoft.Quantum.Development.Kit package, so I think this bug is resolved now.