Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit b5072d1

Browse files
[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 - `<Touch />` 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`.
1 parent fed9177 commit b5072d1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

.nuspec/Xamarin.Forms.targets

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,17 @@
8585
</CompileDependsOn>
8686
</PropertyGroup>
8787

88-
<Target Name="XamlC" AfterTargets="AfterCompile" Condition="'$(_XamlCAlreadyExecuted)'!='true'">
89-
<PropertyGroup>
90-
<_XamlCAlreadyExecuted>true</_XamlCAlreadyExecuted>
91-
</PropertyGroup>
88+
<Target Name="XamlC" AfterTargets="AfterCompile" Inputs="$(IntermediateOutputPath)$(TargetFileName)" Outputs="$(IntermediateOutputPath)XamlC.stamp">
9289
<XamlCTask
9390
Assembly = "$(IntermediateOutputPath)$(TargetFileName)"
9491
ReferencePath = "@(ReferencePath)"
9592
OptimizeIL = "true"
9693
DebugSymbols = "$(DebugSymbols)"
9794
DebugType = "$(DebugType)"
9895
KeepXamlResources = "$(XFKeepXamlResources)" />
96+
<Touch Files="$(IntermediateOutputPath)XamlC.stamp" AlwaysCreate="True">
97+
<Output TaskParameter="TouchedFiles" ItemName="FileWrites"/>
98+
</Touch>
9999
</Target>
100100

101101
<!-- CssG -->

0 commit comments

Comments
 (0)