Description
We've never supported absolute paths for [Intermediate]OutputPath, but this has not been a frequent problem, because the default was to use relative paths.
However, in .NET 8, a new output path mode was implemented (UseArtifactsPath=true
), and now absolute paths for [Intermediate]OutputPath will be much more common.
As such, we should look into making absolute paths work.
This wasn't done for .NET 8 because it's a rather complicated problem to fix, and the complexity was discovered too late in the release cycle. In the meantime, we've added logic to detect the scenario, and show an actionable error instead (#18900).
The basic problem is that the project's remote directory, the one with the hash:
/Users/rolf/Library/Caches/Xamarin/mtbs/builds/DotNet8Test/f915cefc3161dc001199a62de03b2def4b16a89c7efc331dce9f95ca9b91ccc1/
is both the root of the project directory (so any relative paths are resolved relative to that directory) as well as the root of the drive system (so it contains C:/... paths).
This means that a given path has two valid locations if it's inside the project directory:
- As a relative path:
/Users/rolf/Library/Caches/Xamarin/mtbs/builds/DotNet8Test/f915cefc3161dc001199a62de03b2def4b16a89c7efc331dce9f95ca9b91ccc1/outputdir/whatever
- As an absolute path
/Users/rolf/Library/Caches/Xamarin/mtbs/builds/DotNet8Test/f915cefc3161dc001199a62de03b2def4b16a89c7efc331dce9f95ca9b91ccc1/C:/source/projects/DotNet8Test/outputdir/whatever
and the build breaks when one file is in one location, but our build logic expects it in the other.
One potential fix would be to only work with absolute paths on the Mac (relative to the hash directory), so that the build would create this path:
/Users/rolf/Library/Caches/Xamarin/mtbs/builds/DotNet8Test/f915cefc3161dc001199a62de03b2def4b16a89c7efc331dce9f95ca9b91ccc1/C:/source/projects/DotNet8Test/
make that the current directory, and make all relative paths relative to that directory. Then there would be no confusion, because each path wouldn't have two different locations.
References:
- Unable to build .NET MAUI iOS project on Windows #18510
- https://developercommunity.visualstudio.com/t/Unable-to-build-NET-for-iOS-projects-on/10409856 (https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1847166)
- https://devblogs.microsoft.com/dotnet/announcing-dotnet-8-preview-3/#simplified-output-path
- [net8.0] [msbuild] Show an error for a remote build if [Intermediate]OutputPath is an absolute path. #18900