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

Generate solution-level nuget.config with cleared Package Sources sections #13173

Open
donnie-msft opened this issue Jan 20, 2024 · 0 comments
Open
Assignees
Labels
Area:Settings NuGet.Config and related issues Category:Quality Week Issues that should be considered for quality week Functionality:VSOptions Priority:2 Issues for the current backlog. Product:dotnet.exe Product:VS.Client Triage:NeedsDesignSpec Type:DCR Design Change Request

Comments

@donnie-msft
Copy link
Contributor

NuGet Product(s) Affected

Visual Studio Package Management UI, dotnet.exe

Current Behavior

When using NuGet Tooling to add a NuGet setting, NuGet.Configuration.dll will walk up the tree of nuget.config files until it finds a matching section. Even if a solution-level config file exists, it will not write Package Sources sections to it.

If a solution-level config exists with <packageSources> and the customer disables one of those sources using Visual Studio Options, the <disabledPackageSources> node will be created in the machine-wide config.
However, if <disabledPackageSources><clear/></disabledPackageSources> exists in the solution-wide config then that section will be updated as expected.

https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#package-source-sections

Desired Behavior

Since customers are encouraged to follow this suggested best-practice anyway, I believe tooling should guide them by generating a solution nuget.config implementing those practices, unless the customer expresses otherwise.

To steer customers towards solution-level configs, the following workflow is suggested for NuGet Tooling (eg, VS Options or dotnet new nugetconfig) when that tooling attempts to write to a Package Sources sections.

VS Options

When modifying any of the package sources sections, check the package source sections using the following workflow.

  1. Solution config exists? If not, create one.
  2. The node being modified exists (in solution config)? If not, create one with <clear/>.
  3. The node being modified exists (in solution config) but is missing a clear? Add a <clear/>.
  4. Repeat 2-3 for all package sources sections.
  5. Write the actual change to the section.

Prompt the customer if steps 1-4 find a missing ideal configuration. If the customer agrees, NuGet tooling completes steps 1-3 in the solution config for the customer.

Otherwise, continue to step 5.

dotnet new nugetconfig

Customers using the nuget.config template without parameters will continue getting only the <packageSource> node from the package sources sections by default. Provide CLI options for appending the remaining package sources sections.

Primarily, these options should be available:
--add-package-source-mapping
--add-disabled-sources

Secondarily, these options could be available:
--add-package-source-credentials
--add-api-keys
--add-active-package-source
--add-trusted-signers

Potentially useful as well may be --no-clear in case customers intend to create a merged configuration.

Additional Context

Feature suggestion of a dotnet CLI config command: #9571
Suggestion to stop creating default configs and/or prompt customers to use the dotnet new nugetconfig: #13027

@donnie-msft donnie-msft self-assigned this Feb 5, 2024
@donnie-msft donnie-msft added the Category:Quality Week Issues that should be considered for quality week label Feb 7, 2024
@nkolev92 nkolev92 added the Priority:2 Issues for the current backlog. label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:Settings NuGet.Config and related issues Category:Quality Week Issues that should be considered for quality week Functionality:VSOptions Priority:2 Issues for the current backlog. Product:dotnet.exe Product:VS.Client Triage:NeedsDesignSpec Type:DCR Design Change Request
Projects
None yet
Development

No branches or pull requests

2 participants