I'm trying to use Microsoft.Build.Evaluation.Project
to run MSBuild inside my project.
I'm getting this error, and I can't figure out why, or where to start diagnosing it:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\CodeAnalysis\Microsoft.CodeAnalysis.targets: error MSB4127: The "CodeAnalysis" task could not be isntantiated from the assembly "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\CodeAnalysis\.\FxCopTask.dll". Please verify the task assembly has been built using the same version of the Microsoft.Build.Framework assembly as the one installed on your computer and that your host application is not missing a binding redirect for Microsoft.Build.Framework. Unable to cast object of type 'Microsoft.Build.Tasks.CodeAnalysis' to type 'Microsoft.Build.Framework.ITask'.
- I've tried using
ToolsVersion="12.0"
in my build file - I've checked
Microsoft.CodeAnalysis.targets
and ensuredFxCopTask.dll
works - I've removed extraneous references and am now only referencing
Microsoft.Build
andMicrosoft.Build.Framework
- I've used
MSBuild.exe
in a shell process successfully on the same solution - This question seems to address the problem, but it's using the command line.
I'm not sure how to "verify the task assembly" or add "a binding redirect for the Microsoft.Build.Framework." Can someone point me in the right direction?