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

69,030

Solution 1

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

Solution 2

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.

Solution 3

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

Share:
69,030
user2727195
Author by

user2727195

Updated on November 14, 2020

Comments

  • user2727195
    user2727195 over 3 years

    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