Nuget - Package restore failed. Rolling back package changes for 'WebApplication1'. 0

user2727195 picture user2727195 · Feb 6, 2017 · Viewed 62.9k times · Source

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

Answer

Shahrooz Ansari picture Shahrooz Ansari · Jun 23, 2017

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