0

While building my code through command line I get the error:

System.TypeLoadException: Could not load type 'Microsoft.Build.Evaluation.Context.EvaluationContext' from assembly 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

I am using Visual Studio 2017 on windows environment.

I have tried

  1. Restarting all instances of Visual Studio
  2. Restarting the machine.
  3. Tried repairing the Visual Studio through Visual Studio Installer.
  4. Tried to uninstall and reinstall Microsoft.Build.Framework.dll using gacutil. I am still getting the same error.

It would be very helpful if I can get a fix for this. Thanks in advance.

大陸北方網友
  • 3,696
  • 3
  • 12
  • 37
Rishabh Nigam
  • 21
  • 1
  • 4
  • What is the detailed build error? enter `Tools`-->`Options`-->`Projects and Solutions`-->`Build and Run`-->set `MSBuild project build output verbosity` to `Detailed`. And then build your project again, what is your error? – Mr Qian Sep 09 '20 at 02:15
  • Also, What is your project type?Did you build your project in VS 2017 IDE successfully? Did you use `C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe` to build your project? – Mr Qian Sep 09 '20 at 02:17
  • Hi, any update about this issue? If my answer helps you handle the issue, please do not forget to [accept it](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work). Or if not or you have a workaround, please feel free to let us know. Thanks:) – Mr Qian Sep 10 '20 at 02:06

1 Answers1

0

Microsoft.Build could not load EvaluationContext

First, check whether you can build the project in VS2017 IDE to make sure the issue is related to MSBuild.exe with you invoke or not.

Besides, use

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe

to build your project with command line. This is the standard msbuild.exe for command line building projects.

Suggestion

1) If these do not work, you could try to reinstall the Microsoft.Build in GAC.

gacutil /u Microsoft.Build

gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Build.dll"

2) check your reference dlls in your project and make sure that they are compatible and accessible.

3) delete bin and obj folder, and then run command to build again.

In addition, you can also share the detailed build error,log, detailed info or provide a small sample of your project with us so that it will help us troubleshoot your issue more quickly.

Mr Qian
  • 21,064
  • 1
  • 31
  • 41