NuGet / Home

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

[Bug]: Sources passed via command line are not used to restore SDK packages with dotnet restore #11252

Closed Thorarin closed 3 years ago

Thorarin commented 3 years ago

NuGet Product Used

dotnet.exe

Product Version

SDK 5.0.400, host 5.0.9.

Worked before?

SDK 5.0.203, unknown host.

Impact

It's more difficult to complete my work

Repro Steps & Context

Some of our C# projects use an in-house SDK NuGet package, hosted on Azure Artifacts.

  1. Create a .csproj ("MyProject.csproj") with a custom SDK package ("MySdkPackage") which does not exist on NuGet.org.
  2. Pass NuGet sources explicitly on the command line: dotnet.exe restore --source https://pkgs.dev.azure.com/XXXXX/XXXX/_packaging/packages/nuget/v3/index.json -v diag
  3. Only api.nuget.org is used to attempt to restore the package, which fails.

Normally we pass multiple sources via the command line, but this should be sufficient for a repro.

Notes:

Verbose Logs

dotnet.exe restore --source https://pkgs.dev.azure.com/XXXXX/XXXX/_packaging/packages/nuget/v3/index.json -v diag

C:\Program Files\dotnet\sdk\5.0.400\MSBuild.dll -nologo -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\5.0.400\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwa
rdingLogger,C:\Program Files\dotnet\sdk\5.0.400\dotnet.dll -maxcpucount -property:RestoreSources=https:%2F%2Fpkgs.dev.azure.com/XXXXX/XXXX/_packaging/packages/nuget/v3/index.j
son -target:Restore -verbosity:m -verbosity:diag .\MyProject.csproj

Build started 21-9-2021 10:41:22.
Environment at start of build:
ALLUSERSPROFILE = C:\ProgramData
APPDATA = C:\Users\buildserver\AppData\Roaming
ASPNETCORE_ENVIRONMENT = Development
ChocolateyInstall = C:\ProgramData\chocolatey
CommonProgramFiles = C:\Program Files\Common Files
CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files
CommonProgramW6432 = C:\Program Files\Common Files
COMPUTERNAME = BUILDAGENT01
ComSpec = C:\Windows\system32\cmd.exe
DevEnvDir = C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\
DNX_HOME = %USERPROFILE%\.dnx
DOTNET_HOST_PATH = C:\Program Files\dotnet\dotnet.exe
FP_NO_HOST_CHECK = NO
Framework40Version = v4.0
FrameworkDir = C:\Windows\Microsoft.NET\Framework\
FrameworkDIR32 = C:\Windows\Microsoft.NET\Framework\
FrameworkVersion = v4.0.30319
FrameworkVersion32 = v4.0.30319
GYP_MSVS_VERSION = 2015
HOMEDRIVE = C:
HOMEPATH = \Users\buildserver
INCLUDE = C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE;C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um;C:\Program Files (x86)\Windows Kits\8.1\include\\shared;C:\Program Files (x86)\Windows Kits\8.1\include\\um;C:\Program Files (x86)\Windows Kits\8.1\include\\winrt;
JAVA_HOME = E:\buildserver\Java\jdk1.7.0_51
JRE_HOME = E:\buildserver\Java\jre1.8.0_31
LIB = C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB;C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x86;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x86;C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86;
LIBPATH = C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB;C:\Program Files (x86)\Windows Kits\8.1\References\CommonConfiguration\Neutral;\Microsoft.VCLibs\14.0\References\CommonConfiguration\neutral;
LOCALAPPDATA = C:\Users\buildserver\AppData\Local
MSBuildExtensionsPath = C:\Program Files\dotnet\sdk\5.0.400\
MSBuildLoadMicrosoftTargetsReadOnly = true
MSBuildSDKsPath = C:\Program Files\dotnet\sdk\5.0.400\Sdks
NETFXSDKDir = C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\
NUMBER_OF_PROCESSORS = 4
OS = Windows_NT
Path = C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\MSBuild\14.0\bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\VCPackages;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Performance Tools;C:\Program Files (x86)\Windows Kits\8.1\bin\x86;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\CollabNet\Subversion Client;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Windows\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Git\cmd;E:\buildserver\npm;C:\Program Files\dotnet\;C:\Program Files (x86)\dotnet\;C:\Python27;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\DTS\Binn\;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\Yarn\bin\;C:\Program Files\nodejs\;C:\Program Files (x86)\dotnet-core-uninstall\;C:\Users\buildserver\.dnx\bin;C:\Users\buildserver\.dotnet\tools;C:\Users\buildserver\AppData\Roaming\npm
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE = AMD64
PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 63 Stepping 2, GenuineIntel
PROCESSOR_LEVEL = 6
PROCESSOR_REVISION = 3f02
ProgramData = C:\ProgramData
ProgramFiles = C:\Program Files
ProgramFiles(x86) = C:\Program Files (x86)
ProgramW6432 = C:\Program Files
PROMPT = $P$G
PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShell\Modules\
PUBLIC = C:\Users\Public
READY_API = C:\Program Files\SmartBear\ReadyAPI-3.9.0\bin
SESSIONNAME = RDP-Tcp#0
SystemDrive = C:
SystemRoot = C:\Windows
TEAMCITY_DATA_PATH = E:\buildserver\TeamCityData
TEMP = C:\Users\BUILDS~1\AppData\Local\Temp\2
TMP = C:\Users\BUILDS~1\AppData\Local\Temp\2
UCRTVersion = 10.0.10240.0
UniversalCRTSdkDir = C:\Program Files (x86)\Windows Kits\10\
USERNAME = buildserver
USERPROFILE = C:\Users\buildserver
VCINSTALLDIR = C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\
VisualStudioVersion = 14.0
VS100COMNTOOLS = C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\
VS140COMNTOOLS = C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
VSINSTALLDIR = C:\Program Files (x86)\Microsoft Visual Studio 14.0\
windir = C:\Windows
WindowsLibPath = C:\Program Files (x86)\Windows Kits\8.1\References\CommonConfiguration\Neutral
WindowsSdkDir = C:\Program Files (x86)\Windows Kits\8.1\
WindowsSDKLibVersion = winv6.3\
WindowsSDKVersion = \
WindowsSDK_ExecutablePath_x64 = C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\
WindowsSDK_ExecutablePath_x86 = C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\

