Repository navigation
[dotnet] Compute _RelativeAppBundlePath correctly when the app bundle is on a different drive than the project. - #27407
Open
Kebechet wants to merge 1 commit into
Conversation
… is on a different drive than the project.
On Windows, MakeRelative can't compute a relative path between two drives, so
when the output directory is on a different drive than the project,
_AppBundlePath stays an absolute path. _ComputeVariables then appended it to
the project directory, which produced a path with a drive letter in the middle:
_RelativeAppBundlePath=D:\src\MyApp\C:\out\MyApp\bin\Debug\net10.0-ios\iossimulator-arm64\MyApp.app\
Use Path.Combine instead, which keeps an absolute path as-is and otherwise
appends it to the project directory (so nothing changes on macOS, where
_AppBundlePath is always relative).
Also trim the result of the target-aware DotNet.GetProperty overload: MSBuild
writes a trailing newline after the value in the result file (the other
GetProperty overload already trims its result).
Ref: dotnet/maui#17438
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
On Windows,
MakeRelativecan't compute a relative path between two drives, so when the output directory is on a different drive than the project (for example the project onD:andBaseOutputPathonC:),_AppBundlePathstays an absolute path._ComputeVariablesthen appended it to the project directory, which produced a path with a drive letter in the middle:Older MSBuild versions threw on this (
MSB4184: The given path's format is not supported, reported in dotnet/maui#17438). Current MSBuild computes the corrupted value silently on every Windows build, and it flows into_AssemblyPublishDir,_DylibPublishDir, theRelativePathofResolvedFileToPublishand the custom linker options.This uses
Path.Combineinstead, which keeps an absolute path as-is and otherwise appends it to the project directory. Nothing changes on macOS, where_AppBundlePathis always relative.To be transparent about the impact: I don't think this is user-visible in a supported scenario today. A build without a remote Mac doesn't consume the value, and remote builds reject an absolute
OutputPathin_VerifyNoAbsoluteOutputPathbefore getting here. The same "project directory + possibly absolute path" pattern also exists in_AppExtensionBundlePath,_WatchAppBundlePathand the archive paths inXamarin.iOS.Common.After.targets; this PR doesn't change those.Tests
WindowsTest.AppBundleOnDifferentDrive(categoryWindows, iOS and Mac Catalyst): runs_ComputeVariableswithBaseOutputPathon another drive than the project and asserts_RelativeAppBundlePathis..\MySimpleApp.app\. The other drive doesn't have to exist, nothing is written there.DotNet.GetPropertyoverload returned the trailing newline MSBuild writes to the result file, so I made it trim the value like the otherGetPropertyoverload does.I couldn't run the test against packs built from this branch (that needs a macOS build), so I ran it locally on Windows against the .NET 10 iOS / Mac Catalyst 26.5.10318 SDK packs with only this line patched: it fails without the fix (both platforms) and passes with it. Default output and same-drive absolute output give the same
..\MySimpleApp.app\with and without the fix.