NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 252 forks source link

NuGet is munging URL sources when passed in from the commandline #6678

Open ericstj opened 6 years ago

ericstj commented 6 years ago

Details about Problem

When passing in an HTTP URL source preceded by a local source NuGet is munging the URL.

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): dotnet.exe

NuGet version (x.x.x.xxx): 4.7.0.4927

dotnet.exe --version (if appropriate): 2.1.300-preview2-008349

OS version (i.e. win10 v1607 (14393.321)): win10 v1709 16299.248

Worked before? If so, with which NuGet version: Yes, 4.0.0.2283

I reproed the broken behavior in all versions of the SDK 2.0.0 and greater. The code that hit this was previously working on a pre-release version of the 2.0 SDK. As I mentioned below I suspect the 2.0 era change was what broke it.

Detailed repro steps so we can see the same problem

  1. Create a project and add a reference:

    
    <ItemGroup>
    <PackageReference Include="System.Banana.1.1.dll.dotnet" Version="1.0.0" />
    </ItemGroup>
  2. Run restore passing two sources, the first a local path, the second a url.

dotnet restore -s c:\ -s https://www.myget.org/F/ericstj-issue-repros/api/v3/index.json

Expect: Successfully restore

Actual: Fails with following error

C:\nuGetRestoreTest>dotnet restore -s c:\ -s https://www.myget.org/F/ericstj-issue-repros/api/v3/index.json
  Restoring packages for C:\nuGetRestoreTest\nuGetRestoreTest.csproj...
C:\Program Files\dotnet\sdk\2.1.300-preview2-008349\NuGet.targets(114,5): error : The local source 'C:\nuGetRestoreTest\https:\www.myget.org\F\ericstj-issue-repros\api\v3\index.json' doesn't exist. [C:\nuGetRestoreTest\nuGetRestoreTest.csproj]

Note that the URL has been mangled: slashes converted to backslashes, deduped, then concated with the working dir. I suspect this is related to https://github.com/NuGet/NuGet.Client/commit/73fbfdf9c770733f9a1d95e0803f68777446f4db. @emgarten

Verbose Logs

msbuild.log

Sample Project

nuGetRestoreTest.zip

/cc @ahsonkhan

ericstj commented 6 years ago

@rrelyea can you triage this? Appears to be a regression when passing in -s on the commandline to dotnet restore. Regression happened between 1.x and 2.x.