From 2373886c11a8f0cdc4dc35bec089d3581bbbbf9d Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Thu, 23 Jan 2020 18:53:39 -0800 Subject: [PATCH 1/9] adding AdditionalQscArguments property --- src/QuantumSdk/README.md | 3 +++ src/QuantumSdk/Sdk/Sdk.targets | 22 ++-------------------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/QuantumSdk/README.md b/src/QuantumSdk/README.md index 70ea1e6bcc..a30d6ca3e5 100644 --- a/src/QuantumSdk/README.md +++ b/src/QuantumSdk/README.md @@ -93,6 +93,9 @@ The NuGet version of the Sdk package. The following properties can be configured to customize the build: +- `AdditionalQscArguments`: +May contain additional arguments to pass to the Q# command line compiler. Valid additional arguments are `--emit-dll`, or `--no-warn` followed by any number of integers specifying the warnings to ignore. + - `CsharpGeneration`: Specifies whether to generate C# code as part of the compilation process. Setting this property to false may prevent certain interoperability features or integration with other pieces of the Quantum Development Kit. diff --git a/src/QuantumSdk/Sdk/Sdk.targets b/src/QuantumSdk/Sdk/Sdk.targets index 6b850f40df..2e3b4a13bd 100644 --- a/src/QuantumSdk/Sdk/Sdk.targets +++ b/src/QuantumSdk/Sdk/Sdk.targets @@ -43,25 +43,7 @@ + BeforeTargets="BeforeCsharpCompile;BeforeBuild"> @@ -89,7 +71,7 @@ <_QscCommandReferencesFlag Condition="@(ResolvedQsharpReferences->Count()) > 0">--references "@(ResolvedQsharpReferences,'" "')" <_QscCommandLoadFlag Condition="@(_PrioritizedResolvedQscReferences->Count()) > 0">--load "@(_PrioritizedResolvedQscReferences,'" "')" <_QscPackageLoadFallbackFoldersFlag Condition="'$(OutputPath)' != '' And '$(MSBuildProjectDirectory)' != ''">--package-load-fallback-folders $(MSBuildProjectDirectory)/$(OutputPath) - <_QscCommandArgs>--proj "$(PathCompatibleAssemblyName)" $(_QscCommandDocsFlag) $(_QscCommandInputFlag) $(_QscCommandOutputFlag) $(_QscCommandReferencesFlag) $(_QscCommandLoadFlag) $(_QscPackageLoadFallbackFoldersFlag) + <_QscCommandArgs>--proj "$(PathCompatibleAssemblyName)" $(_QscCommandDocsFlag) $(_QscCommandInputFlag) $(_QscCommandOutputFlag) $(_QscCommandReferencesFlag) $(_QscCommandLoadFlag) $(_QscPackageLoadFallbackFoldersFlag) $(AdditionalQscArguments) <_QscCommandArgsFile>$(QscBuildConfigOutputPath)qsc.rsp $(QscExe) build --format MsBuild $(_VerbosityFlag) --response-files $(_QscCommandArgsFile) From d9eaece7ce2375c8181da3824c8d6f86bc9ded2c Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Fri, 24 Jan 2020 17:31:32 -0800 Subject: [PATCH 2/9] disabling QsharpCompile target for design time builds --- src/QuantumSdk/Sdk/Sdk.targets | 1 + 1 file changed, 1 insertion(+) diff --git a/src/QuantumSdk/Sdk/Sdk.targets b/src/QuantumSdk/Sdk/Sdk.targets index 2e3b4a13bd..a96f16b5d0 100644 --- a/src/QuantumSdk/Sdk/Sdk.targets +++ b/src/QuantumSdk/Sdk/Sdk.targets @@ -42,6 +42,7 @@ From 36f7ea96b1c50d93bf2fe56480249efcb61d844f Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Fri, 24 Jan 2020 17:32:00 -0800 Subject: [PATCH 3/9] using a (hardcoded version of) the Quantum Sdk for the Example project --- .../Simulation/Example/Example.csproj | 75 ++++++------------- 1 file changed, 22 insertions(+), 53 deletions(-) diff --git a/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj b/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj index 0de3627b7b..fc2be0c1de 100644 --- a/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj +++ b/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj @@ -1,69 +1,38 @@ - + + + Detailed Exe netcoreapp3.0 - x64 - 0.10 + false + dotnet "../../../CommandLineTool/bin/$(Configuration)/netcoreapp3.0/qsc.dll" + "..\Target\bin\$(Configuration)\netstandard2.1\Simulation.dll" + --load $(SimulationTarget) - - - false - - - false - - - - - ExecutionTests\ - generated\ - "..\Target\bin\$(Configuration)\netstandard2.1\Simulation.dll" - dotnet "../../../CommandLineTool/bin/$(Configuration)/netcoreapp3.0/qsc.dll" + generated/ + ExecutionTests/ - - - + + + false - + $(ExecutionTestsDir)%(RecursiveDir)%(Filename)%(Extension) - + - - - - - - - - - - - - - - + + + false + + + - - - - - - - - - $(QscExe) build -v diag --format MsBuild --proj "$(MSBuildProjectName)" -i "@(QsSourceFiles,'" "')" -r "@(QsReferences,'" "')" -o $(GenFilesDir) --load "$(SimulationTarget)" - - - - - - - - + + From 45520b32ae05d52ed35d9df1fb6aab5daa58b877 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Fri, 24 Jan 2020 17:51:11 -0800 Subject: [PATCH 4/9] disabling the two execution tests to get a suitable Sdk version to use for the Example project --- .../TestTargets/Simulation/Example/Example.csproj | 8 ++++---- src/QsCompiler/Tests.Compiler/ExecutionTests.fs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj b/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj index fc2be0c1de..9637a2cbd1 100644 --- a/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj +++ b/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj @@ -4,15 +4,15 @@ Detailed Exe netcoreapp3.0 - false - dotnet "../../../CommandLineTool/bin/$(Configuration)/netcoreapp3.0/qsc.dll" - "..\Target\bin\$(Configuration)\netstandard2.1\Simulation.dll" - --load $(SimulationTarget) + false generated/ ExecutionTests/ + "..\Target\bin\$(Configuration)\netstandard2.1\Simulation.dll" + --load $(SimulationTarget) + dotnet "../../../CommandLineTool/bin/$(Configuration)/netcoreapp3.0/qsc.dll" diff --git a/src/QsCompiler/Tests.Compiler/ExecutionTests.fs b/src/QsCompiler/Tests.Compiler/ExecutionTests.fs index a4a4db38cd..e123951e62 100644 --- a/src/QsCompiler/Tests.Compiler/ExecutionTests.fs +++ b/src/QsCompiler/Tests.Compiler/ExecutionTests.fs @@ -40,7 +40,7 @@ type ExecutionTests (output:ITestOutputHelper) = AssertEqual expectedOutput out - [] + //[] member this.``Specialization Generation for Conjugations`` () = ExecuteAndCompareOutput "ConjugationsInBody" " @@ -139,7 +139,7 @@ type ExecutionTests (output:ITestOutputHelper) = " - [] + //[] member this.``Referencing Projects and Packages`` () = ExecuteAndCompareOutput "PackageAndProjectReference" " From 029b1a4042faf1cc5219b14f957501f570c6c9b3 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Fri, 24 Jan 2020 18:11:08 -0800 Subject: [PATCH 5/9] reenabling execution tests --- src/QsCompiler/TestTargets/Simulation/Example/Example.csproj | 2 +- src/QsCompiler/Tests.Compiler/ExecutionTests.fs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj b/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj index 9637a2cbd1..16c9cb9909 100644 --- a/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj +++ b/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj @@ -1,4 +1,4 @@ - + Detailed diff --git a/src/QsCompiler/Tests.Compiler/ExecutionTests.fs b/src/QsCompiler/Tests.Compiler/ExecutionTests.fs index e123951e62..a4a4db38cd 100644 --- a/src/QsCompiler/Tests.Compiler/ExecutionTests.fs +++ b/src/QsCompiler/Tests.Compiler/ExecutionTests.fs @@ -40,7 +40,7 @@ type ExecutionTests (output:ITestOutputHelper) = AssertEqual expectedOutput out - //[] + [] member this.``Specialization Generation for Conjugations`` () = ExecuteAndCompareOutput "ConjugationsInBody" " @@ -139,7 +139,7 @@ type ExecutionTests (output:ITestOutputHelper) = " - //[] + [] member this.``Referencing Projects and Packages`` () = ExecuteAndCompareOutput "PackageAndProjectReference" " From 0b5a88439df0015a4ff05eeb9ada0da909a5a079 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Fri, 24 Jan 2020 18:37:04 -0800 Subject: [PATCH 6/9] that works but we should strip trailing slashes... --- .../Simulation/Example/Example.csproj | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj b/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj index 16c9cb9909..ebd8eabfeb 100644 --- a/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj +++ b/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj @@ -10,8 +10,8 @@ generated/ ExecutionTests/ - "..\Target\bin\$(Configuration)\netstandard2.1\Simulation.dll" - --load $(SimulationTarget) + ../Target/bin/$(Configuration)/netstandard2.1/Simulation.dll + --load $(SimulationTarget) dotnet "../../../CommandLineTool/bin/$(Configuration)/netcoreapp3.0/qsc.dll" @@ -27,12 +27,21 @@ + + false + false - - + + + + + + + + From ce98e75c08971e14a5660bacdba4caf02d26d288 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Sun, 26 Jan 2020 18:51:00 -0800 Subject: [PATCH 7/9] taking care of slashes, and adding some docs on the defined item groups --- src/QuantumSdk/DefaultItems/DefaultItems.targets | 10 +++------- src/QuantumSdk/QuantumSdk.nuspec | 10 +++++----- src/QuantumSdk/README.md | 16 ++++++++++++++++ src/QuantumSdk/Sdk/Sdk.targets | 4 +++- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/QuantumSdk/DefaultItems/DefaultItems.targets b/src/QuantumSdk/DefaultItems/DefaultItems.targets index f6863306f2..764107d873 100644 --- a/src/QuantumSdk/DefaultItems/DefaultItems.targets +++ b/src/QuantumSdk/DefaultItems/DefaultItems.targets @@ -42,12 +42,15 @@ $([System.String]::Copy('$(AssemblyName)').Replace(' ','')) $(BaseIntermediateOutputPath)qsharp/ + $([MSBuild]::Unescape('$(GeneratedFilesOutputPath)').Replace('\','/')) $(GeneratedFilesOutputPath)/ $(GeneratedFilesOutputPath)docs/ + $([MSBuild]::Unescape('$(QsharpDocsOutputPath)').Replace('\','/')) $(QsharpDocsOutputPath)/ $(GeneratedFilesOutputPath)config/ + $([MSBuild]::Unescape('$(QscBuildConfigOutputPath)').Replace('\','/')) $(QscBuildConfigOutputPath)/ @@ -56,30 +59,23 @@ - - <_RelevantQscProjectReference Remove="@(_RelevantQscProjectReference)"/> <_RelevantQscProjectReference Include="@(QscProjectReference->WithMetadataValue('ExecutionTarget',''))" /> <_RelevantQscProjectReference Include="@(QscProjectReference->WithMetadataValue('ExecutionTarget','Any'))" /> <_RelevantQscProjectReference Include="@(QscProjectReference->WithMetadataValue('ExecutionTarget','$(ExecutionTarget)'))" /> - - <_RelevantQscPackageReference Remove="@(_RelevantQscPackageReference)"/> <_RelevantQscPackageReference Include="@(QscPackageReference->WithMetadataValue('ExecutionTarget',''))" /> <_RelevantQscPackageReference Include="@(QscPackageReference->WithMetadataValue('ExecutionTarget','Any'))" /> <_RelevantQscPackageReference Include="@(QscPackageReference->WithMetadataValue('ExecutionTarget','$(ExecutionTarget)'))" /> - <_RelevantQscPackageReferencePathProperty Remove="@(_RelevantQscPackageReferencePathProperty)"/> <_RelevantQscPackageReferencePathProperty Include="@(_RelevantQscPackageReference->'Pkg$([System.String]::Copy('%(_RelevantQscPackageReference.Identity)').Replace('.','_'))')" /> - - - - - - - + + + + + diff --git a/src/QuantumSdk/README.md b/src/QuantumSdk/README.md index a30d6ca3e5..d76121ce48 100644 --- a/src/QuantumSdk/README.md +++ b/src/QuantumSdk/README.md @@ -116,6 +116,22 @@ Directory where any generated documentation will be saved. [comment]: # (TODO: document QscBuildConfigExe, QscBuildConfigOutputPath) +## Defined item groups ## + +The following configurable item groups are used by the Sdk: + +- `PackageLoadFallbackFolder`: +Contains the directories where the Q# compiler will look for a suitable dll if a qsc reference or one if its dependencies cannot be found. By default, the project output path is included in this item group. + +- `PackageReference`: +Contains all referenced NuGet packages. Package references for which the `IsQscReference` attribute is set to "true" may extend the Q# compiler and any implemented rewrite steps will be executed as part of the compilation process. See [this section](#extending-the-q#-compiler) for more details. + +- `ProjectReference`: +Contains all referenced projects. Project references for which the `IsQscReference` attribute is set to "true" may extend the Q# compiler and any implemented rewrite steps will be executed as part of the compilation process. See [this section](#extending-the-q#-compiler) for more details. + +- `QsharpCompile`: +Contains all Q# source files included in the compilation. + # Sdk Packages # To understand how the content in this package works it is useful to understand how the properties, item groups, and targets defined in the Sdk are combined with those defined by a specific project. diff --git a/src/QuantumSdk/Sdk/Sdk.targets b/src/QuantumSdk/Sdk/Sdk.targets index a96f16b5d0..68e6c5af55 100644 --- a/src/QuantumSdk/Sdk/Sdk.targets +++ b/src/QuantumSdk/Sdk/Sdk.targets @@ -62,6 +62,8 @@ + + @@ -71,7 +73,7 @@ <_QscCommandInputFlag Condition="@(QsharpCompile->Count()) > 0">--input "@(QsharpCompile,'" "')" <_QscCommandReferencesFlag Condition="@(ResolvedQsharpReferences->Count()) > 0">--references "@(ResolvedQsharpReferences,'" "')" <_QscCommandLoadFlag Condition="@(_PrioritizedResolvedQscReferences->Count()) > 0">--load "@(_PrioritizedResolvedQscReferences,'" "')" - <_QscPackageLoadFallbackFoldersFlag Condition="'$(OutputPath)' != '' And '$(MSBuildProjectDirectory)' != ''">--package-load-fallback-folders $(MSBuildProjectDirectory)/$(OutputPath) + <_QscPackageLoadFallbackFoldersFlag Condition="@(ResolvedPackageLoadFallbackFolders->Count()) > 0">--package-load-fallback-folders "@(ResolvedPackageLoadFallbackFolders,'" "')" <_QscCommandArgs>--proj "$(PathCompatibleAssemblyName)" $(_QscCommandDocsFlag) $(_QscCommandInputFlag) $(_QscCommandOutputFlag) $(_QscCommandReferencesFlag) $(_QscCommandLoadFlag) $(_QscPackageLoadFallbackFoldersFlag) $(AdditionalQscArguments) <_QscCommandArgsFile>$(QscBuildConfigOutputPath)qsc.rsp $(QscExe) build --format MsBuild $(_VerbosityFlag) --response-files $(_QscCommandArgsFile) From cbf567c7098d63dfb221adac0b1edc97884a1387 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Sun, 26 Jan 2020 20:21:24 -0800 Subject: [PATCH 8/9] don't change nuspec for Sdk --- src/QuantumSdk/QuantumSdk.nuspec | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/QuantumSdk/QuantumSdk.nuspec b/src/QuantumSdk/QuantumSdk.nuspec index 284dff05e9..f24e7cc016 100644 --- a/src/QuantumSdk/QuantumSdk.nuspec +++ b/src/QuantumSdk/QuantumSdk.nuspec @@ -19,10 +19,10 @@ - - - - - + + + + + From d6829209c64fb9fbd85cceea73fd7ef7825654d5 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Sun, 26 Jan 2020 22:23:10 -0800 Subject: [PATCH 9/9] some other issue ... --- src/QuantumSdk/Sdk/Sdk.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/QuantumSdk/Sdk/Sdk.targets b/src/QuantumSdk/Sdk/Sdk.targets index 68e6c5af55..8ef88a3cd5 100644 --- a/src/QuantumSdk/Sdk/Sdk.targets +++ b/src/QuantumSdk/Sdk/Sdk.targets @@ -63,7 +63,7 @@ - +