Building and modifying Q# Libraries - q#

How can the libraries (https://github.com/microsoft/QuantumLibraries) be modified locally? For example, creating references to the Quantum Chemistry library only uses the prebuilt DLL. Is there a way to reference the local Quantum Chem library, make edits to that code, and see those changes reflected? Thanks.

The Quantum Development Kit uses the .NET Core SDK to find and link together the various Q# libraries, in particular through C# project files (*.csproj).
Within a C# project file, you can declare a dependency to another library using either a package reference or a project reference.
Package references (e.g.: <PackageReference Include="Microsoft.Quantum.Standard" Version="0.7.1905.3109" />) instruct the .NET Core SDK to download a package from NuGet.org with a given name and version and then link to all DLLs contained in the project.
By contrast, project references (e.g.: <ProjectReference Include="..\..\..\Standard\src\Standard.csproj" />) instruct the .NET Core SDK to first build the referenced project, then link to its DLL.
To use the libraries built from https://github.com/microsoft/QuantumLibraries, we generally recommend using package references, as project references across different repositories can be difficult to manage — you need for the path to a project file to be predictable, which can be hard to do in that case.
This is why we've taken the strategy with the QuantumLibraries repo that references within the repo are project references, while references to other parts of the Quantum Development Kit are package references.
For example, the chemistry library runtime uses a project reference to link to the version of the standard libraries in the same repo, but samples in https://github.com/microsoft/Quantum use package references:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.1.1" />
<PackageReference Include="Microsoft.Quantum.Standard" Version="0.7.1905.3109" />
<PackageReference Include="Microsoft.Quantum.Chemistry" Version="0.7.1905.3109" />
<PackageReference Include="Microsoft.Quantum.Development.Kit" Version="0.7.1905.3109" />
<PackageReference Include="Microsoft.Quantum.Research" Version="0.7.1905.3109" />
</ItemGroup>
<ItemGroup>
<Compile Update="Program.cs">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Compile>
</ItemGroup>
</Project>
That said, if you're locally testing a contribution you'd like to make to the Quantum Development Kit, linking to the Q# standard and chemistry libraries using project references can sometimes be helpful until a new package including your contribution is built and published to NuGet.org.

Related

VS Code - debugging referenced project (.NET Core)

How can I force debbuger in Visual Studio Code to step into method which is defined in project which I added reference to? I am referencing Encog library which is outside the working directory like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<RootNamespace>IDS_CS</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\encog-dotnet-core-master\encog-core-cs\encog-core-cs.csproj" />
</ItemGroup>
</Project>
Debugger starts and everything seems fine, however I cannot step into method which is implemented in the Encog librarye.
Any solution? Thanks!
In all of your *.csproj (C# project) files that you want to debug in vs-code, be sure to add the <DebugType>portable</DebugType> in a <PropertyGroup> option. Below is a snippet of how I have all of my *.csproj files setup. After doing this I was able to debug step-into the main web application as well as any of the code referenced from one of my other projects to support separation of concerns: my logic lair layer :) vs. my model layer vs. my data layer, etc.
In all your *.csproj files:
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DebugType>portable</DebugType>
</PropertyGroup>
A bit more info can be found here if you have project.json files instead of *.csproj files.

csproj: Reference a dll file and Librarys

Im new to csproj and msbuild and im trying to Build a small third Party PlugIn for Unity. The Problem is that the view Libs im using are not in Unity. So i have to build a separate PlugIn for Unity. Can somebody show me how to Reference a dll and a lib in csproj. The following Attributes im using are:
<ItemGroup>
<Reference Include="System.Threading" />
<Reference Include="System.Windows.Storage" />
<Reference Include="./bin/Windows.Devices.Enumeration.dll" />
</ItemGroup>
Also i tried PackageReference with Nuget. But at first i want to use the normal way to reference libs with csproj. Or do i have to use nuget? Don`t know. For the build i use Visual Studio Code with the specific PlugIns.
Thanks and Cheers.
You can use dlls in your Unity project by putting them in the Assets/Plugins folder.
https://docs.unity3d.com/Manual/SpecialFolders.html
If you want to have your code build to a separate dll, you can use assembly definition files.
https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html

Nuget packages bundled in teamcity not installing documentation files

So basically I am building nuget packages in TeamCity via a .proj file that runs a "pack" target:
<MSBuild
Projects="$(MSBuildProjectDirectory)\PROJNAME.csproj"
Targets="Rebuild;pack"
Properties="Configuration=$(Configuration);Version=$(BUILD_NUMBER)" />
With an artifact output of:
PROJNAME\bin\Release\PROJNAME.%build.number%.nupkg
This works nicely for basic consuming of the nuget package, however I am having trouble getting the documentation xml files to work.
I have looked inside the output nupkg and I see that the documentation xml is actually bundled and included in the package, however the problem is that when I finally restore nuget packages in my consuming project, the dll gets copied across as expected, however the documentation does not.
I wondered if this is because of the TC generated .nuspec file, and if I may need to abandon teamcities nuspec and create my own, however I was hoping to avoid this, given it works nicely the way it is, and handles versioning etc.
Is there a simple way to include documentation xml when the package is restored?
In the end i found it came down to 3 things, being:
Ensure projects configuration is set to generate documentation.
Either by adding code manually such as:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"><DocumentationFile>bin\$(Configuration)\netstandard2.0\Project.documentation.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <DocumentationFile>bin\$(Configuration)\netstandard2.0\Project.documentation.xml</DocumentationFile>
</PropertyGroup>
Or alternatively via the Visual Studio Project properties menu, if you are doing it through VS also make sure you do it for all configurations (as depicted as A in the picture below):
Add EnableDocumentationFile to your .csproj file, eg:
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>project</RootNamespace>
<Configurations>Debug;Release</Configurations>
<EnableDocumentationFile>true</EnableDocumentationFile>
</PropertyGroup>
and most importantly let your project know (again in your .csproj) that it should be copying over the documentation file, and use PackageFlatten if you want it to appear at the same level as your package dll:
<ItemGroup>
<None Remove="bin\$(Configuration)\netstandard2.0\Project.documentation.xml" />
</ItemGroup>
<ItemGroup>
<Content Include="bin\$(Configuration)\netstandard2.0\Project.documentation.xml">
<Pack>true</Pack>
<PackageCopyToOutput>true</PackageCopyToOutput>
<PackageFlatten>true</PackageFlatten>
</Content>
</ItemGroup>

How do I deploy XULRunner folder to output directory after installing abcpdf gecko via nuget?

I installed the ABCpdf.ABCGecko package via nuget, and it gave me this dialog:
Finished! Please deploy the XULRunner folder to your output directory manually.
I don't really know wtf this means... I have an idea, but don't know precisely where or how to modify my build configuration to allow this to occur. Has anyone done this, and if so, how?
My original attempted answer worked fine for my development setup, but didn't work on our staged deployment setup, as for some reason it didn't include the XULRunner files inside the web package created using MSDeploy. I've found what seems to be a simpler setup, below:
<ItemGroup>
<Content Include="XULRunner\**\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
I'm not 100% sure if this works universally, but it seems to work better in every development and deployment scheme I've encountered thus far.
I found how to accomplish this via this SO answer. The relevant changes to the project's .csproj file are below:
<Target Name="AfterBuild">
<CallTarget Targets="CopyXULRunnerToDeployFolder" />
</Target>
<Target Name="CopyXULRunnerToDeployFolder">
<ItemGroup>
<MyFiles Include="XULRunner\**\*.*" />
</ItemGroup>
<Microsoft.Build.Tasks.Copy SourceFiles="#(MyFiles)" DestinationFiles="#(MyFiles->'$(OutputPath)\XULRunner\%(RecursiveDir)%(Filename)%(Extension)')"/>
</Target>

Asp.net MVC 2 Localization Problem in dev

I work on a multi culture web project. I use Localize and Global Ressources(resx) as multilang technology.
I work in team with 2 developer. How can we share .resx . When my teammate give me the 2 Files ( myfile.resx and myfile.Designer.cs) and I include it in my project, there is no way i can add some new string in the file. The new string seem to not be copy in the myfile.Designer.cs ...
I Miss something here.
I Use Asp.net MVC 2
If you are just manually adding an existing RESX and its designer file to your project then you might have to manually connect them together so that VS knows they are related. You will have to manually edit your .csproj file. Here's an example of how to connect the two:
<ItemGroup>
<Compile Include="Resources\MyResources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>MyResources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\MyResources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>MyResources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>