61
votes

It's my own custom nuget package that I've not published yet and testing locally.

The nuget package consists of a dll file and nuspec file is as follows.

<?xml version="1.0"?>
<package >
  <metadata>
    <id>MyLib</id>
    <version>1.0.0</version>
    <authors>Author</authors>
    <owners>Owner</owners>
    <licenseUrl>license url</licenseUrl>
    <projectUrl>project url</projectUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>some description</copyright>
    <tags>Tag1 Tage2</tags>
  </metadata>
  <files>
    <file src="bin\Debug\netstandard1.4\*.dll" target="lib" />
    <file src="bin\Debug\netstandard1.4\*.pdb" target="lib" />
  </files>
</package>

I've copied the nupkg file to a location and added it to the

Visual studio Tools -> Options -> Packages -> sources directory 

Error:

Package MyLib 1.0.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package MyLib 1.0.0 supports: net (.NETFramework,Version=v0.0)
Package restore failed. Rolling back package changes for 'WebApplication1'.

Not sure how can I resolve the issue or find more information.

More Info

The dll file was created using template (.Net Framework 4.5.2)

Templates -> Visual C# -> .NET Core -> Class Library (.NET Standard)

The web application was crated using template. (Empty Web Application)

Templates -> Visual C# -> .NET Core -> ASP.NET Core Web Application (.NET Core)

Edit

I found more details under Output window

One or more packages are incompatible with .NETCoreApp,Version=v1.0.

What kind of class library should I create which is compatible with .NETCoreApp?

Edit2

I saw this URL. it suggests to create the nupkg using dotnet.exe pack --no-build whereas earlier I downloaded the nuget.exe from nuget.org to create the package.

I tried above command but then visual studio says

"... Target pack doesn't exists in the project ... "

Followed instructions on this site as well but failed URL

3
sorry for confusion, why did you mention .Net Framework 4.5.2 if you want to target .netcore?Oleg Bogdanov
yes it's confusing for me too, when I select New Project -> Templates -> .Net Core -> Class Library Framework (.NET Standard), the .NET Framework 4.5.2 is listed on the top of the dialog box in the drop down menu (that's why I mentioned), so I'm not sure what kind of project template should I pick to create the right kind of dll to be used with .net core.user2727195
Have you seen this one ? Namely that With NuGet 4.0 and .NET Core projects, package metadata is contained directly in the .csproj Oleg Bogdanov
Did you changed your application name or namespace?Aravin
@user2727195 friend please acc my answerShahrooz Ansari

3 Answers

161
votes

You need clear the Nuget Cache. To do this, go to Tools -> Options and click on it like this picture enter image description here

24
votes

Your project is targetting an incompatible version of .Net Framework. Right click on the project, select properties and note the value of the Target Framework. Look at the Nuget package for Microsoft and then install a more suitable NuGet package. Either install the older version of the NuGet package or update your project to target a newer version.

0
votes

I had to change the Build Configuration due to an NU1603: warning.

In my Build configuration the "Treat warnings as errors" was set to All.

This was blocking Nuget from upgrading the Package due to the NU1603 warning. enter image description here