From 65fbdf31670d12940156acad6d0375269d859044 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Mon, 2 Apr 2018 22:26:48 -0500 Subject: [PATCH] [msbuild] setup inputs and outputs for XamlC target Context: https://github.com/jonathanpeppers/XamarinAndroidBuildTimes After doing a profiling/review of Xamarin.Android project build times, I noticed that the `XamlC` target was running on every build no matter what. The project I used was the Forms Master/Detail template from VS 2017 15.6.4. In my test repo, I was timing the following situations: 1. Completely clean/fresh build 2. Build again, no changes 3. Change C#, build again 4. Change `AndroidResource` XML, build again In all cases `XamlC` was running, due to the task not having setup proper inputs and outputs for the MSBuild target. Thinking about it, it seemed like we could skip `XamlC` as long as the input assembly did not change, such as case no. 2 or no. 4. Changes to the `XamlC` target: - Setup `$(IntermediateOutputPath)$(TargetFileName)` (the assembly) as input - Setup a `XamlC.stamp` file as an output - `` the `XamlC.stamp` file after running the `XamlCTask` - Add to the `FileWrites` MSBuild item, so that the `IncrementalClean` target doesn't delete the stamp file On my Windows machine, this improved the following build times for cases: 1. same (XamlC should run) 2. 3.685s -> 2.887s 3. same (XamlC should run) (would also be same as XAML changing) 4. 12.126s -> 11.214s Since this was basically an empty project, I suspect the improvements would be more drastic for apps with lots of XAML and using `XamlC`. --- .nuspec/Xamarin.Forms.targets | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.nuspec/Xamarin.Forms.targets b/.nuspec/Xamarin.Forms.targets index 6e41a5652b0..2b3136990e0 100644 --- a/.nuspec/Xamarin.Forms.targets +++ b/.nuspec/Xamarin.Forms.targets @@ -85,10 +85,7 @@ - - - <_XamlCAlreadyExecuted>true - + + + +