I can't seem to add NuGet packages to a newly created ASP.NET Core Web application.
Reinstalled Visual Studio just now, no difference.
The error I get is: Operation failed as details for project WebApplication2 could not be loaded.
I don't have Resharper installed.
How do I analyze and solve this?
NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe):
Package Manager Console version 4.5.0.4685
dotnet.exe --version (if appropriate):
2.1.2
VS version (if appropriate):
2017 Enterprise, version 15.5.2
OS version (i.e. win10 v1607 (14393.321)):
10.0.14393
Worked before? If so, with which NuGet version:
Nope
Create a new ASP.NET Core Web Application (.NET Core 1.1 or 2.0) or .NET core class library or .NET core console application
Add a NuGet package (for instance AutoMapper or Newtonsoft.Json) to the project.
The error 'The operation failed as details for project
Adding NuGet packages does work with a .NET Framework class library, just not with a .NET Core application. I do notice yellow warning signs in the Solution Explorer regarding dependencies (see attachment). Tried also with .NET Core 1.1, same error.
Does the project restore and build successfully after creating it before adding the new package?
Yes, after I perform 'dotnet restore', the solution builds succesfully. The yellow icons remain though. But no NuGet packages can be added, always the mentioned error message.
Running this from the command line is a different scenario from restoring in VS and seeing errors.
If you only do a file > new project and wait (no command line operations) does it work? And does it work after closing and reopening the solution?
When I build directly after I created the project, the build output is:
Error occurred while restoring NuGet packages: The operation failed as details for project WebApplication3 could not be loaded.
1>------ Build started: Project: WebApplication3, Configuration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\2.1.2\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(327,5): error : Assets file '
1>C:\Program Files\dotnet\sdk\2.1.2\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(167,5): error : Assets file '
1>Done building project "WebApplication3.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
This error shouldn't come in the first place, right? Or is this to be expected?
That's why I ran the command line.
Can I restore from VS directly?
You can restore from VS by right clicking on the solution and selecting Restore. It also happens automatically before build.
Check your ActivityLog.xml file for errors around NuGet. You may need to run devenv with the activitylog option from the developer command prompt to get this.
I checked the activity log and there’s this entry:
From: Justin Emgarten [mailto:[email protected]]
Sent: zaterdag 16 december 2017 21:49
To: NuGet/Home Home@noreply.github.com
Cc: ngruson ngruson@hotmail.com; Author author@noreply.github.com
Subject: Re: [NuGet/Home] Operation failed as details for project could not be loaded when adding packages to .NET Core application (#6324)
You can restore from VS by right clicking on the solution and selecting Restore. It also happens automatically before build.
Check your ActivityLog.xml file for errors around NuGet. You may need to run devenv with the activitylog option from the developer command prompt to get this.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/NuGet/Home/issues/6324#issuecomment-352210787, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADCmY93DhfF_6vKcsXHHraTvCA0tRm8nks5tBCyugaJpZM4REVoK.
Thanks, that is helpful!
Encountering the same issue. Like @ngruson, it's only been happening the last day or so.
I'm still able to compile fine with existing packages though.
@ngruson so you also see something like "The nominate API is called for...." in the activityLog.xml?
@jainaashish No, I don't see that in my log file.
Then it's more likely Project System bug since they haven't nominated this project to NuGet which is why restore failed. @Pilchie @natidea to take a further look.
Make sure to run devenv with the /log
parameter, otherwise the activity log may not be saved if no error conditions occur.
I think this is related to non-letter character in project path. I have the same set of environment and when I had non-letter character in my project path same error was occurring.
So I switched from C:\@Projects\ to C:\Projects\ it is working fine now.
I can confirm what @nikator suggested. Restoring from VS was failing with this error until I removed a $
from my working directory.
Me too, I had braces in the path of my workspace. Once I moved to another workspace without braces, this problem didn't occur.
Another me too, Dropbox had added parentheses to my path \Dropbox (Business Name). I created a symbolic link without them to work around this issue.
I also can confirm what @nikator and @EvanMulawski were saying. I had projects in path D:\@Work\
... and VS2017 (v15.5.2) didn't find references (from solution) neither load them from nuget.
I mention that in older versions of VS2017 I didn't encounter this problem.
Solution
I renamed path D:\@Work\
... in D:\__Work\
... and the problem went away. So illegal chars in solution path (until now): $ and @.
Does restore work from the command line for projects with these chars in the path?
It is unclear from this if the project system is having issues sending the restore nomination to NuGet, or if NuGet is having trouble parsing the nomination.
Tag @lifengl as there were some core project system issues with special characters introduced in 15.5 AFAIK.
@emgarten Yes, restore was working from dotnet cli.
Same issue here with C:\@Source
folder if adding new dependencies.
@emgarten dotnet restore
does work from command line for existing dependencies
Thanks for confirming it works on the command line. This could be caused by the issue @Pilchie has mentioned if this is VS specific.
I'll leave this open for tracking, but it doesn't seem like a fix is needed on the NuGet side currently.
Yeah, a special character in the path can block design time build, and Jacob fixed it in 15.6 preview 3.
Sent from my phone
On Jan 10, 2018, at 12:06 PM, Justin Emgarten
Thanks for confirming it works on the command line. This could be caused by the issue @Pilchiehttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpilchie&data=02%7C01%7C%7Cda8e5842ffff4c30b7c108d5586596d9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636512115696303695&sdata=x8BF%2B6605MxdGzUAz7sIsXM8s1n7J0QlqRkt5q2Qj2c%3D&reserved=0 has mentioned if this is VS specific.
I'll leave this open for tracking, but it doesn't seem like a fix is needed on the NuGet side currently.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FNuGet%2FHome%2Fissues%2F6324%23issuecomment-356720685&data=02%7C01%7C%7Cda8e5842ffff4c30b7c108d5586596d9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636512115696303695&sdata=78AIf8FghzaGL3RY4XQGCZC3WVBq1xavtezR%2FvSCVXo%3D&reserved=0, or mute the threadhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FALGWwgNsA2WRHlyiHODC6V9jVY5bM01Wks5tJRgpgaJpZM4REVoK&data=02%7C01%7C%7Cda8e5842ffff4c30b7c108d5586596d9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636512115696303695&sdata=6%2B2T3BVwtC2kN4uO3zWbiVfIPfB39XJtpCSN01ReHeM%3D&reserved=0.
Just wasted half my day trying to figure out why I am having this error, only to read this thread and discover that the '$' character somewhere in my path (which I have no control of... symlink time) is causing it. This MUST be fixed.
Please follow this thread to get latest update on this issue - https://developercommunity.visualstudio.com/content/problem/160750/nuget-bug-in-vs155.html
Thanks @jainaashish for the link. Was having same problem, this fixed it... 👍
In my case, I was creating the project which was typically inside a lot of folders, I just created a project in near c directory, which solved my problem, my dependencies folder was restored. I was able to add nuget package. Though the dependency folder showed warning sign but every thing worked fine
@emgarten
Running this from the command line is a different scenario from restoring in VS and seeing errors.
THANK YOU SO MUCH!
In my case with a new Asp.Net Core 2.2 project with Visual Studio 2017 (15.9.11). Also, I have a big solution with too many other projects.
The following steps fixed the issue for me
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
</PropertyGroup>
Same problem with VS 2019 (16.1.1) and .NET Core 3.0.0-preview5-27626-15.
Unload and reload the project solved the problem.
I just removed that project in my solution, then added the same project again.it worked
@liciniomendes's solution did the job.
Was working on a solution with ~20 projects, unloaded and reloaded them all, just a few had the problems remaining, after reloading them individually the problems were all solved.
Had the same problem in VS 2019 16.2.5. @ArulPushpam's solution worked with removing and readding the project. Before that, the intellisense in the whole solution was broken. I do not have a repro now, but will register a bug next time it happens.
I had the same issue, when the version in the csproj file was malformed.
Hope following helps some users (if not all):
Had the same issue with VS2019
It did not work on Package Manager Console
. But worked on Manage Nuget Package for Solution
where you search for the package and click on Install
.
I had opened the VS2019
as admin but I don't think that was necessary.
My problem was that my PackageReference version had a 'v' before the version...
e.g.
<PackageReference Include="NUnit3TestAdapter" Version="v3.15.1" />
Change the v3.15.1
to 3.15.1
and it works again. Only figured it out by running dotnet restore
. The GUI error messages were less than helpful.
Had the same issue. Solved it by clearing all Nuget Caches.
Tools > Options > NuGet Package Manager > General > Clear All NuGet Cache(s)
I had this issue when generating projects and solution from commandline, then loading in Visual Studio. Solved it by unloading and reloading all projects. Structure generated using:
dotnet new sln --name <domain>
dotnet new web --name <domain>.<domain>Service --output <domain>Service
dotnet new xunit --name <domain>.<domain>Service.Tests.Unit --output <domain>Service.Tests.Unit
dotnet new classlib --name <domain>.Domain --output Domain
dotnet new xunit --name <domain>.Domain.Tests.Unit --output Domain.Tests.Unit
dotnet sln add Domain*/*.csproj -s Libraries
dotnet sln add <domain>Service*/*.csproj -s <domain>Service
Most helpful comment
Same problem with VS 2019 (16.1.1) and .NET Core 3.0.0-preview5-27626-15.
Unload and reload the project solved the problem.