After I add NuGet.Core
package to my csproj as PackageReference, I have no any effect. Next I describe reproduction steps and my project folder content. My question: am I doing something wrong way or it is a dotnet cli bug? I registered an issue and will be track both - this question and the issue.
Steps to reproduce:
dotnet new console
TargetFramework
in csproj
file to net461
dotnet add package NuGet.Core
using NuGet
to Program.cs
(this namespace is exists in NuGet.Core Assembly, I checked)dotnet restore
dotnet build
Result: an error "The type or namespace name 'NuGet' could not be found".
Full content of my project dir:
nuget-tree.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NuGet.Core" Version="2.14.0" />
</ItemGroup>
</Project>
Program.cs:
using System;
using NuGet;
namespace nuget_tree
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
.NET CLI Tools Version: I'm tried on both: 1.0.4
and 2.0.0-preview2-25407-01
I figured out that problem is not in dotnet CLI, but in nuget. I do following:
PM> Install-Package Microsoft.Web.Xdt -Version 2.1.0
PM> Install-Package NuGet.Core -Version 2.13.1
That is worked fine. But if I installed latest version of NuGet.Core
then in packages dir in NuGet.Core subfolder there is no lib
folder with assembly. And so I can't reference it in project. That is all seems weird. Then I decided to clear nuget cache. And this solves my problem. After cache was cleared I can create a new project and successfully use latest NuGet.Core.
To clear cache I used:
nuget locals all -list
- list the local cachesnuget locals all -clear
- clear all caches