Develop with Q# command line applications

Q# programs can be executed on their own, without a driver in a host language like C#, F#, or Python.

Prerequisites

Installation

While you can build Q# command line applications in any IDE, we recommend using Visual Studio Code (VS Code) or Visual Studio IDE for your Q# applications. Developing in these environments includes the rich functionality of the QDK extension, which includes warnings, syntax highlighting, project templates, and more.

To configure VS Code:

  1. Download and install VS Code (Windows, Linux and Mac).
  2. Install the Microsoft QDK for VS Code.

To configure Visual Studio:

  1. Download and install Visual Studio 16.3 or greater, with the .NET Core cross-platform development workload enabled.
  2. Download and install the Microsoft QDK.

To install the QDK for another environment, enter in the command line:

dotnet new -i Microsoft.Quantum.ProjectTemplates

Develop with Q#

Follow the instructions at the tab corresponding to your environment.

Install the Q# project templates:

  1. Open VS Code.
  2. Click View -> Command Palette.
  3. Select Q#: Install project templates.

When Project templates installed successfully displays, the QDK is ready to use with your own applications and libraries.

To create a new project:

  1. Click View -> Command Palette and select Q#: Create New Project.
  2. Click Standalone console application.
  3. Navigate to the location to save the project and click Create Project.
  4. When the project is successfully created, click Open new project... in the lower right.

Inspect the project. You should see a source file named Program.qs, which is a Q# program that defines a simple operation to print a message to the console.

To run the application:

  1. Click Terminal -> New Terminal.
  2. At the terminal prompt, enter dotnet run.
  3. You should see the following text in the output window Hello quantum world!

Note

Workspaces with multiple root folders are not currently supported by the VS Code Q# extension. If you have multiple projects within one VS Code workspace, all projects need to be contained within the same root folder.

Next steps

Now that you have installed the Quantum Development Kit in your preferred environment, you can write and run your first quantum program.