can some one explain how the two Build tasks MarkupCompilePass1
and PartialClassGenerationTask
belongs together? Currently I don't get whether they co-exists or if one needs each other. Can some one clearify the usage of both classes and how they might interact with each other?

- 106,458
- 22
- 256
- 341

- 20,098
- 17
- 57
- 131
1 Answers
The MarkupCompilePass1
will use the PartialClassGenerationTask
to generate partial classes for all XAML files.
The WPF pipeline is pretty complex and there are many moving parts when compiling a WPF application.
The PartialClassGenerationTask
acts specifically on XAML files that specify a type and have x:Class
. When these are encountered the task will generate a matching cs or vb code file so the C#/VB compiler can reference the class and its properties later on.
The MarkupCompilePass1
task turns a text based XAML file into a the binary BAML format. It will compile all XAML files that reference only types defined in other projects and referenced assemblies.
The MarkupCompilePass2
task follows up on the Pass 1 and it specifically compiles XAML files which reference code in the same project to BAML.
To speed up compilation of your XAML projects it's better to define your types in a second project (standard Class Library). That way the MarkupCompilePass2
can be skipped.
The full WPF build pipeline is explained on MSDN:

- 106,458
- 22
- 256
- 341
-
Thanks for that detailed explanation and the link! – BendEg May 01 '16 at 14:44
-
I used `cs or vb code file so the C#/VB compiler can reference the class and its properties later on.` to compile xaml/create a partial class, but no properties are created. Do you have any hint here? – BendEg May 01 '16 at 15:20
-
Not sure what you are doing. A partial class is generated upon compilation. You'll be able to see what's generated by looking into the `obj` folder under your xaml project. Unless *your* classes are partial classes and specify the same namespace and classname, they won't be matched up. – jessehouwing May 01 '16 at 16:07
-
Thanks for this answer. BTW, the updated location of the link is here: https://learn.microsoft.com/en-us/dotnet/framework/wpf/app-development/building-a-wpf-application-wpf – Sabuncu Dec 29 '18 at 20:31