Skip to content

Backslash in property gets converted to forward slash on LinuxΒ #3468

@ermshiperete

Description

@ermshiperete

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority:2Work that is important, but not critical for the releaseneeds-designRequires discussion with the dev team before attempting a fix.triagedxplat

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions