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
- Restarting all instances of Visual Studio
- Restarting the machine.
- Tried repairing the Visual Studio through Visual Studio Installer.
- 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.
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
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.2) check your reference dlls in your project and make sure that they are compatible and accessible.
3) delete
bin
andobj
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.