How does PartialClassGenerationTask and MarkupCompilePass1 works/belongs together

414 Views Asked by At

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?

1

There are 1 best solutions below

4
On BEST ANSWER

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: