Build error when trying to run a Quantum Development Kit (QDK) project in .NET 7.0 on Windows 11, related to the Microsoft.Quantum.Sdk version and its dependencies.

Ramesh Dange 5 Reputation points
2023-10-13T13:44:45.5333333+00:00

(Couldn't find any tag for Q# & QDK)

I am using the latest .NET (version: 7.0.402) and OS is Windows 11.

Upon executing

dotnet run

I get:


C:\Users\rames\.nuget\packages\microsoft.quantum.sdk\0.28.302812\Sdk\Sdk.targets(68,5): erro

2812\DefaultItems\../tools/utils/Microsoft.Quantum.Sdk.BuildConfiguration.dll" -v Normal --o 

utput "obj/qsharp/config/qsc.config" --QscReferences "(C:\Users\rames\.nuget\packages\micros 

oft.quantum.csharpgeneration\0.28.302812\build\/../lib/net6.0/Microsoft.Quantum.CSharpGenera 

tion.dll, -1)"" exited with code -2147450730. [C:\Users\rames\Desktop\LNMIIT\Stamdalone-cons 

ole-QSharp\Stamdalone-console-QSharp.csproj]

The build failed. Fix the build errors and run again.

Upon running,

dotnet list package
Project 'Stamdalone-console-QSharp' has the following package references    
[net7.0]:     
Top-level Package                            Requested         Resolved       
> Microsoft.Quantum.CSharpGeneration     (A)   [0.28.302812, )   0.28.302812    
> Microsoft.Quantum.EntryPointDriver     (A)   [0.28.302812, )   0.28.302812    
> Microsoft.Quantum.QSharp.Core                0.28.302812       0.28.302812    
> Microsoft.Quantum.Runtime.Core         (A)   [0.28.302812, )   0.28.302812    
> Microsoft.Quantum.Sdk                        0.28.263081       0.28.263081    
> Microsoft.Quantum.Standard                   0.28.302812       0.28.302812    
> Microsoft.Quantum.Targets.Interfaces   (A)   [0.28.302812, )   0.28.302812  
(A) : Auto-referenced package.

Upon executing,

dotnet --list-sdks

I get

7.0.402 [C:\Program Files\dotnet\sdk]

And,

dotnet --list-runtimes

gives

Microsoft.AspNetCore.App 7.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 7.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

My Stamdalone-console-QSharp.csproj is:

<Project Sdk="Microsoft.Quantum.Sdk/0.28.302812">

  <OutputType>Exe</OutputType>    
      <TargetFramework>net7.0</TargetFramework>  
  </PropertyGroup>
    <PackageReference Include="Microsoft.Quantum.Sdk" Version="0.28.302812" />  
  </ItemGroup>
</Project>
Azure Quantum
Azure Quantum
An Azure service that provides quantum computing and optimization solutions.
61 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,461 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,131 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Ramesh Dange 5 Reputation points
    2023-10-13T15:46:03.1733333+00:00

    Issue resolved. It required .net6.0, which I discovered by printing verbose output (suggested by ChatGPT)! Quite surprising that VS Code didn't consider it necessary to include it in the default error message!

    1 person found this answer helpful.
    0 comments No comments

  2. kobulloc-MSFT 24,321 Reputation points Microsoft Employee
    2023-10-13T20:44:34.6833333+00:00

    Thank you very much for the follow up, @Ramesh Dange !

    I am surprised as well that the .NET 6.0 requirement wasn't included in the error message. We really appreciate you providing the solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer for increased visibility.

    Issue:

    Build error when trying to run a Quantum Development Kit (QDK) project in .NET 7.0 on Windows 11, related to the Microsoft.Quantum.Sdk version and its dependencies.

    • Exited with code -2147450730
    • "The build failed. Fix the build errors and run again."

    Solution (provided by Ramesh Dange):

    Issue resolved. It required .net6.0, which I discovered by printing verbose output (suggested by ChatGPT)! Quite surprising that VS Code didn't consider it necessary to include it in the default error message!

    0 comments No comments