Skip to content

Commit b69ad9e

Browse files
[Xamarin.Android.Build.Tasks] fix $(DestinationSubDirectory) double slash (#9186)
I noticed in a `.binlog` in .NET 9: ProcessAssemblies ... OutputItems ... D:\.nuget\packages\microsoft.maui.controls.core\9.0.0-preview.7.24407.4\lib\net9.0-android35.0\ar\Microsoft.Maui.Controls.resources.dll DestinationSubDirectory = arm64-v8a\ar\\ I believe this causes an issue, later down the line: FastDeploy ... Remove redundant file files/.__override__/arm64-v8a/ar/Microsoft.Maui.Controls.resources.dll So, `<FastDeploy/>` seems to delete every `Microsoft.Maui.Controls.resources.dll` file, because it is passed in: obj\Debug\net9.0-android\android\assets\arm64-v8a\ar\Microsoft.Maui.Controls.resources.dll TargetPath = arm64-v8a\ar\\Microsoft.Maui.Controls.resources.dll I think this was introduced in 86260ed, we can fix it by only appending to `%(DestinationSubDirectory)` if it *doesn't* end with a `DirectorySeparatorChar`. There may be additional safety we could add to the `<FastDeploy/>` task, in a separate PR. I updated a couple tests to look for: `Remove redundant file` To test this going forward, I'm going to review our MSBuild performance tests, and see if we can adjust the timings there.
1 parent d050fda commit b69ad9e

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/Xamarin.Android.Build.Tasks/Tasks/ProcessAssemblies.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,10 @@ void SetIt (ITaskItem? item)
186186
}
187187

188188
string destination = Path.Combine (abi, item.GetMetadata ("DestinationSubDirectory"));
189-
//Log.LogDebugMessage ($"DEBUG!!!'{item.ItemSpec}' '{rid}' = '{abi}'. DestinationSubDirectory='{destination}'");
190-
item.SetMetadata ("DestinationSubDirectory", destination + Path.DirectorySeparatorChar);
189+
if (destination.Length > 0 && destination [destination.Length - 1] != Path.DirectorySeparatorChar) {
190+
destination += Path.DirectorySeparatorChar;
191+
}
192+
item.SetMetadata ("DestinationSubDirectory", destination);
191193
item.SetMetadata ("DestinationSubPath", Path.Combine (destination, Path.GetFileName (item.ItemSpec)));
192194
}
193195
}

tests/MSBuildDeviceIntegration/Tests/InstallTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ public void IncrementalFastDeployment (string packageFormat)
583583
builder.BuildLogFile = "install3.log";
584584
Assert.IsTrue (builder.Install (app, doNotCleanupOnUpdate: true, saveProject: false), "Third install should have succeeded.");
585585
logLines = builder.LastBuildOutput;
586+
Assert.IsFalse (logLines.Any (l => l.Contains ("Remove redundant file")), "No redundant files should be deleted");
586587
Assert.IsTrue (logLines.Any (l => l.Contains ("NotifySync CopyFile") && l.Contains ("UnnamedProject.dll")), "UnnamedProject.dll should have been uploaded");
587588
Assert.IsTrue (logLines.Any (l => l.Contains ("NotifySync CopyFile") && l.Contains ("Library1.dll")), "Library1.dll should have been uploaded");
588589
Assert.IsTrue (logLines.Any (l => l.Contains ("NotifySync SkipCopyFile") && l.Contains ("Library2.dll")), "Library2.dll should not have been uploaded");

tests/MSBuildDeviceIntegration/Tests/InstantRunTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,10 @@ public void SkipFastDevAlreadyInstalledFile ()
155155
"Xamarin.AndroidX.AppCompat.dll",
156156
"Xamarin.AndroidX.Core.dll",
157157
};
158+
var logLines = b.LastBuildOutput;
159+
Assert.IsFalse (logLines.Any (l => l.Contains ("Remove redundant file")), "No redundant files should be deleted");
158160
foreach (var assembly in assemblies) {
159-
Assert.IsTrue (b.LastBuildOutput.Any (l => l.Contains (assembly) && l.Contains ("NotifySync SkipCopyFile")), $"{assembly} should be skipped, but no relevant log line");
161+
Assert.IsTrue (logLines.Any (l => l.Contains (assembly) && l.Contains ("NotifySync SkipCopyFile")), $"{assembly} should be skipped, but no relevant log line");
160162
}
161163

162164
Assert.IsTrue (b.Uninstall (proj), "uninstall should have succeeded.");

0 commit comments

Comments
 (0)