80

I edit the project.csproj. and re-open the solution the errors occurred: The operation failed as details for project xxx could not be loaded

I try delete obj & bin folder, clear the nuget cache by tool>options. but the error still exist.

Remark: the error do not occur each time, i just restart the project three times. the first and second is correct. but the third the error occur

vs2017: Microsoft Visual Studio Community 2017 Version 15.0.26228.9 D15RTWSVC Microsoft .NET Framework Version 4.6.01586

Package Manager Console Host Version 4.0.0.2323

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
Cuiqs
  • 821
  • 1
  • 6
  • 5

11 Answers11

123

I've faced the problem several times, and all but one were solved by just closing and then restarting visual studio 2017. So if you've not, please try restarting VS, then if that fails, look for more serious solutions.

Youngjae
  • 24,352
  • 18
  • 113
  • 198
Alireza
  • 5,421
  • 5
  • 34
  • 67
70

I've just had the same problem. Microsoft are apparently aware of the problem and have fixed in the preview of the next release, see the following comment for details:

https://developercommunity.visualstudio.com/comments/31393/view.html

In the meantime, the workaround is to open VS2017 (without loading your solution), open the Package Manager Console, wait for it to fully load, then open your solution.

Andrew Trevers
  • 1,246
  • 8
  • 10
  • 1
    This has been fixed in April 2017, just need to download the latest Visual Studio. – Andrey Prokhorov Jun 16 '17 at 19:33
  • 2
    Upgraded from version 15.0.26906.1 to 15.0.26923.0 and this error appeared. – screig Sep 28 '17 at 10:47
  • 5
    I have 15.3.5 and I still see this. What's going on. Nuget says SEMVER 2.0 is supported in 15.3 https://blog.nuget.org/20170815/Whats-nu-in-NuGet-with-VS2017-15-3.html#support-for-semantic-versioning-200 – bradgonesurfing Oct 05 '17 at 10:21
  • 4
    I'm seeing this problem now on 15.4.2. – Finster Nov 14 '17 at 17:36
  • 1
    I'm seeing this problem now on 15.4.2. too – heringer Dec 12 '17 at 12:42
  • 1
    Me too on 15.5.6 – RHaguiuda Feb 02 '18 at 11:23
  • 4
    After one of our team members updated to version 15.5.6 he started getting this error message. He had an apostrophe in one of the directories in his project path. He moved the solution to a directory with no non-letter characters and it fixed the error. The strange thing is, I have an underscore in my path and my build/restore works just fine. I guess some characters are illegal in the full path now. – Brett Mathe Feb 06 '18 at 19:24
  • @BrettMathe, you sir, are a star! This issue has been causing me problems for months, but I never thought about paths. I have `()` in my paths and they too cause this problem. At last, I know the cause :) – David Arno Feb 27 '18 at 21:14
  • 1
    Raised an issue about this on [dotnet/project-system](https://github.com/dotnet/project-system/issues/3320). Turns out it looks like it'll be properly fixed with VS2017 Update 6. Just tested it with the latest preview and my issue (using `(` and `)` in paths) and @BrettMathe's colleague's issue (using `'`) are both fixed. – David Arno Feb 27 '18 at 23:20
  • Had this issue occur on 15.7.2 – Xcalibur Jun 05 '18 at 03:39
  • 2
    I'm getting it in 15.7.4 – Anthony Jun 28 '18 at 16:24
  • Wow, how did you figure out the workaround!??!! THANKS – granadaCoder May 02 '19 at 14:03
  • I had to use this workaround in Visual Studio 2019 16.1.1. – Andrew Keeton Jun 05 '19 at 17:58
16

I came across the same issue in VS 2017 with lastest .NET SDK updates. But here is a quick and easy fix that i was able to find.

While your project is open, open your 'Package Manager Console' and then run 'dotnet restore' command.

In the Package Manager Console window, make sure 'Package Source' dropdown on the top is set to 'All' and 'Default Project' is set to your project name

Abdi
  • 264
  • 3
  • 5
5

Just restarting Visual Studio 2017 can be enough to resolve this.

robyaw
  • 2,274
  • 2
  • 22
  • 29
  • 6
    How does your answer differ from [this one](https://stackoverflow.com/questions/42971449/vs2017-the-operation-failed-as-details-for-project-could-not-be-loaded/46593479#46593479)? – Pika Supports Ukraine Mar 06 '19 at 18:30
3

Similarly to @Keith it was a result of SemVer in my 2017 project file.

In the .csproj file I am using <PackageReference... Version="1.1.*" />. When the solution first loads Package Manager outputs the following:

Error occurred while restoring NuGet packages: The operation failed as details for project ProjectWebApi could not be loaded.

In VS 2017 15.2 (26430.14) it doesn't seem to cause any actual problems, the solution loads and builds just fine. If a more recent package version is available but not in the local .nuget cache it is downloaded and installed as part of the solution startup. I have not tested with pre-release or build metadata tags trailing the patch number.

Aaron
  • 705
  • 10
  • 19
  • Update: Since the release of `Visual Studio 2017 15.3.1` the Solution Explorer better handles floating dependencies in referenced packages without error. The UI may show the warning exclamation sign if you change package versions manually using the 'edit .csproj' feature for .NET Core projects, but unloading and reloading the project removes these warnings. – Aaron Sep 06 '17 at 03:48
2

I ran into this on a build server on Nuget restore. I turned out that the build pipeline used an old version of Nuget and broke after upgrading Visual Studio. Updating the Nuget version solved it for me

Soundislate
  • 126
  • 1
  • 7
  • How did you update Nuget version on the build pipeline? – BHANG Feb 19 '21 at 16:29
  • 2
    @BHANG I use Azure Pipelines: Add the task [NuGet tool installer](https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/tool/nuget?view=azure-devops). It allows you to specify which NuGet version the pipeline should use. – Soundislate Mar 08 '21 at 18:27
1

This happened for me due to VS2017's poor support for SemVer. They sort of tried to start supporting it in project.json files, but when translating to .csproj they've managed to make something quite broken.

I had:

<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <Version>0.2.1-alpha</Version>
    ...

This is partially supported by VS2017, in that it compiles, but it breaks NuGet and has lots of other issues due to some parts of .NET recognising the SemVer suffix.

The fix was to remove the suffix:

<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <Version>0.2.1</Version>
    ...

Now NuGet works.

Keith
  • 150,284
  • 78
  • 298
  • 434
  • 1
    Maybe use `VersionPrefix` and `VersionSuffix` elements? – Stephen Drew Apr 27 '17 at 19:41
  • 1
    @StephenDrew those sound like a workaround for this. VS2015 and VS2017RC1 projects used `project.json` with SemVer numbers, the upgrade to `MyApp.csproj` kept the full SemVer number (which it can't support) but should have split out the `VersionSuffix` – Keith Apr 28 '17 at 07:07
  • 1
    Did not help as I have not even a Version-tag inside my csproj files :/ but I run latest VS2017 with that error. – Pascal Jul 28 '17 at 19:57
  • @Pascal that fixed it for this project. I guess this symptom can have more than one cause. – Keith Jul 29 '17 at 07:58
  • Probably yes Keith, I just get it for common class libraries (csproj files) and those project files are nearly empty... – Pascal Jul 30 '17 at 10:28
1

Possible Work Around

Try This: Change the location of your project to a simpler location. E.g. place it on your desktop.

Possible Reason: Perhaps it couldn't load because the path was an issue (Included spaces, special characters, etc?).

For reference:
My old path: C:\Users\Corey\Google Drive\College\Semesters\2018\Spring\CSIS 434 (Programming)\Projects\Project 1
My new path is: C:\Users\Corey\Desktop

Conclusion: From Andrew's solution, it looks like Microsoft is still trying to fix this problem. Regardless, this work around may work for you!

Community
  • 1
  • 1
Corey P
  • 955
  • 1
  • 14
  • 23
0

I found another issue causing this error as well.

If you add Package details for the project and specify the version with three digits, like 1.0.0 you will get this error.

If you specify the version as 1.0.0.0 the solution will build perfectly. I guess this breaks som internal validation as this will also set Version in the csproj-file.

TL;DR:

Do: <Version>1.0.0.0</Version>

Don't: <Version>1.0.0</Version>

UPDATE: Please see also Keith's answer.

Jonas Stensved
  • 14,378
  • 5
  • 51
  • 80
0

Make sure that the AssemblyName tag value is the same as the RootNamespace tag value, inside the .csproj. This worked for me!

Sherif
  • 1,249
  • 4
  • 15
  • 38
0

For me the solution path had an apostrophe and a space in it (C:/Users/[myName]'s PC/etc). I changed the path to just C:/ and it worked :)

Ziad
  • 63
  • 1
  • 9