09:43:22.765     0>Process = "C:\Program Files\dotnet\dotnet.exe"
                   MSBuild executable path = "C:\Program Files\dotnet\sdk\5.0.400\MSBuild.dll"
                   Command line arguments = ""C:\Program Files\dotnet\sdk\5.0.400\MSBuild.dll" -maxcpucount -verbosity:m -nologo -target:Restore -property:RestoreSources=https:%2F%2Fpkgs.dev.azure.com/XXXXX/
XXXX/_packaging/packages/nuget/v3/index.json -verbosity:diag "-distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\5.0.400\dotnet.dll*Micro
soft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\Program Files\dotnet\sdk\5.0.400\dotnet.dll""
                   Current directory = "E:\BuildAgents\2\work\f45588a65f7fdf68\MyProject"
                   MSBuild version = "16.11.0+0538acc04"
                   Resolving SDK 'MySdkPackage/1.1.2'...
                   Running restore with 4 concurrent jobs.
                   Reading project file C:\Users\buildserver\AppData\Local\Temp\2\NuGetScratch\5ca315c2fce443828b6b899dc64a2816\59b2922a08ac400c8837381e2d578067.proj.
                   Restoring packages for C:\Users\buildserver\AppData\Local\Temp\2\NuGetScratch\5ca315c2fce443828b6b899dc64a2816\59b2922a08ac400c8837381e2d578067.proj...
                   Restoring packages for .NETStandard,Version=v0.0...
                     GET https://api.nuget.org/v3-flatcontainer/MySdkPackage/index.json
                     NotFound https://api.nuget.org/v3-flatcontainer/MySdkPackage/index.json 616ms
nkolev92 commented 3 years ago

Dup of https://github.com/NuGet/Home/issues/7855.

There's a slight chicken or egg problem here.

In the mean time please consider specifying it in a config file in the root repo instead.