Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Latest commit

 

History

History
82 lines (57 loc) · 3.37 KB

standalone.md

File metadata and controls

82 lines (57 loc) · 3.37 KB
title author ms.author ms.date ms.topic ms.custom uid
Execute Q# programs without a driver and a host language
KittyYeungQ
kitty
4/24/2020
article
how-to
microsoft.quantum.install.standalone

Q# Command Line Applications

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

Pre-requisites

Installation

While you can build Q# command line applications in any IDE, we highly recommend using Visual Studio Code (VS Code) or Visual Studio IDE for your Q# applications. By using VS Code or Visual Studio and the QDK Visual Studio Code extension you gain access to richer functionality.

Develop with Q# using VS Code

Install the Quantum project templates:

  • Go to View -> Command Palette
  • Select Q#: Install project templates

You now have the Quantum Development Kit installed and ready to use in your own applications and libraries.

  • Create a new project:

    • Go to View -> Command Palette
    • Select Q#: Create New Project
    • Select Standalone console application
    • Navigate to the location on the file system where you would like to create the application
    • Click on the Open new project... button, once the project has been created
  • Inspect the project

    • You should see that a file called Program.qs created, which is a Q# program that defines a simple operation to print a message to the console.
  • Run the application:

    • Go to Terminal -> New Terminal
    • Enter dotnet run
    • 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 Visual Studio Code extension. If you have multiple projects within one VS Code workspace, all projects need to be contained within the same root folder.

Develop with Q# using Visual Studio

Verify the installation by creating a Hello World application

  • Create a new Q# application

    • Go to File -> New -> Project
    • Type Q# in the search box
    • Select Q# Application
    • Select Next
    • Choose a name and location for your application
    • Select Create
  • Inspect the project

    • You should see that a file called Program.qs has been created, which is a Q# program that defines a simple operation to print a message to the console.
  • Run the application

    • Select Debug -> Start Without Debugging
    • You should see the text Hello quantum world! printed to a console window.

Note

  • If you have multiple projects within one Visual Studio solution, all projects contained in the solution need to be in the same folder as the solution, or in one of its subfolders.

What's next?

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