Skip to content

Commit 4b1ec57

Browse files
dellis1972jonathanpeppers
authored andcommitted
[Xamarin.Android.Build.Tasks] Support VS "Build Acceleration" (#9042)
Fixes: #8581 Fixes: https://dev.azure.com/devdiv/DevDiv/_workitems/edit/2051915 Context: https://github.com/dotnet/project-system/blob/9c9efad1d986e38232cbd74bec9dbd794883a91c/docs/build-acceleration.md Context: https://github.com/dotnet/project-system/blob/dd9431b535a6158060d7ab64597276eb2c354aab/docs/design-time-builds.md#targets-that-run-during-design-time-builds Context: https://github.com/dotnet/project-system/blob/dd9431b535a6158060d7ab64597276eb2c354aab/docs/up-to-date-check.md#default-inputs-and-outputs Context: https://github.com/dotnet/project-system/blob/dd9431b535a6158060d7ab64597276eb2c354aab/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/DesignTimeTargets/Microsoft.Managed.DesignTime.targets#L448-L449 Context: dc3ccf2 The Visual Studio Fast Up-to-Date Check (FUTDC) flags `_Microsoft.Android.Resource.Designer.dll` (dc3ccf2) as newer than the output assembly (which it is). But this flagging also causes it to incorrectly think the build is out of date. WARNING: Potential build performance issue in 'Foo.csproj'. The project does not appear up-to-date after a successful build: Input ResolvedCompilationReference item 'obj\Debug\net8.0-android\_Microsoft.Android.Resource.Designer.dll' (2023-12-11 11:34:12.546) has been modified since the last successful build started. Fix this by removing `_Microsoft.Android.Resource.Designer.dll` from the list of files checked. To do so, we *must* remove the item from the `@(ReferencePathWithRefAssemblies)` item group *before* the [`CollectResolvedCompilationReferencesDesignTime`][0] target runs. This is because that Target uses the [`Returns` attribute][1]; it turns out you cannot modify the ItemGroup that is being returned via the `Returns` attribute on a target. Unfortunately there isn't a way to unit test this since the Fast Update check *only* runs in Visual Studio. The targets do not even exist on the command line. [0]: https://github.com/dotnet/project-system/blob/dd9431b535a6158060d7ab64597276eb2c354aab/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/DesignTimeTargets/Microsoft.Managed.DesignTime.targets#L448-L449 [1]: https://learn.microsoft.com/visualstudio/msbuild/target-element-msbuild?view=vs-2022
1 parent b1c6040 commit 4b1ec57

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Resource.Designer.targets

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,28 @@ Copyright (C) 2016 Xamarin. All rights reserved.
196196
</ItemGroup>
197197
</Target>
198198

199+
<!--
200+
The Visual Studio FastUpdate check flags the Resource Designer assembly as
201+
newer than the output assembly (which it is). But it causes it to incorrectly
202+
think the build is out of date.
203+
204+
So lets remove it. We MUST remove the item from the @ReferencePathWithRefAssemblies
205+
ItemGroup BEFORE the CollectResolvedCompilationReferencesDesignTime target runs.
206+
This is because that target uses the Returns functionality. It turns out you cannot
207+
modify the ItemGroup that is being returned via a Returns on a target.
208+
-->
209+
<Target Name="_RemoveResourceDesignerFromResolvedComilationReferences"
210+
BeforeTargets="CollectResolvedCompilationReferencesDesignTime"
211+
Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'"
212+
>
213+
<ItemGroup>
214+
<_ResourceDesignerFiles Include="%(ReferencePathWithRefAssemblies.Identity)"
215+
Condition="'%(ReferencePathWithRefAssemblies.OriginalPath)' == '$(_GenerateResourceDesignerAssemblyOutput)'"
216+
/>
217+
<ReferencePathWithRefAssemblies Remove="@(_ResourceDesignerFiles)" />
218+
</ItemGroup>
219+
</Target>
220+
199221
<Target Name="_BuildResourceDesigner"
200222
Condition=" '$(AndroidUseDesignerAssembly)' == 'True' "
201223
DependsOnTargets="$(_BuildResourceDesignerDependsOn)" />

0 commit comments

Comments
 (0)