Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Xamarin.Android.Build.Tasks] improve incremental design-time builds (#…
…6406) I was testing .NET MAUI projects inside Visual Studio, and noticed on solution load two sets of builds run for each `$(TargetFramework)`: 1. `CollectPackageReferences;CollectFrameworkReferences;CollectUpToDateCheckBuiltDesignTime;CollectPackageDownloads;GenerateSupportedTargetFrameworkAlias;CollectAnalyzersDesignTime;CollectUpToDateCheckInputDesignTime;CollectUpToDateCheckOutputDesignTime;CollectSuggestedWorkloads;CollectCentralPackageVersions;CompileDesignTime;CollectResolvedCompilationReferencesDesignTime` 2. `ResolveFrameworkReferencesDesignTime;ResolveProjectReferencesDesignTime2;CollectResolvedSDKReferencesDesignTime;ResolveComReferencesDesignTime;ResolveAssemblyReferencesDesignTime;ResolvePackageDependenciesDesignTime;CollectSuggestedWorkloads` 1) net6.0-maccatalyst 0.344s 1) net6.0-ios 0.353s 1) net6.0-android 1.466s 2) net6.0-maccatalyst 0.063s 2) net6.0-ios 0.059s 2) net6.0-android 1.424s Android is the worst in both cases, due to: GenerateResourceDesigner 737ms GenerateResourceDesigner 766ms I'm not sure how I got in this state, but the `_ManagedUpdateAndroidResgen` MSBuild target *never* skips for me: Building target "_ManagedUpdateAndroidResgen" completely. Input file "C:\Program Files\dotnet\sdk-manifests\6.0.100\microsoft.net.sdk.maui\WorkloadManifest.targets" is newer than output file "obj\Debug\net6.0-android\designtime\Resource.designer.cs". Plausibly I built this app, and then updated the `maui` workload, then tried future incremental builds. Reviewing the `<GenerateResourceDesigner/>` MSBuild task, there is a case it doesn't update the timestamp on the `Resource.designer.cs` output file. I added a `<Touch/>` call to solve this issue: <Touch Condition="Exists ('$(_AndroidManagedResourceDesignerFile)')" Files="$(_AndroidManagedResourceDesignerFile)" /> This is a nice solution, as it is localized to the MSBuild target where the `Inputs` and `Outputs` are. While I was at it, I switched from using a `new StreamWriter()` to `MemoryStreamPool`. `MemoryStreamPool` usage saw a modest improvement: Before: GenerateResourceDesigner 491ms After: GenerateResourceDesigner 480ms Overall these changes should improve all design-time builds by ~11ms, and some incremental design-time builds will properly skip: saving up to ~766ms.
- Loading branch information