Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[One .NET] conditionally add
generated\*\*.cs
to @(Compile) (#6291)
Fixes: #6280 .NET 6 projects have the following issue: 1. Build a .NET 6 project with a `.jar` to create a C# binding. 2. Delete the `.jar` completely & build again. 3. The generated C# binding types remain in the assembly! We have the following expression to decide when C#-binding related targets should be completely skipped: Condition=" '$(UsingAndroidNETSdk)' != 'true' Or '@(InputJar->Count())' != '0' Or '@(EmbeddedJar->Count())' != '0' Or '@(LibraryProjectZip->Count())' != '0' " This allows the targets to run for "legacy" Xamarin.Android binding projects, and .NET 6 project when certain item groups are non-empty. We were missing this condition on the `AddBindingsToCompile` MSBuild target! <Target Name="AddBindingsToCompile" DependsOnTargets="GenerateBindings"> <ItemGroup> <Compile Include="$(IntermediateOutputPath)generated\*\*.cs" /> </ItemGroup> </Target> I don't think we necessarily have to delete this directory; these files should just not be added to the `@(Compile)` item group. Instead of copying this long `Condition` to a third place, refactor the expression into a new `_SetAndroidGenerateManagedBindings` MSBuild target. All three places can use a simpler expression that will be harder to mess up: Condition=" '$(_AndroidGenerateManagedBindings)' == 'true' " I updated a test to verify removing a `.jar` removes the C# classes from the compiled assembly.
- Loading branch information
1 parent
bf77a7c
commit 33e92ca
Showing
4 changed files
with
28 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters