MarkupCompilePass1 Task

 

For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.

For the latest documentation on Visual Studio 2017, see MarkupCompilePass1 Task on docs.microsoft.com. The MarkupCompilePass1 task converts non-localizable Extensible Application Markup Language (XAML) project files to compiled binary format.

ParameterDescription
AllGeneratedFilesOptional ITaskItem[] output parameter.

Contains a complete list of files that are generated by the MarkupCompilePass1 task.
AlwaysCompileMarkupFilesInSeparateDomainOptional 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 Microsoft build engine (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.
ApplicationMarkupOptional ITaskItem[] parameter.

Specifies the name of the application definition XAML file.
AssembliesGeneratedDuringBuildOptional String[] parameter.

Specifies references to assemblies that change during the build process. For example, a Microsoft Visual Studio 2005 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 the AssembliesGeneratedDuringBuild parameter.

Note: The AssembliesGeneratedDuringBuild parameter must contain references to the complete set of assemblies that are generated by a build solution.
AssemblyNameRequired string parameter.

Specifies the short name of the assembly that is generated for a project. For example, if a project is generating a Windows executable whose name is WinExeAssembly.exe, the AssemblyName parameter has a value of WinExeAssembly.
AssemblyPublicKeyTokenOptional String parameter.

Specifies the public key token for the assembly.
AssemblyVersionOptional String parameter.

Specifies the version number of the assembly.
ContentFilesOptional ITaskItem[] parameter.

Specifies the list of loose content files.
DefineConstantsOptional String parameter.

Specifies that the current value of DefineConstants, is kept. which affects target assembly generation; if this parameter is changed, the public API in the target assembly may be changed and the compilation of XAML files that reference local types may be affected.
ExtraBuildControlFilesOptional ITaskItem[] parameter.

Specifies a list of files that control whether a rebuild is triggered when the MarkupCompilePass1 task reruns; a rebuild is triggered if one of these files changes.
GeneratedBamlFilesOptional ITaskItem[] output parameter.

Contains the list of generated files in XAML binary format.
GeneratedCodeFilesOptional ITaskItem[] output parameter.

Contains the list of generated managed code files.
GeneratedLocalizationFilesOptional ITaskItem[] output parameter.

Contains the list of localization files that were generated for each localizable XAML file.
HostInBrowserOptional String parameter.

Specifies whether the generated assembly is a XAML browser application (XBAP). The valid options are true and false. If true, code is generated to support browser hosting.
KnownReferencePathsOptional String[] parameter.

Specifies references to assemblies that do not change during the build process. Includes assemblies that are located in the global assembly cache (GAC), in a Microsoft .NET Framework installation directory, and so on.
LanguageRequired String parameter.

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

Specifies the extension that is appended to the extension of the generated managed code file:

 <Filename>.g<LanguageSourceExtension>

If the LanguageSourceExtension parameter is not set with a specific value, the default source file name extension for a language is used: .vb for Microsoft Visual Basic, .csharp for C#.
LocalizationDirectivesToLocFileOptional String parameter.

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

Specifies the directory in which the generated managed code files and XAML binary format files are generated.
OutputTypeRequired String parameter.

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

Specifies a list of XAML files to process.
ReferencesOptional ITaskItem[] parameter.

Specifies the list of references from files to assemblies that contain the types that are used in the XAML files.
RequirePass2ForMainAssemblyOptional Boolean output parameter.

Indicates whether the project contains non-localizable XAML files that reference local types that are embedded into the main assembly.
RequirePass2ForSatelliteAssemblyOptional Boolean output parameter.

Indicates whether the project contains localizable XAML files that reference local types that are embedded in the main assembly.
RootNamespaceOptional 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.
SourceCodeFilesOptional ITaskItem[] parameter.

Specifies the list of code files for the current project. The list does not include generated language-specific managed code files.
UICultureOptional String parameter.

Specifies the satellite assembly for the UI culture in which the generated XAML binary format files are embedded. If UICulture is not set, the generated XAML binary format files are embedded in the main assembly.
XAMLDebuggingInformationOptional Boolean parameter.

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

The MarkupCompilePass1 task typically compiles XAML into binary format and generates code files. If a XAML file contains references to types that are defined in the same project, its compilation to binary format is deferred by MarkupCompilePass1 to a second markup compilation pass (MarkupCompilePass2). Such files must have their compilation deferred because they must wait until the referenced locally-defined types are compiled. However, if a XAML file has an x:Class attribute, MarkupCompilePass1 generates the language-specific code file for it.

A XAML file is localizable if it contains elements that use the x:Uid attribute:

<Page x:Class="WPFMSBuildSample.Page1"  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    x:Uid="Page1Uid"  
    >  
  ...  
</Page>  

A XAML file references a locally-defined type when it declares an XML namespace that uses the clr-namespace value to refer to a namespace in the current project:

<Page x:Class="WPFMSBuildSample.Page1"  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    xmlns:localNamespace="clr-namespace:WPFMSBuildSample"  
    >  
    <Grid>  
      <Grid.Resources>  
        <localNameSpace:LocalType x:Key="localType" />  
      </Grid.Resources>  
      ...  
    </Grid>  
</Page>  

If any XAML file is localizable, or references a locally-defined type, a second markup compilation pass is required, which requires running the GenerateTemporaryTargetAssembly and then the MarkupCompilePass2.

The following example shows how to convert three PageXAML files to binary format files. Page1 contains a reference to a type, Class1, which is in the root namespace of the project and therefore, is not converted to binary format files in this markup compile pass. Instead, the GenerateTemporaryTargetAssembly is executed and is followed by the MarkupCompilePass2.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">  
  <UsingTask   
    TaskName="Microsoft.Build.Tasks.Windows.MarkupCompilePass1"   
    AssemblyFile="C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationBuildTasks.dll" />  
  <Target Name="MarkupCompilePass1Task">  
    <MarkupCompilePass1   
      AssemblyName="WPFMSBuildSample"  
      Language="C#"  
      OutputType="WinExe"  
      OutputPath="obj\Debug\"  
      ApplicationMarkup="App.xaml"  
      PageMarkup="Page1.xaml;Page2.xaml;Page3.xaml"  
      SourceCodeFiles="Class1.cs"  
      References="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>  

WPF MSBuild Reference
Task Reference
MSBuild Reference
Task Reference
Building a WPF Application (WPF)
WPF XAML Browser Applications Overview

Show: