microsoft / qsharp-compiler

Q# compiler, command line tool, and Q# language server
https://docs.microsoft.com/quantum
MIT License
682 stars 171 forks source link

Set CopyLocalLockFileAssemblies to False for Q# projects by default #471

Closed vadym-kl closed 4 years ago

vadym-kl commented 4 years ago

Isssue

Currently CopyLocalLockFileAssemblies is set to true and dotnet copies assemblies without pdb files and documentation xml files. This means that pdb files are not found and debugging is limited.

Workaround

Add a line <CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies> to the project file as shown below for the case of Test projects.

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

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <IsPackable>false</IsPackable>
    <CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Quantum.Xunit" Version="0.10.2001.2831" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
    <PackageReference Include="xunit" Version="2.4.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
    <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
  </ItemGroup>

</Project>

Context

For the following test file:

namespace qsharp_unit_test_example {

    open Microsoft.Quantum.Canon;
    open Microsoft.Quantum.Diagnostics;
    open Microsoft.Quantum.Intrinsic;

    operation FailH ( q : Qubit) : Unit {
        H(q);
        fail "d";
    }

    @Test("QuantumSimulator")
    operation AllocateQubit2 () : Unit {
        using( qs = Qubit[5] ) {
            ApplyToEach(FailH, qs);
        }
    }
}

With this option enabled call stack error message (line 4) points to GitHub as following:

  Standard Output Messages:
 Unhandled exception. Microsoft.Quantum.Simulation.Core.ExecutionFailException: d
  ---> qsharp_unit_test_example.FailH on D:\repos\qsharp-unit-test-example\Tests.qs:line 10
    at Microsoft.Quantum.Canon.ApplyToEach on https://github.com/microsoft/QuantumLibraries/blob/7327e6a9901b2fede48797fb8537982b87df545a/Standard/src/Canon/Combinators/ApplyToEach.qs#L155
    at qsharp_unit_test_example.AllocateQubit2 on D:\repos\qsharp-unit-test-example\Tests.qs:line 16

Without the option enabled error (line 4) points to path on build machine, it looks like:

  Standard Output Messages:
 Unhandled exception. Microsoft.Quantum.Simulation.Core.ExecutionFailException: d
  ---> qsharp_unit_test_example.FailH on D:\repos\qsharp-unit-test-example\Tests.qs:line 10
    at Microsoft.Quantum.Canon.ApplyToEach on D:\a\1\s\submodules\QuantumLibraries\Standard\src\Canon\Combinators\ApplyToEach.qs:line 0
    at qsharp_unit_test_example.AllocateQubit2 on D:\repos\qsharp-unit-test-example\Tests.qs:line 0
bettinaheim commented 4 years ago

CopyLocalLockFileAssemblies is no longer needed and removed with PR #472.