question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.net core MSBuild normalizes slashes when it shouldn't

See original GitHub issue

Description copied from internal email

Repro steps:

  1. On linux, get the latest CLI
  2. Create a new project “test.csproj”(dotnet new)
  3. Run dotnet msbuild /p:RestoreSources=/tmp/some-source%3Bhttps://api.nuget.org/v3/index.json /t:restore test.csproj /v:diag > output
  4. 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:open
  • Created 7 years ago
  • Reactions:7
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
r3h0commented, Apr 3, 2022

@stan-sz, more that don’t work: &#92;, $([MSBuild]::Escape(&#92;)). However, %5C does work for me. Here’s how I used it for a multi-line command:

  <Target Name="GenerateGrpcSources" BeforeTargets="CoreCompile">
    <Exec Command="/bin/bash -ce &quot;
    echo 'Generating code...';
    $(NuGetPackageRoot)google.protobuf.tools/3.5.1/tools/linux_x64/protoc %5C
        -I$(NuGetPackageRoot)google.protobuf.tools/3.5.1/tools/google/protobuf %5C
        --proto_path=$(NuGetPackageRoot)google.protobuf.tools/3.5.1/tools %5C
        --proto_path=$(ProjectDir)Protobuf %5C
        --csharp_out=$(ProjectDir)Messages %5C
        $(ProjectDir)Protobuf/*.proto %5C
        ;
    echo 'Done generating code.';
    &quot;" />
  </Target>
1reaction
Happypig375commented, Jun 23, 2023

How is this open for 6 years with Priority:1 removed

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found