MarkupCompilePass2 task

The MarkupCompilePass2 task performs second-pass markup compilation on XAML files that reference types in the same project.

Task parameters

Parameter Description
AlwaysCompileMarkupFilesInSeparateDomain Optional Boolean parameter.

Specifies whether to run the task in a separate AppDomain. If this parameter returns false, the task runs in the same AppDomain as MSBuild, and it runs faster. If the parameter returns true, the task runs in a second AppDomain that is isolated from MSBuild and runs slower.
AssembliesGeneratedDuringBuild Optional String[] parameter.

Specifies references to assemblies that change during the build process. For example, a Visual Studio solution may contain one project that references the compiled output of another project. In this case, the compiled output of the second project can be added to AssembliesGeneratedDuringBuild.

Note: AssembliesGeneratedDuringBuild must contain references to the complete set of assemblies that are generated by a build solution.
AssemblyName Required String parameter.

Specifies the short name of the assembly that is generated for a project. For example, if a project is generating an executable whose name is WinExeAssembly.exe, the AssemblyName parameter has a value of WinExeAssembly.
GeneratedBaml Optional ITaskItem[] output parameter.

Contains the list of generated files in XAML binary format.
KnownReferencePaths Optional String[] parameter.

Specifies references to assemblies that are never changed during the build process. Includes assemblies that are located in the global assembly cache (GAC), in a .NET installation directory, and so on.
Language Required String parameter.

Specifies the managed language that the compiler supports. The valid options are C#, VB, JScript, and C++.
LocalizationDirectivesToLocFile Optional String parameter.

Specifies how to generate localization information for each source XAML file. The valid options are None, CommentsOnly, and All.
OutputPath Required String parameter.

Specifies the directory in which the generated XAML binary format files are generated.
OutputType Required String parameter.

Specifies the type of assembly that is generated by a project. The valid options are winexe, exe, library, and netmodule.
References Optional ITaskItem[] parameter.

Specifies the list of references from files to assemblies that contain the types that are used in the XAML files. One reference is to the assembly that was generated by the GenerateTemporaryTargetAssembly task, which must be run before the MarkupCompilePass2 task.
RootNamespace Optional String parameter.

Specifies the root namespace for classes that are inside the project. RootNamespace is also used as the default namespace of a generated managed code file when the corresponding XAML file does not include the x:Class attribute.
XAMLDebuggingInformation Optional Boolean parameter.

When true, diagnostic information is generated and included in the compiled XAML in order to aid debugging.

Remarks

Before you run MarkupCompilePass2, you must generate a temporary assembly that contains the types that are used by the XAML files whose markup compilation pass were deferred. You generate the temporary assembly by running the GenerateTemporaryTargetAssembly task.

A reference to the generated temporary assembly is provided to MarkupCompilePass2 when it runs, allowing the XAML files whose compilation was deferred in the first markup compilation pass to now be compiled to binary format.

Example

The following example shows how to use the MarkupCompilePass2 task to perform a second pass compilation.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <UsingTask
    TaskName="Microsoft.Build.Tasks.Windows.MarkupCompilePass2"
    AssemblyFile="C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationBuildTasks.dll" />
  <Target Name="MarkupCompilePass2Task">
    <MarkupCompilePass2
      AssemblyName="WPFMSBuildSample"
      Language="C#"
      OutputType="WinExe"
      OutputPath="obj\Debug\"
      References=".\obj\debug\WPFMSBuildSample.exe;c:\windows\Microsoft.net\Framework\v2.0.50727\System.dll;C:\Program Files\Reference Assemblies\Microsoft\WinFx\v3.0\PresentationCore.dll;C:\Program Files\Reference Assemblies\Microsoft\WinFx\v3.0\PresentationFramework.dll;C:\Program Files\Reference Assemblies\Microsoft\WinFx\v3.0\WindowsBase.dll" />
  </Target>
</Project>

See also