Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support sourceUri passed on nuget restore/install and dotnet restore package or other equivalent commands #10948

Closed
erdembayar opened this issue Jun 16, 2021 · 10 comments · Fixed by NuGet/NuGet.Client#4214
Assignees
Labels
Area:PackageSourceMapping Issues related to the package source mapping feature Priority:2 Issues for the current backlog. Type:Bug

Comments

@erdembayar
Copy link
Contributor

erdembayar commented Jun 16, 2021

Details about Problem

NuGet product used (NuGet.exe | Visual Studio | MSBuild.exe | dotnet.exe):

Product version: N/A

Worked before? If so, with which NuGet version:

Repro steps and/or sample project

Address Karteek's comment about there are chances that users might pass -source option to the restore command.
To support this we may need small changes SearchTree, PackageDownloader.cs and PackageNamespacesConfiguration.cs
files.

Verbose Logs

@erdembayar
Copy link
Contributor Author

@aortiz-msft @nkolev92
It looks, I started working on this issue too early. I created new unit tests but I better to work on this after I complete #10738

@nkolev92
Copy link
Member

@erdembayar

Are you planning to validate both packages.config and PackageReference with this one?

cc @kartheekp-ms

@erdembayar
Copy link
Contributor Author

@nkolev92
Packages.config is yes, not sure about PackageReference, but I'll try to validate both.

@nkolev92
Copy link
Member

I see dotnet add package is in the name, but that only handles PR.

I'll let you and @kartheekp-ms decide, but consider splitting up the work in 2 issues.

@nkolev92
Copy link
Member

nkolev92 commented Jul 16, 2021

For complete here are the scenarios of interest PC & PR.

  • nuget.exe restore -source
  • dotnet.exe restore -source
  • RestoreSources in csproj for PackageReference
  • nuget.exe install -source
  • dotnet add package -source
  • PMC install-package -source
  • PMC update-package -source

Note that the last 2 are not relevant in PackageReference. There's a warning message when you try that.

@erdembayar
Copy link
Contributor Author

@nkolev92
Could you be able to give more context on RestoreSources in csproj for PackageReference? How does it work?

@nkolev92
Copy link
Member

You can do the following and it overrides the package sources specified in the nuget config.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <RestoreSources>https://api.nuget.org/v3/index.json</RestoreSources>
  </PropertyGroup>
  
  <ItemGroup>
    <PackageReference Include="nuget.common" Version="4.9.1"/>
  </ItemGroup>

</Project>

@erdembayar
Copy link
Contributor Author

@nkolev92 @kartheekp-ms
I noticed there's another option p:RestoreAdditionalProjectSources besides p:RestoreSources.
Do we need to take into account?

@nkolev92
Copy link
Member

nkolev92 commented Aug 2, 2021

@erdembayar

Yes, but I'd expect they'd be automatically handled.
RestoreSources, RestoreAdditionalProjectSources are all merged early on.
If your tests work with RestoreSources, I'd expect them to work with RestoreAdditionalProjectSources as well.

@erdembayar erdembayar changed the title Support sourceUri passed on restore and dotnet add package or other equivalent commands Support sourceUri passed on nuget restore/install and dotnet restore package or other equivalent commands Aug 7, 2021
@erdembayar
Copy link
Contributor Author

I created follow up issue for dotnet add package --source scenario #11140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment