Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 570
user2727195 Avatar asked Feb 06 '17 02:02

user2727195


People also ask

How do I fix NuGet recovery failed?

Quick solution for Visual Studio usersSelect the Tools > NuGet Package Manager > Package Manager Settings menu command. Set both options under Package Restore. Select OK. Build your project again.

How do I force a NuGet package to restore?

Restore NuGet packagesNavigate to Tools > Options > NuGet Package Manager > General, and then select the Allow NuGet to download missing packages check box under Package Restore. Enabling Restore NuGet Packages. In Solution Explorer, right-click the solution, and then select Restore NuGet Packages.

How do I run a NuGet package restore in Visual Studio?

To do that, go to Tools, NuGet Packaged Manager, then go to Package Manager Settings. Go to the General section, and then make sure you have a checkmark for Allow NuGet to download missing packages and also to automatically check for missing packages during the build in Visual Studio.

How do I restore NuGet packages in Visual Studio 2013?

In Visual Studio, click Project > Enable NuGet Package Restore > answer Yes in the dialog. Right-click on the gplus-quickstart-csharp project and select Manage NuGet Packages. Click Restore on the Manage NuGet Packages window. This will install the Google API Client libraries.


1 Answers

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

like image 132
Shahrooz Ansari Avatar answered Sep 24 '22 18:09

Shahrooz Ansari