Project creation failed. The Q# project template may not be installed.
Describe the bug
Trying to create the hello world project with VSCode and the Ms Quantu Development Kit for Visual Studio.
To Reproduce
VSCode used: Visual Studio Code - Insiders Version: 1.43.0-insider (system setup) Commit: 0eebaf9ad23748baca2afc0da425650922bc23de Date: 2020-02-27T05:47:59.073Z Electron: 7.1.11 Chrome: 78.0.3904.130 Node.js: 12.8.1 V8: 7.8.279.23-electron.0 OS: Windows_NT x64 10.0.18363
Steps to reproduce the behavior: -Windows 10 1909
- Run VSCode Insiders;
- ctrl+shift+p, select Q#: Create new project...
Observed:
- you get this error

- pressing on "Install project template and retry" does not help -restarting VSCode does not help
Expected behavior
The project is created successfully.
Thanks for the report, @lukka! To try and help debug, would you be willing to share the log from the Q# Language Server output window (View → Output, then select "Q# Language Extension" from the drop down at the upper-right of the terminal pane) and the Developer Console (Help → Toggle Developer Tools, then select the "Console" tab at the top of the right-hand pane). Also, what version of the .NET Core SDK do you have installed? Thanks for your help!
@cgranade Looks like this is the only output when i select the file:
[Info - 12:29:42 PM] workspace folder: (Null)
And if i open a folder first (in order to get an actual workspace open manually) I get similar output:
[Info - 12:31:36 PM] workspace folder: d:\temp\qproject
Then, I i click on "install project templates" while a workspace is there (i.e. i opened manually a folder), then the project gets created on disk. I get some error still, like:
[Info - 12:31:36 PM] workspace folder: d:\temp\qproject
[Error - 12:33:47 PM] MSBuild error in C:\Program Files\dotnet\sdk\3.1.200-preview-014977\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(59,5): The "ProcessFrameworkReferences" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'NuGet.Frameworks, Version=5.5.0.4, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'NuGet.Frameworks, Version=5.5.0.4, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at System.Linq.Enumerable.WhereEnumerableIterator`1.ToList()
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Microsoft.NET.Build.Tasks.ProcessFrameworkReferences.ExecuteCore()
at Microsoft.NET.Build.Tasks.TaskBase.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
[Error - 12:33:47 PM] Failed to restore project 'd:\temp\qproject\test\test.csproj'.
[Error - 12:33:47 PM] MSBuild error in C:\Program Files\dotnet\sdk\3.1.200-preview-014977\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(59,5): The "ProcessFrameworkReferences" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'NuGet.Frameworks, Version=5.5.0.4, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'NuGet.Frameworks, Version=5.5.0.4, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at System.Linq.Enumerable.WhereEnumerableIterator`1.ToList()
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Microsoft.NET.Build.Tasks.ProcessFrameworkReferences.ExecuteCore()
at Microsoft.NET.Build.Tasks.TaskBase.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
[Error - 12:33:47 PM] Failed to resolve assembly references for project 'd:\temp\qproject\test\test.csproj'.
Discovered Q# project 'd:\temp\qproject\test\test.csproj'.
Loading project 'd:\temp\qproject\test\test.csproj'.
Done loading project 'd:\temp\qproject\test\test.csproj'
I think that what it is not handled correctly is the fact that the extension does not seem to work if workspace is not open.
Thanks for providing those logs, @lukka! It looks like there may be a problem with your .NET Core SDK installation itself, perhaps, that's causing it to not find NuGet.Frameworks? Does it work to install project templates and use them manually from the command line using the code below?
dotnet new -i Microsoft.Quantum.ProjectTemplates
dotnet new console -lang Q#
@cgranade
it looks like it errors out while accessing an internal nuget feed, which I have access to (but i guess the credential provider is not enabled in this scenario):
> dotnet new -i Microsoft.Quantum.ProjectTemplates
C:\Program Files\dotnet\sdk\3.1.200\NuGet.targets(124,5): error : Unable to load the service index for source https://name.pkgs.visualstudio.com/_packaging/name/nuget/v3/index.json. [C:\Users\luca\.templateengine\dotnetcli\v3.1.200\scratch\restore.csproj]
C:\Program Files\dotnet\sdk\3.1.200\NuGet.targets(124,5): error : Response status code does not indicate success: 401 (Unauthorized). [C:\Users\luca\.templateengine\dotnetcli\v3.1.200\scratch\restore.csproj]
My version of dotnet:
>dotnet --version
3.1.200
I'm having the same problem. Any solution or workaround? Thanks in advance.
@cgranade Any progress on this?
@lukka: My apologies for missing your response! It looks like the internal feed that's causing the issue is hosted on Azure Artifacts, in which case the Azure Artifact Credential Provider should allow you to use NuGet successfully from outside Visual Studio, and thus should hopefully address this problem as well. Thanks for the additional detail!