Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuget.exe restore foo.sln - broken with msbuild 15.7 installed #6918

Closed
AndrewGretton opened this issue May 8, 2018 · 25 comments · Fixed by NuGet/NuGet.Client#2264
Closed
Labels
Priority:1 High priority issues that must be resolved in the current sprint.

Comments

@AndrewGretton
Copy link

AndrewGretton commented May 8, 2018

Environment / tooling

nuget.exe, version 4.6.2
VS2017/msbuild version 15.7
Win10, 1703

Repro steps

Run nuget restore <any valid .sln file>

Expected result: nuget restore works
Actual result: nuget restore no longer works since 15.6 --> 15.7 upgrade

Sample problem output

> 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.

@asmichi
Copy link

asmichi commented May 8, 2018

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
Copy link
Author

AndrewGretton commented May 8, 2018

Great spot asmichi - we are running .NET 4.7 (version 460798) on Creator's Update (version 1703). I'll try updating to get around our current issues.

@asmichi
Copy link

asmichi commented May 8, 2018

For me copying System.Runtime.InteropServices.RuntimeInformation.dll from MSBuild to the same directory as NuGet.exe made NuGet work.

@dasMulli
Copy link

dasMulli commented May 8, 2018

Does it work for you using the 4.7.0 nuget.exe from https://www.nuget.org/downloads? (warning: "recommended latest" listed at the top is actually older)

@AndrewGretton
Copy link
Author

@dasMulli thanks, but it seems not - on my affected machines, the entire 4.x range has stopped working since 15.7 was applied.

@AndrewGretton
Copy link
Author

AndrewGretton commented May 8, 2018

Applying .NET 4.7.2 to my affected machine has fixed the issue. However, rolling this out to all my developers, build agents, etc is not an exciting prospect :-)

@JaCoB1123
Copy link

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.

@LouisMT
Copy link

LouisMT commented May 8, 2018

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.

@zhekaby
Copy link

zhekaby commented May 8, 2018

Yes, 4.7.2 fixes this issue

@zhili1208 zhili1208 added the Priority:1 High priority issues that must be resolved in the current sprint. label May 8, 2018
@rrelyea
Copy link
Contributor

rrelyea commented May 8, 2018

We are working with the MsBuild team to determine the right fix(es).
Until then, workarounds include:

  1. Install .NET Framework 4.7 or later
  2. Copy System.Runtime.InteropServices.RuntimeInformation.dll from msbuild directory to the same directory that NuGet.exe is in.

Sorry for the problem.

@rrelyea rrelyea changed the title Nuget restore doesn't work after 15.7 upgrade Nuget.exe restore foo.sln - broken with msbuild 15.7 installed May 9, 2018
@Ncage1974
Copy link

@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?

@rainersigwald
Copy link

rainersigwald commented May 9, 2018

@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?

@Ncage1974
Copy link

@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
Copy link

jdshkolnik commented May 9, 2018

@Ncage1974 You can work around that by using the NuGet Tool Installer extension which will put it in the agent's tools folder.

@Ncage1974
Copy link

@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?

@jdshkolnik
Copy link

Yes, sorry I wasn't clear. I was offering a workaround for the temporary nuget.exe location rather than the root error. It's much easier to copy the dll into a single tool folder per agent.

@seanterry42
Copy link

seanterry42 commented May 10, 2018

Installing the .NET Framework 4.7 SDK on Windows 2016 did not get around the error for me, but installing the .NET Framework 4.7.2 (not the SDK) did.

@dominik-weber
Copy link

Installing .NET Framework 4.7.2 (Runtime, NOT SDK!) did the trick for me.
Download here: https://www.microsoft.com/net/download/dotnet-framework-runtime

@sbrockway
Copy link

We just installed .net 4.6.2 on our build agent which triggered the issue described.

@rainersigwald
Copy link

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.

@tegaaa
Copy link

tegaaa commented May 17, 2018

I had the same issue and installing .net 4.7.2 solved it. I concur.

@rainersigwald
Copy link

This should be resolved with MSBuild 15.7.179, delivered in Visual Studio 2017 15.7.2.

@hbulens
Copy link

hbulens commented May 23, 2018

I experience the same problem but only on VSTS. I seem to be the only having this issue. Could there be anything I can do to fix this?

@elahaha
Copy link

elahaha commented May 12, 2020

Hi @ALL

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!

@rainersigwald
Copy link

@elahaha If possible, please update your nuget.exe version. There should be an MSBuild fix in Visual Studio 16.5.5 and 16.6.0 when they are released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:1 High priority issues that must be resolved in the current sprint.
Projects
None yet
Development

Successfully merging a pull request may close this issue.