Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 578
Exclude satellite assemblies from _PostTrimmingPipeline#11086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2 ...id.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.LlvmIr.targets
This file contains hidden or 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
82 changes: 82 additions & 0 deletions
82 src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -726,6 +726,88 @@ public void MissingSatelliteAssemblyInApp ([Values] bool publishAot, [Values] An | ||
| } | ||
| } | ||
| /// <summary> | ||
| /// Verifies that _PostTrimmingPipeline does not include satellite assemblies | ||
| /// (.resources.dll) in its input. Satellite assemblies are not processed by | ||
| /// ILLink and retain their original paths in the shared NuGet package cache. | ||
| /// Including them causes PostTrimmingPipeline to open them with ReadWrite | ||
| /// access, leading to IOException in parallel multi-RID builds. | ||
| /// See: https://github.com/dotnet/android/issues/11085 | ||
| /// </summary> | ||
| [Test] | ||
| [NonParallelizable] // Commonly fails NuGet restore | ||
| public void PostTrimmingPipelineExcludesSatelliteAssemblies () | ||
| { | ||
| var proj = new XamarinAndroidApplicationProject { | ||
| IsRelease = true, | ||
| }; | ||
| proj.SetRuntime (AndroidRuntime.MonoVM); | ||
| proj.SetRuntimeIdentifiers (AndroidTargetArch.Arm64); | ||
| proj.PackageReferences.Add (new Package { | ||
| Id = "Humanizer.Core", | ||
| Version = "2.14.1", | ||
| }); | ||
| proj.PackageReferences.Add (new Package { | ||
| Id = "Humanizer.Core.es", | ||
| Version = "2.14.1", | ||
| }); | ||
| proj.MainActivity = proj.DefaultMainActivity | ||
| .Replace ("//${USINGS}", @"using Humanizer; | ||
| using System.Globalization;") | ||
| .Replace ("//${AFTER_ONCREATE}", @"var c = new CultureInfo (""es-ES""); | ||
| Console.WriteLine ($""{DateTime.UtcNow.AddHours(-30).Humanize(culture:c)}"");"); | ||
| proj.OtherBuildItems.Add (new BuildItem ("Using", "System.Globalization")); | ||
| proj.OtherBuildItems.Add (new BuildItem ("Using", "Humanizer")); | ||
| // Inject a diagnostic target that logs the _PostTrimmingAssembly items | ||
| // created by the production _PostTrimmingPipeline target. In MSBuild, | ||
| // items defined in a target's <ItemGroup> are visible to subsequent targets. | ||
| proj.Imports.Add (new Import ("PostTrimmingDiag.targets") { | ||
| TextContent = () => """ | ||
| <Project> | ||
| <Target Name="_DiagLogPostTrimmingAssemblies" | ||
| AfterTargets="_PostTrimmingPipeline" | ||
| Condition=" '$(PublishTrimmed)' == 'true' "> | ||
| <Message Importance="high" Text="DIAG_PTA: %(_PostTrimmingAssembly.Identity)" /> | ||
| <Message Importance="high" Text="DIAG_RFP: %(ResolvedFileToPublish.Identity)" | ||
| Condition=" '%(ResolvedFileToPublish.Extension)' == '.dll' and '%(Filename)' != '' and $([System.String]::Copy('%(Filename)').EndsWith('.resources')) " /> | ||
| </Target> | ||
| </Project> | ||
| """, | ||
| }); | ||
| using var b = CreateApkBuilder (); | ||
| Assert.IsTrue (b.Build (proj), "Build should have succeeded."); | ||
| // Verify the diagnostic target actually ran and logged assemblies | ||
| Assert.IsTrue ( | ||
| b.LastBuildOutput.ContainsText ("DIAG_PTA:"), | ||
| "Diagnostic target should have logged _PostTrimmingAssembly items"); | ||
| // Verify satellite assemblies ARE present in ResolvedFileToPublish (positive check) | ||
| bool hasSatelliteInRfp = false; | ||
| foreach (var line in b.LastBuildOutput) { | ||
| if (line.Contains ("DIAG_RFP:") && line.Contains (".resources.dll")) { | ||
| hasSatelliteInRfp = true; | ||
| break; | ||
| } | ||
| } | ||
| Assert.IsTrue (hasSatelliteInRfp, | ||
| "Satellite assemblies should be present in ResolvedFileToPublish to confirm the scenario is exercised"); | ||
| // Verify satellite assemblies were NOT included in _PostTrimmingAssembly | ||
| var satelliteLines = new List<string> (); | ||
| foreach (var line in b.LastBuildOutput) { | ||
| if (line.Contains ("DIAG_PTA:") && line.Contains (".resources.dll")) { | ||
| satelliteLines.Add (line.Trim ()); | ||
| } | ||
| } | ||
| Assert.IsEmpty (satelliteLines, | ||
| "Satellite assemblies (.resources.dll) should not be passed to PostTrimmingPipeline. " + | ||
| "They retain paths in the shared NuGet cache and cause file locking conflicts in parallel RID builds. Found:\n" + | ||
| string.Join ("\n", satelliteLines)); | ||
sbomer marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| [Test] | ||
| public void IgnoreManifestFromJar ([Values] AndroidRuntime runtime) | ||
| { | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.