Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Update Nuget Package Failed because URL to an interal Nuget Feed contains a Space #942

Closed
may82 opened this issue Apr 25, 2020 · 2 comments

Comments

@may82
Copy link

may82 commented Apr 25, 2020

🐛 Bug Report

We are happy that we found this tool. Our system configuration is special, so we encountered a rare error.

Our internal Nuget-Feed Link (e.g. http:\tfs.local\Our%20Solution_packaging/our-Feed/nuget/v3/index.json) contains a space.

In line 36 (DotNetUpdatePackageCommand.cs) NuKeeper cut the Url in two parts (e.g. http:\tfs.local\Our Solution_packaging/our-Feed/nuget/v3/index.json) while executing "dotnet add" command.

here is the part of the log (--verbosity D) before the exception is thrown:
Nuget restore on local.project.TestConsole.csproj complete In path C:\tfs\OurSolution\local.project\Development\local.project.TestConsole, running command: dotnet restore local.project.TestConsole.csproj -s http://tfs.local/Our%20Solution/_packaging/our-Feed/nuget/v3/index.json In path C:\tfs\OurSolution\local.project\Development\local.project.TestConsole, running command: dotnet remove local.project.TestConsole.csproj package local.package In path C:\tfs\OurSolution\local.project\Development\local.project.TestConsole, running command: dotnet add local.project.TestConsole.csproj package local.package -v 1.0.4.209 -s http://tfs.local/Our Solution/_packaging/our-Feed/nuget/v3/index.json

Expected behavior

To add in line 36 masked quotes for parameter "-s"

e.g. dotnet add local.project.TestConsole.csproj package local.package -v 1.0.4.209 -s "http://tfs.local/Our Solution/_packaging/our-Feed/nuget/v3/index.json"

@AnthonySteele
Copy link
Member

AnthonySteele commented Apr 29, 2020

What's interesting is that the dotnet restore part escapes the url. I assume that the %20 escaping there is correct and can be applied to the dotnet add part as well?

Although, the issue is really with a command-line param containing a space, so quoting it with " " seems a more accurate fix.

AnthonySteele pushed a commit to AnthonySteele/NuKeeper that referenced this issue Apr 29, 2020
cannot apply Uri.EscapeUriString blinbdly, or it will double-escape already escaped strings
For NuKeeperDotNet#942
AnthonySteele added a commit that referenced this issue Apr 29, 2020
* Escape uris that contain spaces
cannot apply Uri.EscapeUriString blinbdly, or it will double-escape already escaped strings
For #942

* escape with ""

* Use `ArgumentEscaper.EscapeAndConcatenate` which will wrap in quotes if need be
And is generally more detailed and robust than what I  did
see https://github.com/natemcmaster/CommandLineUtils/blob/master/src/CommandLineUtils/Utilities/ArgumentEscaper.cs

Co-authored-by: Anthony Steele <anthony.steele@pockit.com>
@AnthonySteele
Copy link
Member

Should be fixed in latest release, can you verify?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants