https://github.com/firstfloorsoftware/xcc
https://mhut.ch/journal/2015/06/30/build_time_code_generation_msbuild
A quick breakdown:
The UpdateGeneratedFiles target runs if you have any ResourceFile items. It injects the generated file into the build as a Compile item, and also injects a FileWrites item so the file is recorded for incremental clean. It depends on the 'real' generation target, _UpdateGeneratedFiles, so that the file is generated before the UpdateGeneratedFiles target runs.
The _UpdateGeneratedFiles target has Inputs and Outputs set, so that it is incremental. The target will be skipped if the output file exists is newer than all of the input files - the project file and the resource files.
The project file is included in the inputs list because its write time will change if the list of resource files changes.
The _UpdateGeneratedFiles target simply runs a tasks that generates the output file from the input files.
Note that the generated file has the suffix .g.cs. This is the convention for built-time generated files. The .designer.cs suffix is used for user-visible files generated at design-time by the designer.
Hooking into the Build The UpdateGeneratedFiles target is added to the dependencies of the CoreCompile target by prepending it to the CoreCompileDependsOn property.
<Target Name="UpdateGeneratedFiles" DependsOnTargets="_UpdateGeneratedFiles" Condition=="'@(ResourceFile)' != ''"
<ItemGroup>
<Compile Include="$(IntermediateOutputDir)GeneratedFile.g.cs" />
<FileWrites Include="$(IntermediateOutputDir)GeneratedFile.g.cs" />
</ItemGroup>
UpdateGeneratedFiles;$(CoreCompileDependsOn)
MSBuild:UpdateGeneratedFiles
WPF .Targets Files
Visual Studio 2015 Other Versions
Windows Presentation Foundation (WPF) extends the Microsoft build engine (MSBuild)
by adding a set of WPF-specific tasks that are combined into a special .targets file,
Microsoft.WinFX.targets. This file combines the set of MSBuild tasks that are
required to build an MSBuild project in Windows Presentation Foundation (WPF).
https://msdn.microsoft.com/en-us/library/bb397829.aspx
https://msdn.microsoft.com/en-us/library/bb397738.aspx
GenerateTemporaryTargetAssembly Task
https://msdn.microsoft.com/en-us/library/bb397861.aspx
The first markup compilation pass, which is run by the MarkupCompilePass1 Task, compiles XAML files to binary format. Consequently, the compiler needs a list of the referenced assemblies that contain the types that are used by the XAML files. However, if a XAML file uses a type that is defined in the same project, a corresponding assembly for that project is not created until the project is built. Therefore, an assembly reference cannot be provided during the first markup compilation pass.
Instead, MarkupCompilePass1 defers the conversion of XAML files that contain references to types in the same project to a second markup compilation pass, which is executed by the MarkupCompilePass2 Task. Before MarkupCompilePass2 is executed, a temporary assembly is generated. This assembly contains the types that are used by the XAML files whose markup compilation pass was deferred. A reference to the generated assembly is provided to MarkupCompilePass2 when it runs to allow the deferred compilation XAML files to be converted to binary format
https://msdn.microsoft.com/en-us/library/bb397883.aspx
If the GetWinFXPath task is executing on a 64-bit processor, the WinFXPath parameter is set to the path that is stored in the WinFXWowPath parameter; otherwise, the WinFXPath parameter is set to the path that is stored in the WinFXNativePath parameter.
https://msdn.microsoft.com/en-us/library/bb384283.aspx
The ResourcesGenerator task embeds one or more resources (.jpg, .ico, .bmp, XAML in binary format, and other extension types) into a .resources file.
Accesses XAML files that define types (with x:Class) and generates the corresponding source code that can be compiled into an assembly.
========================================================
https://msdn.microsoft.com/en-us/library/bb397865.aspx
http://stackoverflow.com/questions/992006/generation-and-compilation-of-resources-files-with-msbuild
*)