dotnet / dotnet/msbuild

Backslash in property gets converted to forward slash on Linux

Open
#3,468 19 comments 15 reactions 0 assignees View on GitHub
needs-design Priority:2 triaged xplat
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

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`:
```xml


\(([^]]+)\)



```

### 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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.