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
It would be very helpful if I can get a fix for this. Thanks in advance.
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.