msbuild
msbuild copied to clipboard
Backslash in property gets converted to forward slash on Linux
When a property contains backslashs in a project file, it will be converted to forward slashs when running with msbuild on Linux.
While this would be fine for paths (although one could just as well use forward slash in the project file since that works on both Windows and Linux), it causes problems when trying to set a regular expression in a property which requires a backslash to escape the next character.
Steps to reproduce
Project file bug.proj
:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Regex>\(([^]]+)\)</Regex>
</PropertyGroup>
<Target Name="Build">
<Message Text="Regex=$(Regex)"/>
</Target>
</Project>
Command line
msbuild /t:Build bug.proj
Expected behavior
Outputs the line
Regex=\(([^]]+)\)
Actual behavior
Outputs the line
Regex=/(([^]]+)/)
Environment data
msbuild /version
output: 15.6.0.0
Also happens with xbuild
from older Mono versions.
When building with dotnet build -v d bug.proj
the output is as expected.
OS Info: Ubuntu 16.04.4 LTS