Reputation: 167
I'm trying to run a Q# program that uses Microsoft.Quantum.Extensions.Convert, I added to my project file and included it in the code, but when I run 'dotnet run', I get '/workspace/QSharp/QSharpTest/QSharpTest.csproj : error NU1101: Unable to find package Microsoft.Quantum.Extensions.Convert. No packages exist with this id in source(s): nuget.org'.
QSharpTest.csproj
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Canon"/>
<PackageReference Include="Microsoft.Quantum.Development.Kit"/>
<PackageReference Include="Microsoft.Quantum.Extensions.Convert"/>
</ItemGroup>
</Project>
Operations.qs
namespace QSharpTest
{
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Primitive;
open Microsoft.Quantum.Development.Kit;
open Microsoft.Quantum.Extensions.Convert;
operation HelloQ () : Unit {
let hello = GetHello();
Message(hello);
let multiple = multiply(2, 3);
Message(ToStringI(multiple));
}
function GetHello () : (String) {
return "Hello";
}
function multiply (a : Int, b : Int) : (Int) {
return a*b;
}
}
Upvotes: 0
Views: 255
Reputation: 2032
Microsoft.Quantum.Extensions.Convert
is a namespace, but it is not a separate NuGet package - it is included in Microsoft.Quantum.Development.Kit
package. You should include a package reference to Microsoft.Quantum.Development.Kit
in your project files. You can see examples in existing Q# projects.
To do this automatically, you can create your project from scratch as a Q# project (as described in the documentation) - this will create necessary package references automatically:
dotnet new console -lang Q# --output MyProject
Update: To address your updated question,
You don't need <PackageReference Include="Microsoft.Quantum.Extensions.Convert"/>
in your csproj file - this is namespace, not package name.
You don't need open Microsoft.Quantum.Development.Kit;
in your Q# file - this is package name, not namespace.
You probably need versions of NuGet packages in your csproj file:
<PackageReference Include="Microsoft.Quantum.Canon" Version="0.4.1901.3104" />
<PackageReference Include="Microsoft.Quantum.Development.Kit" Version="0.4.1901.3104" />
Upvotes: 1
Reputation: 933
Would you be willing to provide the contents of your QSharpTest.csproj
file? It sounds like you've added Microsoft.Quantum.Extensions.Convert
as a <PackageReference />
, but as that error says, there's no such package— you probably want an open
statement in your Q# source file itself:
namespace QSharp.Test {
open Microsoft.Quantum.Primitives;
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Extensions.Convert;
// ...
}
As for the question in your title, the Visual Studio Code extension can be installed the same way on Ubuntu as on macOS or Windows 10. See the Quantum Development Kit documentation for details, but one way to do so is to go to the Quantum Development Kit extension page on the Visual Studio Code marketplace and press "Install."
Upvotes: 0