# Q#: How to setup a project correctly (on Linux, command line)?

When setting up projects with Q# I used to start with the given Quick-Starting Guide. Following the tutorial I am able to setup the example problem and the program works well.

However, there seems to be some issues when trying to use the Q# Libraries, e.g., the Arithmetic libraries or Arrays. Consider the following minimal working example created from the tutorial:

Driver.cs  using Microsoft.Quantum.Simulation.Core; using Microsoft.Quantum.Simulation.Simulators; using System.Diagnostics;

 

namespace Microsoft.Quantum.Numerics.Samples { class Program { static void Main(string[] args) { using (var qsim = new QuantumSimulator()) { RunAll.Run(qsim).Wait(); } } } } 

Operation.qs  namespace Bell { open Microsoft.Quantum.Canon; open Microsoft.Quantum.Intrinsic; open Microsoft.Quantum.Arithmetic; // Added this line operation HelloQ () : Unit { Message("Hello quantum world!"); using ( (xQb, yQb) = (Qubit[5], Qubit[5]) ) // And this block { AddI(LittleEndian(xQb), LittleEndian(yQb)); } } } 

Where only the line indicating the usage of the Microsoft.Quantum.Arithmetic library and the code block using the AddI($\cdot$) operation (or function?) have been added to the tutorial code. This results in an error :

error QS5022: No identifier with that name exists.

Whereas I am sure that this is not a Q# issue, I do wonder if anybody stumbled upon a similar problem, or know how to fix that?

Solution: Using any of the example code from GitHub, all functionalities that I was able to add work without any problems. Using such a sample project I can just delete all the code and rewrite it, which works well.

Question: While copy-paste-delete using sample projects is a viable approach to set up new projects, I do wonder what I am missing in the "normal" project setup?

(I tried the fix in Visual Studio, but I'm pretty sure that will work with command line as well)

You need to add Microsoft.Quantum.Numerics NuGet package reference to your project, as described here. That is the package in which AddI is defined, and by default a newly created Q# project doesn't include this reference.

If you copy an existing project from Numerics section of the samples, it will already include the reference to this package (see, for example, this .csproj file).

• Thanks, it works. I do feel a little bad though, especially since I have more questions that I was not able to figure out :/ (but that might not be worthy of opening posts, since they are apparently easy to solve :D) – Fleeep Aug 12 '19 at 9:10
• It seems fair to ask questions that can be easy for somebody but you can't solve - that's what StackExchange network is for? – Mariia Mykhailova Aug 12 '19 at 15:53
• @Fleeep Mariia is exactly right - One aim is to be a repository of questions and answers and another is to help people find answers. Just because someone (who happens to work at the company that wrote the thing you're asking the question about!) knows the answer easily doesn't make it a worthless question! – Mithrandir24601 Aug 13 '19 at 9:19

According to the [Microsoft website][1], basically you create a new C# project with language Q#. That should do the trick.

$$dotnet new console -lang Q# -o myApp$$ cd MyApp
$$dotnet run Update: To add dependencies, such as nuGet, go to your project folder, open the terminal, and run this: $$ dotnet add package Microsoft.Quantum.Numerics


[1]: https://docs.microsoft.com/en-us/quantum/install-guide/csharp?view=qsharp-preview

• This will not add the necessary NuGet package reference... – Mariia Mykhailova Aug 13 '19 at 15:58
• To add a package from the terminal, simply go to the project folder, and run commands like this way, $cd myApp $ dotnet add ypurDesiredPackage . So to add nuGet, you add \$ dotnet add package Microsoft.Quantum.Numerics` – Qazi Fahim Farhan Aug 14 '19 at 10:24