-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[Bug]: Transforming backslashes to slashes next to a property value on macOS #9200
Comments
Workaround: it seem that doing <RelativePath1>mydir\$(MyFileName)%5C</RelativePath1> would make it print:
|
I suspect there is a bug but it's minor because MSBuild will accept both Because the directory separator is different between OSes, if you want paths to be consistent within a build, consider avoiding hard coding the directory separator. You can use <PropertyGroup>
...
<RelativePath4>$([MSBuild]::EnsureTrailingSlash($([System.IO.Path]::Combine('mydir', '$(MyFileName)'))))</RelativePath4>
</PropertyGroup>
<Target Name="Print">
...
<Message Text="RelativePath4: $(RelativePath4)" Importance="high"/>
</Target> These functions will use the native directory separator. You can get the native directory separator with <PropertyGroup>
<DirectorySeparator>$([System.IO.Path]::DirectorySeparatorChar())</DirectorySeparator>
</PropertyGroup> When the build runs on Windows the paths will use (Similarly and also related to OS portability, with MSBuild v17.3 and later you can use |
@jrdodds thank you for your suggestions! However, I did not provide enough context to explain why using With the support of Within the SDK, we need to construct a relative path, which the runtime will use to lookup files during the app execution. Since the build host (where MSBuild is running) is Windows, and the target platforms is iOS (Unix) the constructed relative path will be invalid if Having said all this, as a workaround we use: In any case, the issue reported here is still very much reproducible and is not tied to path manipulation. It is just a use case where it occurred, but I agree it is probably a niche one. |
Issue Description
This is maybe not a bug, but I did not manage to find a way to get a single trailing backslash when building up a relative path in a project file (please see the repro steps).
PS If there is an existing/proper way to do this, I would like to know the way. Thank you!
Steps to Reproduce
Expected Behavior
Not sure what is the expected behaviour, but I wanted to achieve to get a single trailing backslash:
Actual Behavior
The build prints out:
Analysis
No response
Versions & Configurations
dotnet sdk version:
8.0.100-preview.7.23376.3
machine/OS:
MacBookPro M1
- macOS Ventura:Version 13.5.1 (22G90)
The text was updated successfully, but these errors were encountered: