.net core MSBuild normalizes slashes when it shouldn't
See original GitHub issueDescription copied from internal email
Repro steps:
- On linux, get the latest CLI
- Create a new project “test.csproj”(dotnet new)
- Run
dotnet msbuild /p:RestoreSources=/tmp/some-source%3Bhttps://api.nuget.org/v3/index.json /t:restore test.csproj /v:diag > output - In output file, search “RestoreSources” and “Sources”.
You can find RestoreSources = /tmp/some-source;https://api.nuget.org/v3/index.json Sources= /tmp/some-source;https:/api.nuget.org/v3/index.json
The target file: https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets#L415
<Sources>$(RestoreSources)<Sources>
The known workaround is to escape the slash so MSBuild treats it as a literal:
dotnet msbuild /p:RestoreSources=/tmp/some-source%3Bhttps:%2F%2Fapi.nuget.org/v3/index.json /t:restore test.csproj /v:diag > output
Issue Analytics
- State:
- Created 7 years ago
- Reactions:7
- Comments:9 (5 by maintainers)
Top Results From Across the Web
net core MSBuild normalizes slashes when it shouldn't
Description copied from internal email. Repro steps: 1. On linux, get the latest CLI 2. Create a new project “test.csproj”(dotnet new)
Read more >How do I stop MSBuild from replacing backslashes with ...
MSBuild normally replaces backslashes in your build file (usually found in paths) with forward slashes, which helps when working on a cross- ...
Read more >MSBuild Reserved and Well-known Properties
Property Reserved or well‑known Description
FrameworkSDKRoot Well‑known Path to the root folder for .NET Framewor...
MSBuildExtensionsPath Well‑known
MSBuildLastTaskResult Reserved
Read more >Path.Combine() isn't as cross-platform as you think it is
Well now with .NET Core, cross-platform .NET is a reality, but as it turns out, Path.Combine() isn't quite the cross ...
Read more >Security Code Scan
Stand-alone runner or through MSBuild for custom integrations. Analyzes .NET and .NET Core projects in a background (IntelliSense) or during a build.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@stan-sz, more that don’t work:
\,$([MSBuild]::Escape(\)). However,%5Cdoes work for me. Here’s how I used it for a multi-line command:How is this open for 6 years with Priority:1 removed