Microsoft.Build.BuildEngine.Engine throws an error when creating a WPF application

I am using Microsoft.Build.BuildEngine.Engine to create a WPF application. This works successfully for class libraries and web applications, but now, trying to use it to create a WPF application, I get the following error:

Target MarkupCompilePass1: C: \ Windows \ Microsoft.NET \ Framework \ v3.5 \ Microsoft.WinFX.targets (294.9): MC1000 error: Unknown build error, 'API constraint: build' file: /// C: \ Program Files (X86) \ Assembly Link \ Microsoft \ Framework \ v3.0 \ PresentationCore.dll "is already loaded from another location. It cannot be downloaded from a new location in the same AppDomain. Completed building target" MarkupCompilePass1 "in the project" TestWindowsApplication.csproj "- FAILED.

This application works great when created using VisualStudio 2008 (i.e. building from a menu), but with Microsoft.Build.BuildEngine.Engine, it throws this build error. Does anyone know what is going on here?

+2
source share
2 answers

I had the same problem and found this in msdn which says

By default, markup compilation is performed in the same AppDomain as the MSBuild engine. This gives us a significant increase in productivity. This behavior can be switched with the AlwaysCompileMarkupFilesInSeparateDomain property. The latter has the advantage of offloading entire assembly links by offloading individual AppDomain.

, , PresentationCore AppDomain, , :

projectToBuild.SetProperty("AlwaysCompileMarkupFilesInSeparateDomain", "True");

, .

, .

+3

! . WPF.

MSBuild MarkupCompilePass1, , , VS2008, MSBuild:

<!--
When performing an intellisense compile, we don't want to abort the compile if 
MarkupCompilePass1 fails.  This would prevent the list of files from being handed 
off to the compiler, thereby breaking all intellisense.  For intellisense compiles
we set ContinueOnError to true.  The property defined here is used as the value
for ContinueOnError on the MarkupCompilePass1 task.
-->
+2

Source: https://habr.com/ru/post/1719585/


All Articles