> nuget restore C:\folder\somefile.sln -verbosity detailed
NuGet Version: 4.6.2.5055
MSBuild auto-detection: using msbuild version '15.7.177.53362' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
Error parsing solution file at C:\folder\somefile.sln: Exception has been thrown by the target of an invocation. The project file could not be loaded. Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. C:\folder\somefile.sln
NuGet.CommandLine.CommandLineException: Error parsing solution file at C:\folder\somefile.sln: Exception has been thrown by the target of an invocation. The project file could not be loaded. Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. C:\folder\somefile.sln
at NuGet.CommandLine.MsBuildUtility.GetAllProjectFileNamesWithMsBuild(String solutionFile, String msbuildPath)
at NuGet.CommandLine.RestoreCommand.ProcessSolutionFile(String solutionFileFullPath, PackageRestoreInputs restoreInputs)
at NuGet.CommandLine.RestoreCommand.<DetermineRestoreInputsAsync>d__42.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.CommandLine.RestoreCommand.<ExecuteCommandAsync>d__34.MoveNext()
This is reproducible on any .sln file, including newly created ones, and is reproducible on the two test machines we have performed an upgrade on so far.
Nuget 3.3 (last public release from the Github releases page) does not exhibit this issue on the affected machines, and restores correctly.
I hit the same issue.
This issue doesn't seem to reproduce when .NET Framework 4.7.1 is installed and thus the GAC contains System.Runtime.InteropServices.RuntimeInformation.dll.
From my observation, it does not reproduce in:
nuget.exe, version 4.6.2
VS2017 version 15.7
Win10 1709 1803
.NET Framework 4.7.1
It reproduces in:
nuget.exe, version 4.6.2
VS2017 version 15.7
Win7 SP2
.NET Framework 4.6.2
AndrewGretton, LouisMT, rshramko, mitch-b, oleg-makaruk, jaredpar, and pr0gg3r reacted with thumbs up emoji
brent-williams and YohskDista reacted with hooray emoji
All reactions
I can confirm what @AndrewGretton said.
I had NuGet 4.1 in use and restore
stopped working after updating Visual Studio to 15.7.
After installing .NET 4.7.2 it started working again.
I can also confirm this.
The error message is really confusing and makes it seem that there's something wrong with the solution, but building the solution with MSBuild directly yields no errors at all.
Installing .NET 4.7.1 fixed this issue.
We are working with the MsBuild team to determine the right fix(es).
Until then, workarounds include:
Install .NET Framework 4.7 or later
Copy System.Runtime.InteropServices.RuntimeInformation.dll from msbuild directory to the same directory that NuGet.exe is in.
Sorry for the problem.
jdshkolnik, cjuroz, KumG, Portikus, asmichi, fishbits, rjhernandez, escalonn, mookid8000, janmohammadi, and 6 more reacted with thumbs up emoji
janmohammadi and SubPointSupport reacted with hooray emoji
All reactions
Nuget restore doesn't work after 15.7 upgrade
Nuget.exe restore foo.sln - broken with msbuild 15.7 installed
May 9, 2018
@rrelyea we copied System.Runtime.InteropServices.RuntimeInformation.dll from C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin to our nuget.exe location c:\programdata\chocolaty\bin which did not work. I looked at the file version information of the dll and it was 4.6.24705.1. Apparently its trying to load 4.0.1.0. We are using nuget version 4.6.2.5055. Unfortunately we can't update the .net framework to 4.7 or later because this is running on Server 2012 R2 which is not supported. Any clue?
@Ncage1974 Confusingly, the System.Runtime.InteropServices.RuntimeInformation.dll
that has file version and product version 4.6.24705.1
has managed assembly version 4.0.1.0
. So that version of the file should be loadable.
Can you use fuslogvw
to collect more detailed information on the load failure?
@rainersigwald thanks for the hint of using fuslogvw which enabled me to figure it out. I not sure if this is the way nuget works or if this is an oddity of chocolatey but you will find nuget.exe at c:\programdata\chocolatey\bin\nuget.exe but this is not the REAL executable (its some type of shim). It essentially points to c:\programdata\chocolatey\lib\Nuget.CommandLine\Tools\nuget.exe. I copied the dll to the directory now everything is working perfectly from the command line:
Unfortunately it looks like when VSTS when its doing the builds creates a temporary type location (C:\agent2_work_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.31\node_modules\nuget-task-common\NuGet\4.0.0\NuGet.exe). Of course the needed dll is not located there and is failing causing our builds to fail. Still trying to determine a work around.
@jdshkolnik Hi John. I tried that and it still fails but at a different location:
C:\agent2_work_tool\NuGet\4.3.0\x64\nuget.exe restore C:\agent2_work\1\s\STAR.sln -Verbosity Detailed -NonInteractive -ConfigFile C:\agent2_work\1\Nuget\tempNuGet_1501.config
Should i just stick the required dll (System.Runtime.InteropServices.RuntimeInformation.dll) in c:\agent2_work_tool\Nuget\4.3.0\x64\ folder? If i do that wouldn't it start failing as soon as 4.4.x version of nuget comes out or should i lock the version to nuget 4.3.x?
Update: an MSBuild change that will fix this has been accepted by VS shiproom and will go out with a 15.7 update. I don't have any timing information on when it'll ship.
Until that's out, @rrelyea's workarounds in #6918 (comment) are good, except that it should say to install .NET Framework 4.7.1 or later; 4.7 is not enough.
I am getting the same issue when trying to run
nuget restore
on my Win-10 VDI with MsBuildTools2019 installed, msbuild version '16.5.0.12403' and nuget '4.7.1'
See below my output on the command line of the VDI:
Command line log
D:\VDI\directory\build>nuget restore
MSBuild auto-detection: using msbuild version '16.5.0.12403' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\bin'.
Error parsing solution file at D:\VDI\directory\buildl\project.sln: Exception has been thrown by the target of an invocation.
The project file could not be loaded. Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b12334567890' or one of its dependencies.
The system cannot find the file specified. D:\VDI\directory\buildl\project.sln
Hints on how to resolve are appreciated. Thanks!