From e8fdc34ac26ee74b8bb58acbd90874942509e2c6 Mon Sep 17 00:00:00 2001 From: Heng Liu <liu.heng@microsoft.com> Date: Tue, 18 Oct 2022 21:35:40 -0700 Subject: [PATCH 01/30] work --- proposed/2022/dotnet-nuget-config-spec.md | 58 +++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 proposed/2022/dotnet-nuget-config-spec.md diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md new file mode 100644 index 0000000000..770826731e --- /dev/null +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -0,0 +1,58 @@ +# dotnet nuget config command + +- Author: [Heng Liu](https://github.com/heng-liu) +- GitHub Issue [8420](https://github.com/NuGet/Home/issues/8420) + +## Problem Background + +Currently, there is no command for NuGet users to know about the NuGet configuration file locations. This is inconvienient for both NuGet users and NuGet team. When NuGet users want to figure out where is the merged configuration coming from, or when NuGet team tries to diagnose issues but needs all the configuration files, this command will be helpful. + +## Who are the customers + +This feature is for dotnet.exe users. + +## Goals +Design and implement `dotnet nuget config list` commands. + +## Non-Goals +Design and implement other `dotnet nuget config` commands. E.g. add/update/delete + +## Solution +The following command will be implemented in the `dotnet.exe` CLI. + +### `dotnet nuget config` + +#### Commands +If no command is specified, the command will default to list. + +- List + +Lists all the NuGet configuration file locations. This command will include all the NuGet configuration file that will be applied, when invoking NuGet command from the current working directory path. The listed NuGet configuration files are in priority order. So the order of loading those configurations is reversed, that is, loading order is from the bottom to the top. So the configuration on the top will apply. +You may refer to [How settings are applied](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#how-settings-are-applied) for more details. + +#### Options +- -?|-h|--help + +Prints out a description of how to use the command. + +#### Examples + +- List all the NuGet configuration file that will be applied. + +``` +dotnet nuget config list + +c:\repos\Solution\Project\NuGet.Config +c:\repos\Solution\NuGet.Config +C:\Users\username\AppData\Roaming\NuGet\NuGet.Config +C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config +C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config +``` + +### Future Work +The `dotnet nuget config list` is a community ask. We will consider adding more commands, like add/update/delete, in the future. + +## Open Questions +1. Shall we add `working directory` as an option? So that people could check different NuGet configuration lists without changing current directory. +2. Do we need to add this into NuGet.exe CLI? + From 006cb0f3de85fdf03b135a8a523b286b940d7e1c Mon Sep 17 00:00:00 2001 From: Heng Liu <liu.heng@microsoft.com> Date: Wed, 19 Oct 2022 09:59:54 -0700 Subject: [PATCH 02/30] fix --- proposed/2022/dotnet-nuget-config-spec.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index 770826731e..da94962dfb 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -1,21 +1,21 @@ -# dotnet nuget config command +# NuGet configuration CLI for dotnet.exe - Author: [Heng Liu](https://github.com/heng-liu) - GitHub Issue [8420](https://github.com/NuGet/Home/issues/8420) ## Problem Background -Currently, there is no command for NuGet users to know about the NuGet configuration file locations. This is inconvienient for both NuGet users and NuGet team. When NuGet users want to figure out where is the merged configuration coming from, or when NuGet team tries to diagnose issues but needs all the configuration files, this command will be helpful. +Currently, there is no NuGet configuration CLI for dotnet.exe. It's inconvenient for NuGet users to know about the NuGet configuration file locations and figure out where is the merged configuration coming from. ## Who are the customers This feature is for dotnet.exe users. ## Goals -Design and implement `dotnet nuget config list` commands. +Design and implement `dotnet nuget config` command. ## Non-Goals -Design and implement other `dotnet nuget config` commands. E.g. add/update/delete +Design and implement `dotnet nuget config` command with commands other than `list`, E.g. add/update/delete ## Solution The following command will be implemented in the `dotnet.exe` CLI. @@ -49,10 +49,13 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.conf C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config ``` -### Future Work +## Future Work The `dotnet nuget config list` is a community ask. We will consider adding more commands, like add/update/delete, in the future. ## Open Questions 1. Shall we add `working directory` as an option? So that people could check different NuGet configuration lists without changing current directory. 2. Do we need to add this into NuGet.exe CLI? +## Considerations +1. NuGet.exe [config command](https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-config) is implemented. But there is no `list` command. And the behavior is confusing (the `set` command will set the property which appears last when loading, so sometimes it's not updating the closest NuGet configuration file). Do we want to implement those subcommand(e.g.`set`) in the future in dotnet.exe differently? + From 335e6ae28bf180abd131d12056d45e79b4f97f11 Mon Sep 17 00:00:00 2001 From: Heng Liu <liu.heng@microsoft.com> Date: Wed, 19 Oct 2022 14:59:01 -0700 Subject: [PATCH 03/30] address feedback --- proposed/2022/dotnet-nuget-config-spec.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index da94962dfb..98d92b63b2 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -35,9 +35,12 @@ You may refer to [How settings are applied](https://learn.microsoft.com/en-us/nu Prints out a description of how to use the command. +- --current-directory +Run this command as if current directory is set to the specified directory. + #### Examples -- List all the NuGet configuration file that will be applied. +- List all the NuGet configuration file that will be applied, when invoking NuGet command in the current directory. ``` dotnet nuget config list @@ -49,12 +52,21 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.conf C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config ``` +- List all the NuGet configuration file that will be applied, when invoking NuGet command in the specific directory. +``` +dotnet nuget config list --current-directory c:\repos\Solution + +c:\repos\Solution\NuGet.Config +C:\Users\username\AppData\Roaming\NuGet\NuGet.Config +C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config +C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config +``` + ## Future Work The `dotnet nuget config list` is a community ask. We will consider adding more commands, like add/update/delete, in the future. ## Open Questions -1. Shall we add `working directory` as an option? So that people could check different NuGet configuration lists without changing current directory. -2. Do we need to add this into NuGet.exe CLI? +1. Do we need to add this into NuGet.exe CLI? ## Considerations 1. NuGet.exe [config command](https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-config) is implemented. But there is no `list` command. And the behavior is confusing (the `set` command will set the property which appears last when loading, so sometimes it's not updating the closest NuGet configuration file). Do we want to implement those subcommand(e.g.`set`) in the future in dotnet.exe differently? From 204ba1a52f7a1897d616a4f7acd1bc9b1a683578 Mon Sep 17 00:00:00 2001 From: Heng Liu <liu.heng@microsoft.com> Date: Wed, 19 Oct 2022 15:01:19 -0700 Subject: [PATCH 04/30] fix --- proposed/2022/dotnet-nuget-config-spec.md | 1 + 1 file changed, 1 insertion(+) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index 98d92b63b2..2b8cd72864 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -36,6 +36,7 @@ You may refer to [How settings are applied](https://learn.microsoft.com/en-us/nu Prints out a description of how to use the command. - --current-directory + Run this command as if current directory is set to the specified directory. #### Examples From 5dff9f6795d306360f49f0d8e57d833f96561a8e Mon Sep 17 00:00:00 2001 From: Heng Liu <liu.heng@microsoft.com> Date: Fri, 21 Oct 2022 15:50:31 -0700 Subject: [PATCH 05/30] address feedback --- proposed/2022/dotnet-nuget-config-spec.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index 2b8cd72864..e9a7864437 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -30,15 +30,16 @@ If no command is specified, the command will default to list. Lists all the NuGet configuration file locations. This command will include all the NuGet configuration file that will be applied, when invoking NuGet command from the current working directory path. The listed NuGet configuration files are in priority order. So the order of loading those configurations is reversed, that is, loading order is from the bottom to the top. So the configuration on the top will apply. You may refer to [How settings are applied](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#how-settings-are-applied) for more details. +#### Arguments +- CURRENT_DIRECTORY + +Run this command as if current directory is set to the specified directory. + #### Options - -?|-h|--help Prints out a description of how to use the command. -- --current-directory - -Run this command as if current directory is set to the specified directory. - #### Examples - List all the NuGet configuration file that will be applied, when invoking NuGet command in the current directory. @@ -46,18 +47,21 @@ Run this command as if current directory is set to the specified directory. ``` dotnet nuget config list -c:\repos\Solution\Project\NuGet.Config -c:\repos\Solution\NuGet.Config +C:\Test\Repos\Solution\NuGet.Config +C:\Test\Repos\NuGet.Config +C:\Test\NuGet.Config C:\Users\username\AppData\Roaming\NuGet\NuGet.Config C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config ``` - List all the NuGet configuration file that will be applied, when invoking NuGet command in the specific directory. + ``` -dotnet nuget config list --current-directory c:\repos\Solution +dotnet nuget config list C:\Test\Repos -c:\repos\Solution\NuGet.Config +C:\Test\Repos\NuGet.Config +C:\Test\NuGet.Config C:\Users\username\AppData\Roaming\NuGet\NuGet.Config C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config From abc436dd1a919a8aadc7b923e8bbcbffdf8159fe Mon Sep 17 00:00:00 2001 From: Heng Liu <liu.heng@microsoft.com> Date: Mon, 24 Oct 2022 11:11:18 -0700 Subject: [PATCH 06/30] address feedback --- proposed/2022/dotnet-nuget-config-spec.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index e9a7864437..202fc0e7ef 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -23,7 +23,6 @@ The following command will be implemented in the `dotnet.exe` CLI. ### `dotnet nuget config` #### Commands -If no command is specified, the command will default to list. - List @@ -31,11 +30,13 @@ Lists all the NuGet configuration file locations. This command will include all You may refer to [How settings are applied](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#how-settings-are-applied) for more details. #### Arguments + - CURRENT_DIRECTORY Run this command as if current directory is set to the specified directory. #### Options + - -?|-h|--help Prints out a description of how to use the command. From ffd5e7147450d95710f6b0dcf581460d37d5b554 Mon Sep 17 00:00:00 2001 From: Heng Liu <liu.heng@microsoft.com> Date: Wed, 26 Oct 2022 11:58:29 -0700 Subject: [PATCH 07/30] address comments --- proposed/2022/dotnet-nuget-config-spec.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index 202fc0e7ef..dc640711c4 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -69,11 +69,16 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config ``` ## Future Work -The `dotnet nuget config list` is a community ask. We will consider adding more commands, like add/update/delete, in the future. +1. The `dotnet nuget config list` is a community ask. We will consider adding more commands, like add/update/delete, in the future. +2. We will discuss if adding this command into NuGet.exe CLI, in the future. +3. NuGet.exe [config command](https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-config) is implemented. But there is no `list` command. And the behavior is confusing (the `set` command will set the property which appears last when loading, so sometimes it's not updating the closest NuGet configuration file). Do we want to implement those subcommand(e.g.`set`) in the future in dotnet.exe differently? ## Open Questions -1. Do we need to add this into NuGet.exe CLI? +1. When the specified `CURRENT_DIRECTORY` doesn't exist, shall we list user-wide and machine-wide config files? Or show a warning saying the working directory doesn't exist? Or do both? + +I prefer do just a warning, or do both. +When user has a spelling mistake when passing `CURRENT_DIRECTORY` without knowing, if we don't show a warning, that would mislead the user. +Showing them user-wide and machine-wide config files could provide extra info and may help them to understand the example of a right path. But since this is not a real scenario (It's impossible that a real `CURRENT_DIRECTORY` doesn't exist), this adds very limited value. ## Considerations -1. NuGet.exe [config command](https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-config) is implemented. But there is no `list` command. And the behavior is confusing (the `set` command will set the property which appears last when loading, so sometimes it's not updating the closest NuGet configuration file). Do we want to implement those subcommand(e.g.`set`) in the future in dotnet.exe differently? From a25ea5d607fb176e6db8ba5833fe99ab98391136 Mon Sep 17 00:00:00 2001 From: Heng Liu <liu.heng@microsoft.com> Date: Thu, 27 Oct 2022 16:53:57 -0700 Subject: [PATCH 08/30] address feedback --- proposed/2022/dotnet-nuget-config-spec.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index dc640711c4..6add173269 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -76,9 +76,9 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config ## Open Questions 1. When the specified `CURRENT_DIRECTORY` doesn't exist, shall we list user-wide and machine-wide config files? Or show a warning saying the working directory doesn't exist? Or do both? -I prefer do just a warning, or do both. -When user has a spelling mistake when passing `CURRENT_DIRECTORY` without knowing, if we don't show a warning, that would mislead the user. -Showing them user-wide and machine-wide config files could provide extra info and may help them to understand the example of a right path. But since this is not a real scenario (It's impossible that a real `CURRENT_DIRECTORY` doesn't exist), this adds very limited value. +We decided to show a warning/error. +When user has a spelling mistake when passing `CURRENT_DIRECTORY` without knowing, if we don't show a warning/error, that would mislead the user. +Showing them user-wide and machine-wide config files doesn't help. ## Considerations From 9da2a9f6d7ad041f685586b3bafcfed5b089afdf Mon Sep 17 00:00:00 2001 From: Heng Liu <liu.heng@microsoft.com> Date: Fri, 28 Oct 2022 12:59:27 -0700 Subject: [PATCH 09/30] address comments & add more examples --- proposed/2022/dotnet-nuget-config-spec.md | 43 ++++++++++++++++++----- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index 6add173269..f1ef702b61 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -15,7 +15,7 @@ This feature is for dotnet.exe users. Design and implement `dotnet nuget config` command. ## Non-Goals -Design and implement `dotnet nuget config` command with commands other than `list`, E.g. add/update/delete +Design and implement `dotnet nuget config` command with commands other than `list`, e.g. add/update/delete ## Solution The following command will be implemented in the `dotnet.exe` CLI. @@ -26,14 +26,21 @@ The following command will be implemented in the `dotnet.exe` CLI. - List -Lists all the NuGet configuration file locations. This command will include all the NuGet configuration file that will be applied, when invoking NuGet command from the current working directory path. The listed NuGet configuration files are in priority order. So the order of loading those configurations is reversed, that is, loading order is from the bottom to the top. So the configuration on the top will apply. +Lists all the NuGet configuration file locations. + +This command will include all the NuGet configuration file that will be applied, when invoking NuGet command from the current working directory path. The listed NuGet configuration files are in priority order. So the order of loading those configurations is reversed, that is, loading order is from the bottom to the top. So the configuration on the top will apply. You may refer to [How settings are applied](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#how-settings-are-applied) for more details. #### Arguments -- CURRENT_DIRECTORY +- WORKING_DIRECTORY + +Run this command as if working directory is set to the specified directory. + +If the specified `WORKING_DIRECTORY` doesn't exist, an error is displayed indicating the `WORKING_DIRECTORY` doesn't exist. -Run this command as if current directory is set to the specified directory. +> [!Note] +> If `WORKING_DIRECTORY` (or its parent directories) is not accessible, the command will ignore any NuGet configuration files under those directories without any warning/error. This is aligned with other NuGet commands. #### Options @@ -68,17 +75,35 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.conf C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config ``` +- List all the NuGet configuration file that will be applied, but passing a non-exsiting `WORKING_DIRECTORY`. + +``` +dotnet nuget config list C:\Test\NonExistingRepos + +Error: The path "C:\Test\NonExistingRepos" doesn't exist. +``` + +- List all the NuGet configuration file that will be applied, but passing an inaccessible `WORKING_DIRECTORY`: C:\Test\AccessibleRepos\NotAccessibleSolution. + +The configuration file under C:\Test\AccessibleRepos\NotAccessibleSolution\NuGet.Config will be ignored without any warning or error. + +``` +dotnet nuget config list C:\Test\AccessibleRepos\NotAccessibleSolution + +C:\Test\AccessibleRepos\NuGet.Config +C:\Test\NuGet.Config +C:\Users\username\AppData\Roaming\NuGet\NuGet.Config +C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config +C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config +``` + + ## Future Work 1. The `dotnet nuget config list` is a community ask. We will consider adding more commands, like add/update/delete, in the future. 2. We will discuss if adding this command into NuGet.exe CLI, in the future. 3. NuGet.exe [config command](https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-config) is implemented. But there is no `list` command. And the behavior is confusing (the `set` command will set the property which appears last when loading, so sometimes it's not updating the closest NuGet configuration file). Do we want to implement those subcommand(e.g.`set`) in the future in dotnet.exe differently? ## Open Questions -1. When the specified `CURRENT_DIRECTORY` doesn't exist, shall we list user-wide and machine-wide config files? Or show a warning saying the working directory doesn't exist? Or do both? - -We decided to show a warning/error. -When user has a spelling mistake when passing `CURRENT_DIRECTORY` without knowing, if we don't show a warning/error, that would mislead the user. -Showing them user-wide and machine-wide config files doesn't help. ## Considerations From a1f68cff6ca6ce499c0b5ecfbbb37293d8d4a327 Mon Sep 17 00:00:00 2001 From: Heng Liu <liu.heng@microsoft.com> Date: Mon, 14 Nov 2022 12:28:48 -0800 Subject: [PATCH 10/30] add verbosity detailed --- proposed/2022/dotnet-nuget-config-spec.md | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index f1ef702b61..e41ab2b691 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -43,6 +43,10 @@ If the specified `WORKING_DIRECTORY` doesn't exist, an error is displayed indica > If `WORKING_DIRECTORY` (or its parent directories) is not accessible, the command will ignore any NuGet configuration files under those directories without any warning/error. This is aligned with other NuGet commands. #### Options +- -v|--verbosity <LEVEL> + +Sets the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. The default is minimal. +When the verbosity level is detailed or diagnostic, the command will display the merged NuGet configuration. - -?|-h|--help @@ -75,6 +79,39 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.conf C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config ``` +- List all the NuGet configuration file that will be applied, and show the merged NuGet configuration, when invoking NuGet command in the specific directory. + +``` +dotnet nuget config list C:\Test\Repos -v d + +C:\Test\Repos\NuGet.Config +C:\Test\NuGet.Config +C:\Users\username\AppData\Roaming\NuGet\NuGet.Config +C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config +C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config + +The merged NuGet configuration: +<configuration> + <packageSources> + <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> + <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" /> + <add key="Test Package source" value="C:\work" /> + </packageSources> + <packageRestore> + <add key="enabled" value="False" /> + <add key="automatic" value="False" /> + </packageRestore> + <bindingRedirects> + <add key="skip" value="False" /> + </bindingRedirects> + <packageManagement> + <add key="format" value="0" /> + <add key="disabled" value="False" /> + </packageManagement> +</configuration> + +``` + - List all the NuGet configuration file that will be applied, but passing a non-exsiting `WORKING_DIRECTORY`. ``` From 3fe2fe33ca6aed6f422a3dc13240c6d532db10df Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Tue, 15 Nov 2022 10:10:23 -0800 Subject: [PATCH 11/30] address feedback, list merged settings by default --- proposed/2022/dotnet-nuget-config-spec.md | 83 ++++++++++++++++++----- 1 file changed, 67 insertions(+), 16 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index e41ab2b691..81a6c6b10d 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -26,10 +26,9 @@ The following command will be implemented in the `dotnet.exe` CLI. - List -Lists all the NuGet configuration file locations. +Lists all the NuGet configuration settings. -This command will include all the NuGet configuration file that will be applied, when invoking NuGet command from the current working directory path. The listed NuGet configuration files are in priority order. So the order of loading those configurations is reversed, that is, loading order is from the bottom to the top. So the configuration on the top will apply. -You may refer to [How settings are applied](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#how-settings-are-applied) for more details. +This command will list merged NuGet configuration settings from one or multiple NuGet configuration files that will be applied, when invoking NuGet command from the current working directory path. #### Arguments @@ -46,7 +45,10 @@ If the specified `WORKING_DIRECTORY` doesn't exist, an error is displayed indica - -v|--verbosity <LEVEL> Sets the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. The default is minimal. -When the verbosity level is detailed or diagnostic, the command will display the merged NuGet configuration. +When the verbosity level is detailed or diagnostic, the command will display all the NuGet configuration file that will be applied, when invoking NuGet command from the current working directory path. + +The listed NuGet configuration files are in priority order. So the order of loading those configurations is reversed, that is, loading order is from the bottom to the top. So the configuration on the top will apply. +You may refer to [How settings are applied](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#how-settings-are-applied) for more details. - -?|-h|--help @@ -57,7 +59,25 @@ Prints out a description of how to use the command. - List all the NuGet configuration file that will be applied, when invoking NuGet command in the current directory. ``` -dotnet nuget config list +dotnet nuget config list --verbosity detailed + +<configuration> + <packageSources> + <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> + <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" /> + </packageSources> + <packageRestore> + <add key="enabled" value="False" /> + <add key="automatic" value="False" /> + </packageRestore> + <bindingRedirects> + <add key="skip" value="False" /> + </bindingRedirects> + <packageManagement> + <add key="format" value="0" /> + <add key="disabled" value="False" /> + </packageManagement> +</configuration> C:\Test\Repos\Solution\NuGet.Config C:\Test\Repos\NuGet.Config @@ -70,7 +90,26 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config - List all the NuGet configuration file that will be applied, when invoking NuGet command in the specific directory. ``` -dotnet nuget config list C:\Test\Repos +dotnet nuget config list C:\Test\Repos --verbosity detailed + +<configuration> + <packageSources> + <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> + <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" /> + <add key="Test Package source" value="C:\work" /> + </packageSources> + <packageRestore> + <add key="enabled" value="False" /> + <add key="automatic" value="False" /> + </packageRestore> + <bindingRedirects> + <add key="skip" value="False" /> + </bindingRedirects> + <packageManagement> + <add key="format" value="0" /> + <add key="disabled" value="False" /> + </packageManagement> +</configuration> C:\Test\Repos\NuGet.Config C:\Test\NuGet.Config @@ -79,18 +118,11 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.conf C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config ``` -- List all the NuGet configuration file that will be applied, and show the merged NuGet configuration, when invoking NuGet command in the specific directory. +- List only the NuGet configuration settings, when invoking NuGet command in the specific directory. ``` -dotnet nuget config list C:\Test\Repos -v d - -C:\Test\Repos\NuGet.Config -C:\Test\NuGet.Config -C:\Users\username\AppData\Roaming\NuGet\NuGet.Config -C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config -C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config +dotnet nuget config list C:\Test\Repos -The merged NuGet configuration: <configuration> <packageSources> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> @@ -125,7 +157,26 @@ Error: The path "C:\Test\NonExistingRepos" doesn't exist. The configuration file under C:\Test\AccessibleRepos\NotAccessibleSolution\NuGet.Config will be ignored without any warning or error. ``` -dotnet nuget config list C:\Test\AccessibleRepos\NotAccessibleSolution +dotnet nuget config list C:\Test\AccessibleRepos\NotAccessibleSolution -v d + +<configuration> + <packageSources> + <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> + <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" /> + <add key="Test Package source" value="C:\work" /> + </packageSources> + <packageRestore> + <add key="enabled" value="False" /> + <add key="automatic" value="False" /> + </packageRestore> + <bindingRedirects> + <add key="skip" value="False" /> + </bindingRedirects> + <packageManagement> + <add key="format" value="0" /> + <add key="disabled" value="False" /> + </packageManagement> +</configuration> C:\Test\AccessibleRepos\NuGet.Config C:\Test\NuGet.Config From 1bcd070708e2bc2f39c17679d5091be4e41a3230 Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Tue, 15 Nov 2022 11:08:52 -0800 Subject: [PATCH 12/30] add set and unset --- proposed/2022/dotnet-nuget-config-spec.md | 94 +++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index 81a6c6b10d..a7ec4e697a 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -186,12 +186,106 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config ``` +- Set + +Set the NuGet configuration settings. + +This command will set the value of a specified NuGet configuration setting. + +Please note this command only manages settings in [config section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#config-section). +For other settings not in config section, we have/will have other commands. E.g. for [trustedSigners section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#trustedsigners-section), we have [dotnet nuget trust](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-trust) command. + +#### Arguments + +- SETTING_KEY + +Specify the key of the settings that are to be set. + +If the specified `SETTING_KEY` is not a key in [config section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#config-section), an error is displayed indicating the `SETTING_KEY` could not be set. + +- SETTING_VALUE + +Set the value of the SETTING_KEY to SETTING_VALUE. + +#### Options +- --config-file + +Specify the config file path to add the setting key-value pair. If it's not specified, the config file with highest priority will be updated. + +- -?|-h|--help + +Prints out a description of how to use the command. + +#### Examples + +- Set the `signatureValidationMode` to true in the closest NuGet configuration file. + +``` +dotnet nuget config set signatureValidationMode require + +``` + +- Set the `defaultPushSource` in the specified NuGet configuration file. + +``` +dotnet nuget config set defaultPushSource https://MyRepo/ES/api/v2/package --config-file C:\Users\username\AppData\Roaming\NuGet\NuGet.Config + +``` + +- Unset + +Remove the NuGet configuration settings. + +This command will remove the key-value pair from a specified NuGet configuration setting. + +Please note this command only manages settings in [config section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#config-section). +For other settings not in config section, we have/will have other commands. E.g. for [trustedSigners section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#trustedsigners-section), we have [dotnet nuget trust](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-trust) command. + +#### Arguments + +- SETTING_KEY + +Specify the key of the settings that are to be removed. + +If the specified `SETTING_KEY` is not a key in [config section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#config-section), an error is displayed indicating the `SETTING_KEY` could not be set. + + +#### Options + +- --config-file + +Specify the config file path to remove the setting key-value pair. If it's not specified, the config file with highest priority will be updated. + +- -?|-h|--help + +Prints out a description of how to use the command. + +#### Examples + +- Unset the `signatureValidationMode` in the closest NuGet configuration file. + +``` +dotnet nuget config unset signatureValidationMode + +``` + +- Unset the `defaultPushSource` in the specified NuGet configuration file. + +``` +dotnet nuget config unset defaultPushSource --config-file C:\Users\username\AppData\Roaming\NuGet\NuGet.Config + +``` + ## Future Work 1. The `dotnet nuget config list` is a community ask. We will consider adding more commands, like add/update/delete, in the future. 2. We will discuss if adding this command into NuGet.exe CLI, in the future. 3. NuGet.exe [config command](https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-config) is implemented. But there is no `list` command. And the behavior is confusing (the `set` command will set the property which appears last when loading, so sometimes it's not updating the closest NuGet configuration file). Do we want to implement those subcommand(e.g.`set`) in the future in dotnet.exe differently? ## Open Questions +1. What are the recommended verbs in dotnet command when setting and unsetting values? ('set' and 'unset' work or not?) +2. `Get` is not mentioned in this doc. It may cause some confusions: + Should `get` work for settings not in config section? (It's workable, but then we will miss `set` and `unset` for those as those are not doable) + Should `get` get the settings from a specific config file(like `set` and `unset`), or get the merged settings from multiple config files? ## Considerations From c261b0b7e9bed578e60dc45a323f2bb718aaa87a Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Tue, 15 Nov 2022 12:14:17 -0800 Subject: [PATCH 13/30] fix and add a question --- proposed/2022/dotnet-nuget-config-spec.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index a7ec4e697a..49efc152cf 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -185,6 +185,7 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.conf C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config ``` +#### Commands - Set @@ -282,8 +283,9 @@ dotnet nuget config unset defaultPushSource --config-file C:\Users\username\AppD 3. NuGet.exe [config command](https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-config) is implemented. But there is no `list` command. And the behavior is confusing (the `set` command will set the property which appears last when loading, so sometimes it's not updating the closest NuGet configuration file). Do we want to implement those subcommand(e.g.`set`) in the future in dotnet.exe differently? ## Open Questions -1. What are the recommended verbs in dotnet command when setting and unsetting values? ('set' and 'unset' work or not?) -2. `Get` is not mentioned in this doc. It may cause some confusions: +1. To show configuration files locations, is it better to use `--verbosity` option or some option named like `--show-path`? (git command is using `--show-origin` for similar purpose) +2. What are the recommended verbs in dotnet command when setting and unsetting values? ('set' and 'unset' work or not?) +3. `Get` is not mentioned in this doc. It may cause some confusions: Should `get` work for settings not in config section? (It's workable, but then we will miss `set` and `unset` for those as those are not doable) Should `get` get the settings from a specific config file(like `set` and `unset`), or get the merged settings from multiple config files? From 54133da3437371a3a15b31c3eecd5a5bc962a8ee Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Tue, 15 Nov 2022 12:20:24 -0800 Subject: [PATCH 14/30] add consideration --- proposed/2022/dotnet-nuget-config-spec.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index 49efc152cf..ae0945e6d5 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -290,4 +290,11 @@ dotnet nuget config unset defaultPushSource --config-file C:\Users\username\AppD Should `get` get the settings from a specific config file(like `set` and `unset`), or get the merged settings from multiple config files? ## Considerations - +1. Will this command help with diagnosing incorrect setting format? +No. Incorrect NuGet settings should have seperate error/warning message to tell the customer what's wrong in the setting file. If we have incorrect NuGet settings, all NuGet command, including `dotnet nuget config` command, should display the same error/warning message. +E.g. if we have an invalid XML problem in one of the NuGet configuration file, running all NuGet command will get an error as following: +``` +dotnet nuget list source +error: NuGet.Config is not valid XML. Path: 'C:\Users\username\Source\Repos\NuGet.Config'. +error: The 'disabledPackageSources' start tag on line 19 position 4 does not match the end tag of 'configuration'. Line 20, position 3. +``` \ No newline at end of file From 91e47c07b6d587a10992d1ed3d87259fd0707b6c Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Tue, 15 Nov 2022 12:24:38 -0800 Subject: [PATCH 15/30] fix format --- proposed/2022/dotnet-nuget-config-spec.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index ae0945e6d5..22d73ae5a5 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -291,10 +291,8 @@ dotnet nuget config unset defaultPushSource --config-file C:\Users\username\AppD ## Considerations 1. Will this command help with diagnosing incorrect setting format? -No. Incorrect NuGet settings should have seperate error/warning message to tell the customer what's wrong in the setting file. If we have incorrect NuGet settings, all NuGet command, including `dotnet nuget config` command, should display the same error/warning message. -E.g. if we have an invalid XML problem in one of the NuGet configuration file, running all NuGet command will get an error as following: -``` +<br />No. Incorrect NuGet settings should have seperate error/warning message to tell the customer what's wrong in the setting file. If we have incorrect NuGet settings, all NuGet command, including `dotnet nuget config` command, should display the same error/warning message. +<br />E.g. if we have an invalid XML problem in one of the NuGet configuration file, running all NuGet command will get an error as following: dotnet nuget list source error: NuGet.Config is not valid XML. Path: 'C:\Users\username\Source\Repos\NuGet.Config'. error: The 'disabledPackageSources' start tag on line 19 position 4 does not match the end tag of 'configuration'. Line 20, position 3. -``` \ No newline at end of file From a64746c1039b1d220c453490376d6a862b62ad58 Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Wed, 16 Nov 2022 13:54:57 -0800 Subject: [PATCH 16/30] work --- proposed/2022/dotnet-nuget-config-spec.md | 142 +++++++--------------- 1 file changed, 45 insertions(+), 97 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index 22d73ae5a5..830b9a2d1f 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -24,11 +24,12 @@ The following command will be implemented in the `dotnet.exe` CLI. #### Commands -- List +- Path -Lists all the NuGet configuration settings. +List all the paths of NuGet configuration files that will be applied, when invoking NuGet command from the current working directory path. -This command will list merged NuGet configuration settings from one or multiple NuGet configuration files that will be applied, when invoking NuGet command from the current working directory path. +The listed NuGet configuration files are in priority order. So the order of loading those configurations is reversed, that is, loading order is from the bottom to the top. So the configuration on the top will apply. +You may refer to [How settings are applied](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#how-settings-are-applied) for more details. #### Arguments @@ -42,13 +43,6 @@ If the specified `WORKING_DIRECTORY` doesn't exist, an error is displayed indica > If `WORKING_DIRECTORY` (or its parent directories) is not accessible, the command will ignore any NuGet configuration files under those directories without any warning/error. This is aligned with other NuGet commands. #### Options -- -v|--verbosity <LEVEL> - -Sets the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. The default is minimal. -When the verbosity level is detailed or diagnostic, the command will display all the NuGet configuration file that will be applied, when invoking NuGet command from the current working directory path. - -The listed NuGet configuration files are in priority order. So the order of loading those configurations is reversed, that is, loading order is from the bottom to the top. So the configuration on the top will apply. -You may refer to [How settings are applied](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#how-settings-are-applied) for more details. - -?|-h|--help @@ -59,25 +53,7 @@ Prints out a description of how to use the command. - List all the NuGet configuration file that will be applied, when invoking NuGet command in the current directory. ``` -dotnet nuget config list --verbosity detailed - -<configuration> - <packageSources> - <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> - <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" /> - </packageSources> - <packageRestore> - <add key="enabled" value="False" /> - <add key="automatic" value="False" /> - </packageRestore> - <bindingRedirects> - <add key="skip" value="False" /> - </bindingRedirects> - <packageManagement> - <add key="format" value="0" /> - <add key="disabled" value="False" /> - </packageManagement> -</configuration> +dotnet nuget config path C:\Test\Repos\Solution\NuGet.Config C:\Test\Repos\NuGet.Config @@ -87,29 +63,10 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.conf C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config ``` -- List all the NuGet configuration file that will be applied, when invoking NuGet command in the specific directory. +- List all the paths of NuGet configuration files that will be applied, when invoking NuGet command in the specific directory. ``` -dotnet nuget config list C:\Test\Repos --verbosity detailed - -<configuration> - <packageSources> - <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> - <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" /> - <add key="Test Package source" value="C:\work" /> - </packageSources> - <packageRestore> - <add key="enabled" value="False" /> - <add key="automatic" value="False" /> - </packageRestore> - <bindingRedirects> - <add key="skip" value="False" /> - </bindingRedirects> - <packageManagement> - <add key="format" value="0" /> - <add key="disabled" value="False" /> - </packageManagement> -</configuration> +dotnet nuget config path C:\Test\Repos C:\Test\Repos\NuGet.Config C:\Test\NuGet.Config @@ -118,36 +75,10 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.conf C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config ``` -- List only the NuGet configuration settings, when invoking NuGet command in the specific directory. - -``` -dotnet nuget config list C:\Test\Repos - -<configuration> - <packageSources> - <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> - <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" /> - <add key="Test Package source" value="C:\work" /> - </packageSources> - <packageRestore> - <add key="enabled" value="False" /> - <add key="automatic" value="False" /> - </packageRestore> - <bindingRedirects> - <add key="skip" value="False" /> - </bindingRedirects> - <packageManagement> - <add key="format" value="0" /> - <add key="disabled" value="False" /> - </packageManagement> -</configuration> - -``` - - List all the NuGet configuration file that will be applied, but passing a non-exsiting `WORKING_DIRECTORY`. ``` -dotnet nuget config list C:\Test\NonExistingRepos +dotnet nuget config path C:\Test\NonExistingRepos Error: The path "C:\Test\NonExistingRepos" doesn't exist. ``` @@ -157,26 +88,7 @@ Error: The path "C:\Test\NonExistingRepos" doesn't exist. The configuration file under C:\Test\AccessibleRepos\NotAccessibleSolution\NuGet.Config will be ignored without any warning or error. ``` -dotnet nuget config list C:\Test\AccessibleRepos\NotAccessibleSolution -v d - -<configuration> - <packageSources> - <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> - <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" /> - <add key="Test Package source" value="C:\work" /> - </packageSources> - <packageRestore> - <add key="enabled" value="False" /> - <add key="automatic" value="False" /> - </packageRestore> - <bindingRedirects> - <add key="skip" value="False" /> - </bindingRedirects> - <packageManagement> - <add key="format" value="0" /> - <add key="disabled" value="False" /> - </packageManagement> -</configuration> +dotnet nuget config list C:\Test\AccessibleRepos\NotAccessibleSolution C:\Test\AccessibleRepos\NuGet.Config C:\Test\NuGet.Config @@ -186,6 +98,11 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config ``` #### Commands +- Get + +Get the list of all the NuGet configuration settings. + +This command will list merged NuGet configuration settings from one or multiple NuGet configuration files that will be applied, when invoking NuGet command from the current working directory path. - Set @@ -213,6 +130,11 @@ Set the value of the SETTING_KEY to SETTING_VALUE. Specify the config file path to add the setting key-value pair. If it's not specified, the config file with highest priority will be updated. +- -v|--verbosity <LEVEL> + +Sets the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. The default is minimal. +When the verbosity level is detailed or diagnostic, + - -?|-h|--help Prints out a description of how to use the command. @@ -277,6 +199,32 @@ dotnet nuget config unset defaultPushSource --config-file C:\Users\username\AppD ``` +- List only the NuGet configuration settings, when invoking NuGet command in the specific directory. + +``` +dotnet nuget config list C:\Test\Repos + +<configuration> + <packageSources> + <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> + <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" /> + <add key="Test Package source" value="C:\work" /> + </packageSources> + <packageRestore> + <add key="enabled" value="False" /> + <add key="automatic" value="False" /> + </packageRestore> + <bindingRedirects> + <add key="skip" value="False" /> + </bindingRedirects> + <packageManagement> + <add key="format" value="0" /> + <add key="disabled" value="False" /> + </packageManagement> +</configuration> + +``` + ## Future Work 1. The `dotnet nuget config list` is a community ask. We will consider adding more commands, like add/update/delete, in the future. 2. We will discuss if adding this command into NuGet.exe CLI, in the future. From dfae3bdb7ee42bc0134fd78fe24d2304f14266da Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Fri, 18 Nov 2022 11:56:28 -0800 Subject: [PATCH 17/30] address comments --- proposed/2022/dotnet-nuget-config-spec.md | 214 ++++++++++++++++------ 1 file changed, 162 insertions(+), 52 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index 830b9a2d1f..c1bc9bfb05 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -31,18 +31,17 @@ List all the paths of NuGet configuration files that will be applied, when invok The listed NuGet configuration files are in priority order. So the order of loading those configurations is reversed, that is, loading order is from the bottom to the top. So the configuration on the top will apply. You may refer to [How settings are applied](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#how-settings-are-applied) for more details. -#### Arguments -- WORKING_DIRECTORY +#### Options + +- --working-directory Run this command as if working directory is set to the specified directory. -If the specified `WORKING_DIRECTORY` doesn't exist, an error is displayed indicating the `WORKING_DIRECTORY` doesn't exist. +If the specified `--working-directory` doesn't exist, an error is displayed indicating the `--working-directory` doesn't exist. > [!Note] -> If `WORKING_DIRECTORY` (or its parent directories) is not accessible, the command will ignore any NuGet configuration files under those directories without any warning/error. This is aligned with other NuGet commands. - -#### Options +> If `--working-directory` (or its parent directories) is not accessible, the command will ignore any NuGet configuration files under those directories without any warning/error. This is aligned with other NuGet commands. - -?|-h|--help @@ -66,7 +65,7 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config - List all the paths of NuGet configuration files that will be applied, when invoking NuGet command in the specific directory. ``` -dotnet nuget config path C:\Test\Repos +dotnet nuget config path --working-directory C:\Test\Repos C:\Test\Repos\NuGet.Config C:\Test\NuGet.Config @@ -78,7 +77,7 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config - List all the NuGet configuration file that will be applied, but passing a non-exsiting `WORKING_DIRECTORY`. ``` -dotnet nuget config path C:\Test\NonExistingRepos +dotnet nuget config path --working-directory C:\Test\NonExistingRepos Error: The path "C:\Test\NonExistingRepos" doesn't exist. ``` @@ -88,7 +87,7 @@ Error: The path "C:\Test\NonExistingRepos" doesn't exist. The configuration file under C:\Test\AccessibleRepos\NotAccessibleSolution\NuGet.Config will be ignored without any warning or error. ``` -dotnet nuget config list C:\Test\AccessibleRepos\NotAccessibleSolution +dotnet nuget config list --working-directory C:\Test\AccessibleRepos\NotAccessibleSolution C:\Test\AccessibleRepos\NuGet.Config C:\Test\NuGet.Config @@ -100,9 +99,141 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config #### Commands - Get -Get the list of all the NuGet configuration settings. +Get the NuGet configuration settings that will be applied. + +If CONFIG_KEY is not specified, this command will list all merged NuGet configuration settings from multiple NuGet configuration files that will be applied, when invoking NuGet command from the current working directory path. + +#### Arguments + +- CONFIG_KEY + +Get the effective value of the specified configuration settings of the [config section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#config-section). Please note this is the result of che + +> [!Note] +> The CONFIG_KEY could only be one of the valid key in config section. +For other sections, like package source section, we have/will have specific command [dotnet nuget list source](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-list-source). + +#### Options + +- --working-directory + +Run this command as if working directory is set to the specified directory. + +If the specified `--working-directory` doesn't exist, an error is displayed indicating the `--working-directory` doesn't exist. + +> [!Note] +> If `--working-directory` (or its parent directories) is not accessible, the command will ignore any NuGet configuration files under those directories without any warning/error. This is aligned with other NuGet commands. + +- -?|-h|--help + +Prints out a description of how to use the command. + +- -v|--verbosity <LEVEL> + +Sets the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. The default is minimal. + +When the verbosity level is detailed or diagnostic, the source(NuGet configuration file path) will be show besides the configuration settings. + +#### Examples + +- Get all the NuGet configuration settings that will be applied, when invoking NuGet command in the current directory. + +``` +dotnet nuget config get + +<configuration> + <packageSources> + <add key="source1" value="https://test/source1/v3/index.json" /> + <add key="source2" value="https://test/source2/v3/index.json" /> + </packageSources> + <packageSourceMapping> + <clear /> + <packageSource key = "source1"> + <package pattern="microsoft.*" /> + <package pattern="nuget.*" /> + </packageSource> + <packageSource key = "source2"> + <package pattern="system.*" /> + </packageSource> + </packageSourceMapping> + <packageRestore> + <add key="enabled" value="False" /> + <add key="automatic" value="False" /> + </packageRestore> +</configuration> + +``` +- Get all the NuGet configuration settings that will be applied, when invoking NuGet command in the specific directory. -This command will list merged NuGet configuration settings from one or multiple NuGet configuration files that will be applied, when invoking NuGet command from the current working directory path. +``` +dotnet nuget config get --working-directory C:\Test\Repos + +<configuration> + <packageSources> + <add key="source1" value="https://test/source1/v3/index.json" /> + <add key="source2" value="https://test/source2/v3/index.json" /> + </packageSources> + <packageSourceMapping> + <clear /> + <packageSource key = "source1"> + <package pattern="microsoft.*" /> + <package pattern="nuget.*" /> + </packageSource> + <packageSource key = "source2"> + <package pattern="system.*" /> + </packageSource> + </packageSourceMapping> + <packageRestore> + <add key="enabled" value="False" /> + <add key="automatic" value="False" /> + </packageRestore> +</configuration> + +``` + +- Get all the NuGet configuration settings that will be applied, when invoking NuGet command in the current directory. Show the source(nuget configuration file path) of each configuration settings/child items. + +``` +dotnet nuget config get -v d + +<configuration> + <packageSources> + <add key="source1" value="https://test/source1/v3/index.json" /> <!-- file: C:\Test\Repos\Solution\NuGet.Config --> + <add key="source2" value="https://test/source2/v3/index.json" /> <!-- file: C:\Test\Repos\NuGet.Config --> + </packageSources> + <packageSourceMapping> + <clear /> <!-- file: C:\Users\username\AppData\Roaming\NuGet\NuGet.Config --> + <packageSource key = "source1"> <!-- file: C:\Test\Repos\Solution\NuGet.Config --> + <package pattern="microsoft.*" /> + <package pattern="nuget.*" /> + </packageSource> + <packageSource key = "source2"> <!-- file: C:\Test\Repos\NuGet.Config --> + <package pattern="system.*" /> + </packageSource> + </packageSourceMapping> +</configuration> + +``` + +- Get `http_proxy` from config section, when invoking NuGet command in the current directory. + +``` +dotnet nuget config get http_proxy + +http://company-squid:3128@contoso.com" + +``` + +- Get `http_proxy` from config section, when `http_proxy` is not set in any of the NuGet configuration files. + +``` +dotnet nuget config get http_proxy + +Key 'http_proxy' not found. + +``` + +#### Commands - Set @@ -111,29 +242,25 @@ Set the NuGet configuration settings. This command will set the value of a specified NuGet configuration setting. Please note this command only manages settings in [config section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#config-section). -For other settings not in config section, we have/will have other commands. E.g. for [trustedSigners section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#trustedsigners-section), we have [dotnet nuget trust](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-trust) command. +For other settings not in config section, we have/will have other dedicated commands. E.g. for [trustedSigners section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#trustedsigners-section), we have [dotnet nuget trust](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-trust) command. #### Arguments -- SETTING_KEY +- CONFIG_KEY Specify the key of the settings that are to be set. -If the specified `SETTING_KEY` is not a key in [config section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#config-section), an error is displayed indicating the `SETTING_KEY` could not be set. +If the specified `CONFIG_KEY` is not a key in [config section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#config-section), a message is displayed indicating the `CONFIG_KEY` could not be set. -- SETTING_VALUE +- CONFIG_VALUE -Set the value of the SETTING_KEY to SETTING_VALUE. +Set the value of the CONFIG_KEY to CONFIG_VALUE. #### Options -- --config-file - -Specify the config file path to add the setting key-value pair. If it's not specified, the config file with highest priority will be updated. -- -v|--verbosity <LEVEL> +- --config-file -Sets the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. The default is minimal. -When the verbosity level is detailed or diagnostic, +Specify the config file path to add the setting key-value pair. If it's not specified, `%AppData%\NuGet\NuGet.Config` (Windows), or `~/.nuget/NuGet/NuGet.Config` or `~/.config/NuGet/NuGet.Config` (Mac/Linux) is used. See [On Mac/Linux, the user-level config file location varies by tooling.](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#on-maclinux-the-user-level-config-file-location-varies-by-tooling) - -?|-h|--help @@ -155,6 +282,8 @@ dotnet nuget config set defaultPushSource https://MyRepo/ES/api/v2/package --con ``` +#### Commands + - Unset Remove the NuGet configuration settings. @@ -166,12 +295,11 @@ For other settings not in config section, we have/will have other commands. E.g. #### Arguments -- SETTING_KEY +- CONFIG_KEY Specify the key of the settings that are to be removed. -If the specified `SETTING_KEY` is not a key in [config section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#config-section), an error is displayed indicating the `SETTING_KEY` could not be set. - +If the specified `CONFIG_KEY` is not a key in [config section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#config-section), a message is displayed indicating the `CONFIG_KEY` could not be unset. #### Options @@ -183,9 +311,17 @@ Specify the config file path to remove the setting key-value pair. If it's not s Prints out a description of how to use the command. +- --config-file + +Specify the config file path to remove the setting key-value pair. If it's not specified, `%AppData%\NuGet\NuGet.Config` (Windows), or `~/.nuget/NuGet/NuGet.Config` or `~/.config/NuGet/NuGet.Config` (Mac/Linux) is used. See [On Mac/Linux, the user-level config file location varies by tooling.](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#on-maclinux-the-user-level-config-file-location-varies-by-tooling) + +- -?|-h|--help + +Prints out a description of how to use the command. + #### Examples -- Unset the `signatureValidationMode` in the closest NuGet configuration file. +- Unset the `signatureValidationMode` in the user-wide NuGet configuration file. ``` dotnet nuget config unset signatureValidationMode @@ -199,32 +335,6 @@ dotnet nuget config unset defaultPushSource --config-file C:\Users\username\AppD ``` -- List only the NuGet configuration settings, when invoking NuGet command in the specific directory. - -``` -dotnet nuget config list C:\Test\Repos - -<configuration> - <packageSources> - <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> - <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" /> - <add key="Test Package source" value="C:\work" /> - </packageSources> - <packageRestore> - <add key="enabled" value="False" /> - <add key="automatic" value="False" /> - </packageRestore> - <bindingRedirects> - <add key="skip" value="False" /> - </bindingRedirects> - <packageManagement> - <add key="format" value="0" /> - <add key="disabled" value="False" /> - </packageManagement> -</configuration> - -``` - ## Future Work 1. The `dotnet nuget config list` is a community ask. We will consider adding more commands, like add/update/delete, in the future. 2. We will discuss if adding this command into NuGet.exe CLI, in the future. From 209f3f07d75d110e599eadd502306973dc5e1b6a Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Fri, 18 Nov 2022 16:56:55 -0800 Subject: [PATCH 18/30] edit the open questions --- proposed/2022/dotnet-nuget-config-spec.md | 24 +++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index c1bc9bfb05..862db01b72 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -15,7 +15,7 @@ This feature is for dotnet.exe users. Design and implement `dotnet nuget config` command. ## Non-Goals -Design and implement `dotnet nuget config` command with commands other than `list`, e.g. add/update/delete +Design and implement in the same way for NuGet.exe command. ## Solution The following command will be implemented in the `dotnet.exe` CLI. @@ -101,14 +101,14 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config Get the NuGet configuration settings that will be applied. -If CONFIG_KEY is not specified, this command will list all merged NuGet configuration settings from multiple NuGet configuration files that will be applied, when invoking NuGet command from the current working directory path. - #### Arguments - CONFIG_KEY Get the effective value of the specified configuration settings of the [config section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#config-section). Please note this is the result of che +If CONFIG_KEY is not specified, this command will get all merged NuGet configuration settings from multiple NuGet configuration files that will be applied, when invoking NuGet command from the current working directory path. + > [!Note] > The CONFIG_KEY could only be one of the valid key in config section. For other sections, like package source section, we have/will have specific command [dotnet nuget list source](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-list-source). @@ -336,16 +336,20 @@ dotnet nuget config unset defaultPushSource --config-file C:\Users\username\AppD ``` ## Future Work -1. The `dotnet nuget config list` is a community ask. We will consider adding more commands, like add/update/delete, in the future. -2. We will discuss if adding this command into NuGet.exe CLI, in the future. -3. NuGet.exe [config command](https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-config) is implemented. But there is no `list` command. And the behavior is confusing (the `set` command will set the property which appears last when loading, so sometimes it's not updating the closest NuGet configuration file). Do we want to implement those subcommand(e.g.`set`) in the future in dotnet.exe differently? +1. The `dotnet nuget config path/get` is a community ask. We will discuss if adding this command into NuGet.exe CLI, in the future. +2. NuGet.exe [config command](https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-config) is implemented. +But the behavior is confusing: the `set` command will set the property which appears last when loading, so sometimes it's not updating the closest NuGet configuration file. We might need to change this behavior in the future. (Related code: https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Configuration/Settings/Settings.cs#L229) ## Open Questions 1. To show configuration files locations, is it better to use `--verbosity` option or some option named like `--show-path`? (git command is using `--show-origin` for similar purpose) -2. What are the recommended verbs in dotnet command when setting and unsetting values? ('set' and 'unset' work or not?) -3. `Get` is not mentioned in this doc. It may cause some confusions: - Should `get` work for settings not in config section? (It's workable, but then we will miss `set` and `unset` for those as those are not doable) - Should `get` get the settings from a specific config file(like `set` and `unset`), or get the merged settings from multiple config files? + +2. `dotnet nuget config get <CONFIG_KEY>` will get the value of the specifc config key (which is aligned with NuGet config command). But +`dotnet nuget config get` will get all merged configuration settings in xml format, since many sections are not simple key-value pairs. + Do we need to have another verb for getting all merged configuration settings? + +3. `dotnet nuget config get -v d` will display source of each configuration setting key, in a format of comment in xml file. So that people can still redirect the output into a file without breaking any syntax. Does that sound good to you? + +3. `--working-directory` is changed from an argument into an option. Because we could not differentiate `dotnet nuget config get <WORKING_DIRECTORY>` and `dotnet nuget config get <CONFIG_KEY>`. Any better ideas? ## Considerations 1. Will this command help with diagnosing incorrect setting format? From efb1a2e5d17230304fe06ed337b880fe8c7c1ff7 Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Fri, 18 Nov 2022 17:14:20 -0800 Subject: [PATCH 19/30] fix --- proposed/2022/dotnet-nuget-config-spec.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index 862db01b72..78512a883b 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -74,7 +74,7 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.conf C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config ``` -- List all the NuGet configuration file that will be applied, but passing a non-exsiting `WORKING_DIRECTORY`. +- List all the NuGet configuration file that will be applied, but passing a non-exsiting `--working-directory`. ``` dotnet nuget config path --working-directory C:\Test\NonExistingRepos @@ -82,7 +82,7 @@ dotnet nuget config path --working-directory C:\Test\NonExistingRepos Error: The path "C:\Test\NonExistingRepos" doesn't exist. ``` -- List all the NuGet configuration file that will be applied, but passing an inaccessible `WORKING_DIRECTORY`: C:\Test\AccessibleRepos\NotAccessibleSolution. +- List all the NuGet configuration file that will be applied, but passing an inaccessible `--working-directory`: C:\Test\AccessibleRepos\NotAccessibleSolution. The configuration file under C:\Test\AccessibleRepos\NotAccessibleSolution\NuGet.Config will be ignored without any warning or error. @@ -338,7 +338,10 @@ dotnet nuget config unset defaultPushSource --config-file C:\Users\username\AppD ## Future Work 1. The `dotnet nuget config path/get` is a community ask. We will discuss if adding this command into NuGet.exe CLI, in the future. 2. NuGet.exe [config command](https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-config) is implemented. -But the behavior is confusing: the `set` command will set the property which appears last when loading, so sometimes it's not updating the closest NuGet configuration file. We might need to change this behavior in the future. (Related code: https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Configuration/Settings/Settings.cs#L229) +But the behavior is confusing: the `set` command will set the property which appears last when loading(for all writable files), so it's not updating the closest NuGet configuration file, but the user-wide NuGet configuration file.(Related code: https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Configuration/Settings/Settings.cs#L229) +We keep the behavior of `dotnet nuget config set` the same with above for now. +But we might need to change this behavior in the future. +Considering this will be a breaking change, we will only consider doing it in main version change, if there are enough votes. ## Open Questions 1. To show configuration files locations, is it better to use `--verbosity` option or some option named like `--show-path`? (git command is using `--show-origin` for similar purpose) From b56944dcc7aa47fe702b3cf8f89e4e9a9205a0dc Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Fri, 18 Nov 2022 17:28:33 -0800 Subject: [PATCH 20/30] fix format --- proposed/2022/dotnet-nuget-config-spec.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index 78512a883b..7268e7a1f9 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -358,6 +358,8 @@ Considering this will be a breaking change, we will only consider doing it in ma 1. Will this command help with diagnosing incorrect setting format? <br />No. Incorrect NuGet settings should have seperate error/warning message to tell the customer what's wrong in the setting file. If we have incorrect NuGet settings, all NuGet command, including `dotnet nuget config` command, should display the same error/warning message. <br />E.g. if we have an invalid XML problem in one of the NuGet configuration file, running all NuGet command will get an error as following: +``` dotnet nuget list source error: NuGet.Config is not valid XML. Path: 'C:\Users\username\Source\Repos\NuGet.Config'. error: The 'disabledPackageSources' start tag on line 19 position 4 does not match the end tag of 'configuration'. Line 20, position 3. +``` From 4150a2bdaf49ee004f8a521f95ad4af7f08b28f5 Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Mon, 21 Nov 2022 09:28:06 -0800 Subject: [PATCH 21/30] fix --- proposed/2022/dotnet-nuget-config-spec.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index 7268e7a1f9..0b10273c61 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -305,14 +305,6 @@ If the specified `CONFIG_KEY` is not a key in [config section](https://learn.mic - --config-file -Specify the config file path to remove the setting key-value pair. If it's not specified, the config file with highest priority will be updated. - -- -?|-h|--help - -Prints out a description of how to use the command. - -- --config-file - Specify the config file path to remove the setting key-value pair. If it's not specified, `%AppData%\NuGet\NuGet.Config` (Windows), or `~/.nuget/NuGet/NuGet.Config` or `~/.config/NuGet/NuGet.Config` (Mac/Linux) is used. See [On Mac/Linux, the user-level config file location varies by tooling.](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#on-maclinux-the-user-level-config-file-location-varies-by-tooling) - -?|-h|--help @@ -337,6 +329,7 @@ dotnet nuget config unset defaultPushSource --config-file C:\Users\username\AppD ## Future Work 1. The `dotnet nuget config path/get` is a community ask. We will discuss if adding this command into NuGet.exe CLI, in the future. + 2. NuGet.exe [config command](https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-config) is implemented. But the behavior is confusing: the `set` command will set the property which appears last when loading(for all writable files), so it's not updating the closest NuGet configuration file, but the user-wide NuGet configuration file.(Related code: https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Configuration/Settings/Settings.cs#L229) We keep the behavior of `dotnet nuget config set` the same with above for now. From b74b82974e9471a81913ae7c271f9ac79013070b Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Mon, 21 Nov 2022 09:33:19 -0800 Subject: [PATCH 22/30] fix option working-dir --- proposed/2022/dotnet-nuget-config-spec.md | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index 0b10273c61..4af6a7426c 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -34,14 +34,14 @@ You may refer to [How settings are applied](https://learn.microsoft.com/en-us/nu #### Options -- --working-directory +- -w|--working-dir <WORKING_DIRECTORY> Run this command as if working directory is set to the specified directory. -If the specified `--working-directory` doesn't exist, an error is displayed indicating the `--working-directory` doesn't exist. +If the specified `--working-dir` doesn't exist, an error is displayed indicating the `--working-dir` doesn't exist. > [!Note] -> If `--working-directory` (or its parent directories) is not accessible, the command will ignore any NuGet configuration files under those directories without any warning/error. This is aligned with other NuGet commands. +> If `--working-dir` (or its parent directories) is not accessible, the command will ignore any NuGet configuration files under those directories without any warning/error. This is aligned with other NuGet commands. - -?|-h|--help @@ -65,7 +65,7 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config - List all the paths of NuGet configuration files that will be applied, when invoking NuGet command in the specific directory. ``` -dotnet nuget config path --working-directory C:\Test\Repos +dotnet nuget config path --working-dir C:\Test\Repos C:\Test\Repos\NuGet.Config C:\Test\NuGet.Config @@ -74,20 +74,20 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.conf C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config ``` -- List all the NuGet configuration file that will be applied, but passing a non-exsiting `--working-directory`. +- List all the NuGet configuration file that will be applied, but passing a non-exsiting `--working-dir`. ``` -dotnet nuget config path --working-directory C:\Test\NonExistingRepos +dotnet nuget config path --working-dir C:\Test\NonExistingRepos Error: The path "C:\Test\NonExistingRepos" doesn't exist. ``` -- List all the NuGet configuration file that will be applied, but passing an inaccessible `--working-directory`: C:\Test\AccessibleRepos\NotAccessibleSolution. +- List all the NuGet configuration file that will be applied, but passing an inaccessible `--working-dir`: C:\Test\AccessibleRepos\NotAccessibleSolution. The configuration file under C:\Test\AccessibleRepos\NotAccessibleSolution\NuGet.Config will be ignored without any warning or error. ``` -dotnet nuget config list --working-directory C:\Test\AccessibleRepos\NotAccessibleSolution +dotnet nuget config list --working-dir C:\Test\AccessibleRepos\NotAccessibleSolution C:\Test\AccessibleRepos\NuGet.Config C:\Test\NuGet.Config @@ -115,14 +115,14 @@ For other sections, like package source section, we have/will have specific comm #### Options -- --working-directory +- -w|--working-dir <WORKING_DIRECTORY> Run this command as if working directory is set to the specified directory. -If the specified `--working-directory` doesn't exist, an error is displayed indicating the `--working-directory` doesn't exist. +If the specified `--working-dir` doesn't exist, an error is displayed indicating the `--working-dir` doesn't exist. > [!Note] -> If `--working-directory` (or its parent directories) is not accessible, the command will ignore any NuGet configuration files under those directories without any warning/error. This is aligned with other NuGet commands. +> If `--working-dir` (or its parent directories) is not accessible, the command will ignore any NuGet configuration files under those directories without any warning/error. This is aligned with other NuGet commands. - -?|-h|--help @@ -166,7 +166,7 @@ dotnet nuget config get - Get all the NuGet configuration settings that will be applied, when invoking NuGet command in the specific directory. ``` -dotnet nuget config get --working-directory C:\Test\Repos +dotnet nuget config get --working-dir C:\Test\Repos <configuration> <packageSources> @@ -345,7 +345,7 @@ Considering this will be a breaking change, we will only consider doing it in ma 3. `dotnet nuget config get -v d` will display source of each configuration setting key, in a format of comment in xml file. So that people can still redirect the output into a file without breaking any syntax. Does that sound good to you? -3. `--working-directory` is changed from an argument into an option. Because we could not differentiate `dotnet nuget config get <WORKING_DIRECTORY>` and `dotnet nuget config get <CONFIG_KEY>`. Any better ideas? +3. `--working-dir` is changed from an argument into an option. Because we could not differentiate `dotnet nuget config get <WORKING_DIRECTORY>` and `dotnet nuget config get <CONFIG_KEY>`. Any better ideas? ## Considerations 1. Will this command help with diagnosing incorrect setting format? From b67907434c72723b2cd58d4b55f3ab2bd3f948a9 Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Tue, 22 Nov 2022 12:56:49 -0800 Subject: [PATCH 23/30] address feedback --- proposed/2022/dotnet-nuget-config-spec.md | 158 +++++++++++----------- 1 file changed, 77 insertions(+), 81 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index 4af6a7426c..13c409dbeb 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -22,9 +22,9 @@ The following command will be implemented in the `dotnet.exe` CLI. ### `dotnet nuget config` -#### Commands +### Commands -- Path +### Path List all the paths of NuGet configuration files that will be applied, when invoking NuGet command from the current working directory path. @@ -87,7 +87,7 @@ Error: The path "C:\Test\NonExistingRepos" doesn't exist. The configuration file under C:\Test\AccessibleRepos\NotAccessibleSolution\NuGet.Config will be ignored without any warning or error. ``` -dotnet nuget config list --working-dir C:\Test\AccessibleRepos\NotAccessibleSolution +dotnet nuget config path --working-dir C:\Test\AccessibleRepos\NotAccessibleSolution C:\Test\AccessibleRepos\NuGet.Config C:\Test\NuGet.Config @@ -96,18 +96,20 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.conf C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config ``` -#### Commands -- Get +### Get Get the NuGet configuration settings that will be applied. #### Arguments +- ALL + +Get all merged NuGet configuration settings from multiple NuGet configuration files that will be applied, when invoking NuGet command from the current working directory path. + - CONFIG_KEY -Get the effective value of the specified configuration settings of the [config section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#config-section). Please note this is the result of che +Get the effective value of the specified configuration settings of the [config section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#config-section). -If CONFIG_KEY is not specified, this command will get all merged NuGet configuration settings from multiple NuGet configuration files that will be applied, when invoking NuGet command from the current working directory path. > [!Note] > The CONFIG_KEY could only be one of the valid key in config section. @@ -139,79 +141,68 @@ When the verbosity level is detailed or diagnostic, the source(NuGet configurati - Get all the NuGet configuration settings that will be applied, when invoking NuGet command in the current directory. ``` -dotnet nuget config get - -<configuration> - <packageSources> - <add key="source1" value="https://test/source1/v3/index.json" /> - <add key="source2" value="https://test/source2/v3/index.json" /> - </packageSources> - <packageSourceMapping> - <clear /> - <packageSource key = "source1"> - <package pattern="microsoft.*" /> - <package pattern="nuget.*" /> - </packageSource> - <packageSource key = "source2"> - <package pattern="system.*" /> - </packageSource> - </packageSourceMapping> - <packageRestore> - <add key="enabled" value="False" /> - <add key="automatic" value="False" /> - </packageRestore> -</configuration> +dotnet nuget config get all + +packageSources: + "source1" value="https://test/source1/v3/index.json" + "source2" value="https://test/source2/v3/index.json" + +packageSourceMapping: + clear + "source1" + pattern="microsoft.*" + pattern="nuget.*" + "source2" + pattern="system.*" + +packageRestore: + "enabled" value="False" + "automatic" value="False" ``` - Get all the NuGet configuration settings that will be applied, when invoking NuGet command in the specific directory. ``` -dotnet nuget config get --working-dir C:\Test\Repos - -<configuration> - <packageSources> - <add key="source1" value="https://test/source1/v3/index.json" /> - <add key="source2" value="https://test/source2/v3/index.json" /> - </packageSources> - <packageSourceMapping> - <clear /> - <packageSource key = "source1"> - <package pattern="microsoft.*" /> - <package pattern="nuget.*" /> - </packageSource> - <packageSource key = "source2"> - <package pattern="system.*" /> - </packageSource> - </packageSourceMapping> - <packageRestore> - <add key="enabled" value="False" /> - <add key="automatic" value="False" /> - </packageRestore> -</configuration> +dotnet nuget config get all --working-dir C:\Test\Repos + +packageSources: + "source1" value="https://test/source1/v3/index.json" + "source2" value="https://test/source2/v3/index.json" + +packageSourceMapping: + clear + "source1" + pattern="microsoft.*" + pattern="nuget.*" + "source2" + pattern="system.*" + +packageRestore: + "enabled" value="False" + "automatic" value="False" ``` - Get all the NuGet configuration settings that will be applied, when invoking NuGet command in the current directory. Show the source(nuget configuration file path) of each configuration settings/child items. ``` -dotnet nuget config get -v d - -<configuration> - <packageSources> - <add key="source1" value="https://test/source1/v3/index.json" /> <!-- file: C:\Test\Repos\Solution\NuGet.Config --> - <add key="source2" value="https://test/source2/v3/index.json" /> <!-- file: C:\Test\Repos\NuGet.Config --> - </packageSources> - <packageSourceMapping> - <clear /> <!-- file: C:\Users\username\AppData\Roaming\NuGet\NuGet.Config --> - <packageSource key = "source1"> <!-- file: C:\Test\Repos\Solution\NuGet.Config --> - <package pattern="microsoft.*" /> - <package pattern="nuget.*" /> - </packageSource> - <packageSource key = "source2"> <!-- file: C:\Test\Repos\NuGet.Config --> - <package pattern="system.*" /> - </packageSource> - </packageSourceMapping> -</configuration> +dotnet nuget config get all -v d + +packageSources: + "source1" value="https://test/source1/v3/index.json" file: C:\Test\Repos\Solution\NuGet.Config + "source2" value="https://test/source2/v3/index.json" file: C:\Test\Repos\NuGet.Config + +packageSourceMapping: + clear file: C:\Users\username\AppData\Roaming\NuGet\NuGet.Config + "source1" file: C:\Test\Repos\Solution\NuGet.Config + pattern="microsoft.*" + pattern="nuget.*" + "source2" + pattern="system.*" file: C:\Test\Repos\NuGet.Config + +packageRestore: + "enabled" value="False" file: C:\Users\username\AppData\Roaming\NuGet\NuGet.Config + "automatic" value="False" file: C:\Users\username\AppData\Roaming\NuGet\NuGet.Config ``` @@ -224,6 +215,15 @@ http://company-squid:3128@contoso.com" ``` +- Get `http_proxy` from config section, when invoking NuGet command in the current directory. Show the source(nuget configuration file path) of this configuration setting. + +``` +dotnet nuget config get http_proxy + +http://company-squid:3128@contoso.com" file: C:\Test\Repos\Solution\NuGet.Config + +``` + - Get `http_proxy` from config section, when `http_proxy` is not set in any of the NuGet configuration files. ``` @@ -233,9 +233,7 @@ Key 'http_proxy' not found. ``` -#### Commands - -- Set +### Set Set the NuGet configuration settings. @@ -258,9 +256,9 @@ Set the value of the CONFIG_KEY to CONFIG_VALUE. #### Options -- --config-file +- --configfile <FILE> -Specify the config file path to add the setting key-value pair. If it's not specified, `%AppData%\NuGet\NuGet.Config` (Windows), or `~/.nuget/NuGet/NuGet.Config` or `~/.config/NuGet/NuGet.Config` (Mac/Linux) is used. See [On Mac/Linux, the user-level config file location varies by tooling.](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#on-maclinux-the-user-level-config-file-location-varies-by-tooling) +The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If it's not specified, `%AppData%\NuGet\NuGet.Config` (Windows), or `~/.nuget/NuGet/NuGet.Config` or `~/.config/NuGet/NuGet.Config` (Mac/Linux) is used. See [On Mac/Linux, the user-level config file location varies by tooling.](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#on-maclinux-the-user-level-config-file-location-varies-by-tooling) - -?|-h|--help @@ -278,13 +276,11 @@ dotnet nuget config set signatureValidationMode require - Set the `defaultPushSource` in the specified NuGet configuration file. ``` -dotnet nuget config set defaultPushSource https://MyRepo/ES/api/v2/package --config-file C:\Users\username\AppData\Roaming\NuGet\NuGet.Config +dotnet nuget config set defaultPushSource https://MyRepo/ES/api/v2/package --configfile C:\Users\username\AppData\Roaming\NuGet\NuGet.Config ``` -#### Commands - -- Unset +### Unset Remove the NuGet configuration settings. @@ -303,9 +299,9 @@ If the specified `CONFIG_KEY` is not a key in [config section](https://learn.mic #### Options -- --config-file +- --configfile <FILE> -Specify the config file path to remove the setting key-value pair. If it's not specified, `%AppData%\NuGet\NuGet.Config` (Windows), or `~/.nuget/NuGet/NuGet.Config` or `~/.config/NuGet/NuGet.Config` (Mac/Linux) is used. See [On Mac/Linux, the user-level config file location varies by tooling.](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#on-maclinux-the-user-level-config-file-location-varies-by-tooling) +The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If it's not specified, `%AppData%\NuGet\NuGet.Config` (Windows), or `~/.nuget/NuGet/NuGet.Config` or `~/.config/NuGet/NuGet.Config` (Mac/Linux) is used. See [On Mac/Linux, the user-level config file location varies by tooling.](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#on-maclinux-the-user-level-config-file-location-varies-by-tooling) - -?|-h|--help @@ -323,7 +319,7 @@ dotnet nuget config unset signatureValidationMode - Unset the `defaultPushSource` in the specified NuGet configuration file. ``` -dotnet nuget config unset defaultPushSource --config-file C:\Users\username\AppData\Roaming\NuGet\NuGet.Config +dotnet nuget config unset defaultPushSource --configfile C:\Users\username\AppData\Roaming\NuGet\NuGet.Config ``` From 3b4ef114c120423e9636e7f08c9e090c033ed08b Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Tue, 22 Nov 2022 13:40:06 -0800 Subject: [PATCH 24/30] Reformat the output of dotnet nuget config all --- proposed/2022/dotnet-nuget-config-spec.md | 70 ++++++++++++----------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index 13c409dbeb..c3286440b8 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -144,20 +144,18 @@ When the verbosity level is detailed or diagnostic, the source(NuGet configurati dotnet nuget config get all packageSources: - "source1" value="https://test/source1/v3/index.json" - "source2" value="https://test/source2/v3/index.json" + clear + add key="source1" value="https://test/source1/v3/index.json" + add key="source2" value="https://test/source2/v3/index.json" packageSourceMapping: clear - "source1" - pattern="microsoft.*" - pattern="nuget.*" - "source2" - pattern="system.*" + packageSource key="source1" pattern="microsoft.*","nuget.*" + packageSource key="source2" pattern="system.*" packageRestore: - "enabled" value="False" - "automatic" value="False" + add key="enabled" value="False" + add key="automatic" value="False" ``` - Get all the NuGet configuration settings that will be applied, when invoking NuGet command in the specific directory. @@ -166,20 +164,18 @@ packageRestore: dotnet nuget config get all --working-dir C:\Test\Repos packageSources: - "source1" value="https://test/source1/v3/index.json" - "source2" value="https://test/source2/v3/index.json" + clear + add key="source1" value="https://test/source1/v3/index.json" + add key="source2" value="https://test/source2/v3/index.json" packageSourceMapping: clear - "source1" - pattern="microsoft.*" - pattern="nuget.*" - "source2" - pattern="system.*" + packageSource key="source1" pattern="microsoft.*","nuget.*" + packageSource key="source2" pattern="system.*" packageRestore: - "enabled" value="False" - "automatic" value="False" + add key="enabled" value="False" + add key="automatic" value="False" ``` @@ -189,20 +185,17 @@ packageRestore: dotnet nuget config get all -v d packageSources: - "source1" value="https://test/source1/v3/index.json" file: C:\Test\Repos\Solution\NuGet.Config - "source2" value="https://test/source2/v3/index.json" file: C:\Test\Repos\NuGet.Config + add key="source1" value="https://test/source1/v3/index.json" file: C:\Test\Repos\Solution\NuGet.Config + add key="source2" value="https://test/source2/v3/index.json" file: C:\Test\Repos\NuGet.Config packageSourceMapping: - clear file: C:\Users\username\AppData\Roaming\NuGet\NuGet.Config - "source1" file: C:\Test\Repos\Solution\NuGet.Config - pattern="microsoft.*" - pattern="nuget.*" - "source2" - pattern="system.*" file: C:\Test\Repos\NuGet.Config + clear file: C:\Users\username\AppData\Roaming\NuGet\NuGet.Config + packageSource key="source1" pattern="microsoft.*","nuget.*" file: C:\Test\Repos\Solution\NuGet.Config + packageSource key="source2" pattern="system.*" file: C:\Test\Repos\NuGet.Config packageRestore: - "enabled" value="False" file: C:\Users\username\AppData\Roaming\NuGet\NuGet.Config - "automatic" value="False" file: C:\Users\username\AppData\Roaming\NuGet\NuGet.Config + add key="enabled" value="False" file: C:\Users\username\AppData\Roaming\NuGet\NuGet.Config + add key="automatic" value="False" file: C:\Users\username\AppData\Roaming\NuGet\NuGet.Config ``` @@ -335,13 +328,24 @@ Considering this will be a breaking change, we will only consider doing it in ma ## Open Questions 1. To show configuration files locations, is it better to use `--verbosity` option or some option named like `--show-path`? (git command is using `--show-origin` for similar purpose) -2. `dotnet nuget config get <CONFIG_KEY>` will get the value of the specifc config key (which is aligned with NuGet config command). But -`dotnet nuget config get` will get all merged configuration settings in xml format, since many sections are not simple key-value pairs. - Do we need to have another verb for getting all merged configuration settings? +2. `dotnet nuget config get <CONFIG_KEY>` will get the value of the specifc config key (which is aligned with NuGet config command). `dotnet nuget config get` will get all merged configuration settings(not XML format). Since many sections are not simple key-value pairs, we need to define the format of outputs when getting all merged configuration settings. We need to define formats for all kinds of config sections. Here is an example: +``` +packageSources: + clear + add key="source1" value="https://test/source1/v3/index.json" + add key="source2" value="https://test/source2/v3/index.json" + +packageSourceMapping: + clear + packageSource key="source1" pattern="microsoft.*","nuget.*" + packageSource key="source2" pattern="system.*" -3. `dotnet nuget config get -v d` will display source of each configuration setting key, in a format of comment in xml file. So that people can still redirect the output into a file without breaking any syntax. Does that sound good to you? +packageRestore: + add key="enabled" value="False" + add key="automatic" value="False" +``` -3. `--working-dir` is changed from an argument into an option. Because we could not differentiate `dotnet nuget config get <WORKING_DIRECTORY>` and `dotnet nuget config get <CONFIG_KEY>`. Any better ideas? +3. `--working-dir` is changed from an argument into an option. (Follow the example of Dotnet store command. It has -w|--working-dir <WORKING_DIRECTORY> option https://learn.microsoft.com/dotnet/core/tools/dotnet-store#optional-options). ## Considerations 1. Will this command help with diagnosing incorrect setting format? From 46aec6c0887faa1d43581e75765020349feff7be Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Tue, 22 Nov 2022 13:54:55 -0800 Subject: [PATCH 25/30] address feedback --- proposed/2022/dotnet-nuget-config-spec.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index c3286440b8..8fe6137f6d 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -326,9 +326,13 @@ But we might need to change this behavior in the future. Considering this will be a breaking change, we will only consider doing it in main version change, if there are enough votes. ## Open Questions -1. To show configuration files locations, is it better to use `--verbosity` option or some option named like `--show-path`? (git command is using `--show-origin` for similar purpose) +1. Shall we use `dotnet nuget config get all` or `dotnet nuget config get` to get all configuration settings? -2. `dotnet nuget config get <CONFIG_KEY>` will get the value of the specifc config key (which is aligned with NuGet config command). `dotnet nuget config get` will get all merged configuration settings(not XML format). Since many sections are not simple key-value pairs, we need to define the format of outputs when getting all merged configuration settings. We need to define formats for all kinds of config sections. Here is an example: +2. `--working-dir` is changed from an argument into an option. (Follow the example of Dotnet store command. It has -w|--working-dir <WORKING_DIRECTORY> option https://learn.microsoft.com/dotnet/core/tools/dotnet-store#optional-options). Any other thoughts? + +3. To show configuration files locations, is it better to use `--verbosity` option or some option named like `--show-path`? (git command is using `--show-origin` for similar purpose) + +4. `dotnet nuget config get <CONFIG_KEY>` will get the value of the specifc config key (which is aligned with NuGet config command). `dotnet nuget config get` will get all merged configuration settings(not XML format). Since many sections are not simple key-value pairs, we need to define the format of outputs when getting all merged configuration settings. We need to define formats for all kinds of config sections. Here is an example: ``` packageSources: clear @@ -345,8 +349,6 @@ packageRestore: add key="automatic" value="False" ``` -3. `--working-dir` is changed from an argument into an option. (Follow the example of Dotnet store command. It has -w|--working-dir <WORKING_DIRECTORY> option https://learn.microsoft.com/dotnet/core/tools/dotnet-store#optional-options). - ## Considerations 1. Will this command help with diagnosing incorrect setting format? <br />No. Incorrect NuGet settings should have seperate error/warning message to tell the customer what's wrong in the setting file. If we have incorrect NuGet settings, all NuGet command, including `dotnet nuget config` command, should display the same error/warning message. From 0836860d7c64e30e388bbc1f559e61c440e63cc2 Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Tue, 22 Nov 2022 13:56:23 -0800 Subject: [PATCH 26/30] address feedback --- proposed/2022/dotnet-nuget-config-spec.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index 8fe6137f6d..f8f8858e3b 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -326,13 +326,15 @@ But we might need to change this behavior in the future. Considering this will be a breaking change, we will only consider doing it in main version change, if there are enough votes. ## Open Questions -1. Shall we use `dotnet nuget config get all` or `dotnet nuget config get` to get all configuration settings? +1. Shall we use `dotnet nuget config path` or `dotnet nuget config paths` to get all configuration file paths? -2. `--working-dir` is changed from an argument into an option. (Follow the example of Dotnet store command. It has -w|--working-dir <WORKING_DIRECTORY> option https://learn.microsoft.com/dotnet/core/tools/dotnet-store#optional-options). Any other thoughts? +2. Shall we use `dotnet nuget config get all` or `dotnet nuget config get` to get all configuration settings? -3. To show configuration files locations, is it better to use `--verbosity` option or some option named like `--show-path`? (git command is using `--show-origin` for similar purpose) +3. `--working-dir` is changed from an argument into an option. (Follow the example of Dotnet store command. It has -w|--working-dir <WORKING_DIRECTORY> option https://learn.microsoft.com/dotnet/core/tools/dotnet-store#optional-options). Any other thoughts? -4. `dotnet nuget config get <CONFIG_KEY>` will get the value of the specifc config key (which is aligned with NuGet config command). `dotnet nuget config get` will get all merged configuration settings(not XML format). Since many sections are not simple key-value pairs, we need to define the format of outputs when getting all merged configuration settings. We need to define formats for all kinds of config sections. Here is an example: +4. To show configuration files locations, is it better to use `--verbosity` option or some option named like `--show-path`? (git command is using `--show-origin` for similar purpose) + +5. `dotnet nuget config get <CONFIG_KEY>` will get the value of the specifc config key (which is aligned with NuGet config command). `dotnet nuget config get` will get all merged configuration settings(not XML format). Since many sections are not simple key-value pairs, we need to define the format of outputs when getting all merged configuration settings. We need to define formats for all kinds of config sections. Here is an example: ``` packageSources: clear From e4b6ae53792f01a50dcdd05ae781bfa36eb1c6b1 Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Tue, 6 Dec 2022 11:29:38 -0800 Subject: [PATCH 27/30] change WORKING_DIRECTORY from option to argument --- proposed/2022/dotnet-nuget-config-spec.md | 76 ++++++++++++----------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index f8f8858e3b..de6a868571 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -31,17 +31,18 @@ List all the paths of NuGet configuration files that will be applied, when invok The listed NuGet configuration files are in priority order. So the order of loading those configurations is reversed, that is, loading order is from the bottom to the top. So the configuration on the top will apply. You may refer to [How settings are applied](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#how-settings-are-applied) for more details. +#### Arguments -#### Options - -- -w|--working-dir <WORKING_DIRECTORY> +- WORKING_DIRECTORY -Run this command as if working directory is set to the specified directory. +Run this command as if working directory is set to the specified directory. If it's not specified, the current working directory will be used. -If the specified `--working-dir` doesn't exist, an error is displayed indicating the `--working-dir` doesn't exist. +If the specified `WORKING_DIRECTORY` doesn't exist, an error is displayed indicating the `WORKING_DIRECTORY` doesn't exist. > [!Note] -> If `--working-dir` (or its parent directories) is not accessible, the command will ignore any NuGet configuration files under those directories without any warning/error. This is aligned with other NuGet commands. +> If `WORKING_DIRECTORY` (or its parent directories) is not accessible, the command will ignore any NuGet configuration files under those directories without any warning/error. This is aligned with other NuGet commands. + +#### Options - -?|-h|--help @@ -65,7 +66,7 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config - List all the paths of NuGet configuration files that will be applied, when invoking NuGet command in the specific directory. ``` -dotnet nuget config path --working-dir C:\Test\Repos +dotnet nuget config path C:\Test\Repos C:\Test\Repos\NuGet.Config C:\Test\NuGet.Config @@ -74,20 +75,20 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.conf C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config ``` -- List all the NuGet configuration file that will be applied, but passing a non-exsiting `--working-dir`. +- List all the NuGet configuration file that will be applied, but passing a non-existing argument `WORKING_DIRECTORY`. ``` -dotnet nuget config path --working-dir C:\Test\NonExistingRepos +dotnet nuget config path C:\Test\NonExistingRepos Error: The path "C:\Test\NonExistingRepos" doesn't exist. ``` -- List all the NuGet configuration file that will be applied, but passing an inaccessible `--working-dir`: C:\Test\AccessibleRepos\NotAccessibleSolution. +- List all the NuGet configuration file that will be applied, but passing an inaccessible `WORKING_DIRECTORY`: C:\Test\AccessibleRepos\NotAccessibleSolution. The configuration file under C:\Test\AccessibleRepos\NotAccessibleSolution\NuGet.Config will be ignored without any warning or error. ``` -dotnet nuget config path --working-dir C:\Test\AccessibleRepos\NotAccessibleSolution +dotnet nuget config path C:\Test\AccessibleRepos\NotAccessibleSolution C:\Test\AccessibleRepos\NuGet.Config C:\Test\NuGet.Config @@ -104,7 +105,7 @@ Get the NuGet configuration settings that will be applied. - ALL -Get all merged NuGet configuration settings from multiple NuGet configuration files that will be applied, when invoking NuGet command from the current working directory path. +Get all merged NuGet configuration settings from multiple NuGet configuration files that will be applied, when invoking NuGet command from the working directory path. - CONFIG_KEY @@ -112,19 +113,19 @@ Get the effective value of the specified configuration settings of the [config s > [!Note] -> The CONFIG_KEY could only be one of the valid key in config section. +> The CONFIG_KEY could only be one of the valid keys in config section. For other sections, like package source section, we have/will have specific command [dotnet nuget list source](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-list-source). -#### Options - -- -w|--working-dir <WORKING_DIRECTORY> +- WORKING_DIRECTORY -Run this command as if working directory is set to the specified directory. +Run this command as if working directory is set to the specified directory. If it's not specified, the current working directory will be used. -If the specified `--working-dir` doesn't exist, an error is displayed indicating the `--working-dir` doesn't exist. +If the specified `WORKING_DIRECTORY` doesn't exist, an error is displayed indicating the `WORKING_DIRECTORY` doesn't exist. > [!Note] -> If `--working-dir` (or its parent directories) is not accessible, the command will ignore any NuGet configuration files under those directories without any warning/error. This is aligned with other NuGet commands. +> If `WORKING_DIRECTORY` (or its parent directories) is not accessible, the command will ignore any NuGet configuration files under those directories without any warning/error. This is aligned with other NuGet commands. + +#### Options - -?|-h|--help @@ -161,7 +162,7 @@ packageRestore: - Get all the NuGet configuration settings that will be applied, when invoking NuGet command in the specific directory. ``` -dotnet nuget config get all --working-dir C:\Test\Repos +dotnet nuget config get all C:\Test\Repos packageSources: clear @@ -233,7 +234,7 @@ Set the NuGet configuration settings. This command will set the value of a specified NuGet configuration setting. Please note this command only manages settings in [config section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#config-section). -For other settings not in config section, we have/will have other dedicated commands. E.g. for [trustedSigners section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#trustedsigners-section), we have [dotnet nuget trust](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-trust) command. +For other settings not in config section, we have/will have other dedicated commands. E.g., for [trustedSigners section](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#trustedsigners-section), we have [dotnet nuget trust](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-trust) command. #### Arguments @@ -328,13 +329,26 @@ Considering this will be a breaking change, we will only consider doing it in ma ## Open Questions 1. Shall we use `dotnet nuget config path` or `dotnet nuget config paths` to get all configuration file paths? -2. Shall we use `dotnet nuget config get all` or `dotnet nuget config get` to get all configuration settings? +2. `WORKING_DIRECTORY` is changed from an option to an argument. So we have `dotnet nuget config path <WORKING_DIRECTORY>` and `dotnet nuget config get <ALL|CONFIG_KEY> <WORKING_DIRECTORY>`. Is it okey if we have two arguments in the second command? And if it's key, only the second argument could be optional, right? + +3. To show configuration files locations, is it better to use `--verbosity` option or some option named like `--show-path`? (git command is using `--show-origin` for similar purpose) + + +## Considerations +1. Will this command help with diagnosing incorrect setting format? +<br />No. Incorrect NuGet settings should have separate error/warning message to tell the customer what's wrong in the setting file. If we have incorrect NuGet settings, all NuGet command, including `dotnet nuget config` command, should display the same error/warning message. +<br />E.g., if we have an invalid XML problem in one of the NuGet configuration file, running all NuGet command will get an error as following: +``` +dotnet nuget list source +error: NuGet.Config is not valid XML. Path: 'C:\Users\username\Source\Repos\NuGet.Config'. +error: The 'disabledPackageSources' start tag on line 19 position 4 does not match the end tag of 'configuration'. Line 20, position 3. +``` -3. `--working-dir` is changed from an argument into an option. (Follow the example of Dotnet store command. It has -w|--working-dir <WORKING_DIRECTORY> option https://learn.microsoft.com/dotnet/core/tools/dotnet-store#optional-options). Any other thoughts? +2. Shall we use `dotnet nuget config get all` or `dotnet nuget config get` to get all configuration settings? +<br />We will use `dotnet nuget config get all` to get all configuration settings, or else, we could not differentiate `dotnet nuget config get <CONFIG_KEY>` and `dotnet nuget config get <WORKING_DIRECTORY>`. -4. To show configuration files locations, is it better to use `--verbosity` option or some option named like `--show-path`? (git command is using `--show-origin` for similar purpose) -5. `dotnet nuget config get <CONFIG_KEY>` will get the value of the specifc config key (which is aligned with NuGet config command). `dotnet nuget config get` will get all merged configuration settings(not XML format). Since many sections are not simple key-value pairs, we need to define the format of outputs when getting all merged configuration settings. We need to define formats for all kinds of config sections. Here is an example: +3. `dotnet nuget config get <CONFIG_KEY>` will get the value of the specific config key (which is aligned with NuGet config command). `dotnet nuget config get` will get all merged configuration settings(not XML format). Since many sections are not simple key-value pairs, we need to define the format of outputs when getting all merged configuration settings. We need to define formats for all kinds of config sections. Here is an example: ``` packageSources: clear @@ -349,14 +363,4 @@ packageSourceMapping: packageRestore: add key="enabled" value="False" add key="automatic" value="False" -``` - -## Considerations -1. Will this command help with diagnosing incorrect setting format? -<br />No. Incorrect NuGet settings should have seperate error/warning message to tell the customer what's wrong in the setting file. If we have incorrect NuGet settings, all NuGet command, including `dotnet nuget config` command, should display the same error/warning message. -<br />E.g. if we have an invalid XML problem in one of the NuGet configuration file, running all NuGet command will get an error as following: -``` -dotnet nuget list source -error: NuGet.Config is not valid XML. Path: 'C:\Users\username\Source\Repos\NuGet.Config'. -error: The 'disabledPackageSources' start tag on line 19 position 4 does not match the end tag of 'configuration'. Line 20, position 3. -``` +``` \ No newline at end of file From 160cda000b0cd6ab255ffcc6b12199f7403d2247 Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Mon, 12 Dec 2022 10:11:44 -0800 Subject: [PATCH 28/30] address feedbacks --- proposed/2022/dotnet-nuget-config-spec.md | 38 +++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index de6a868571..af6a2e4f6e 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -24,7 +24,7 @@ The following command will be implemented in the `dotnet.exe` CLI. ### Commands -### Path +### Paths List all the paths of NuGet configuration files that will be applied, when invoking NuGet command from the current working directory path. @@ -53,7 +53,7 @@ Prints out a description of how to use the command. - List all the NuGet configuration file that will be applied, when invoking NuGet command in the current directory. ``` -dotnet nuget config path +dotnet nuget config paths C:\Test\Repos\Solution\NuGet.Config C:\Test\Repos\NuGet.Config @@ -66,7 +66,7 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config - List all the paths of NuGet configuration files that will be applied, when invoking NuGet command in the specific directory. ``` -dotnet nuget config path C:\Test\Repos +dotnet nuget config paths C:\Test\Repos C:\Test\Repos\NuGet.Config C:\Test\NuGet.Config @@ -78,7 +78,7 @@ C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config - List all the NuGet configuration file that will be applied, but passing a non-existing argument `WORKING_DIRECTORY`. ``` -dotnet nuget config path C:\Test\NonExistingRepos +dotnet nuget config paths C:\Test\NonExistingRepos Error: The path "C:\Test\NonExistingRepos" doesn't exist. ``` @@ -88,7 +88,7 @@ Error: The path "C:\Test\NonExistingRepos" doesn't exist. The configuration file under C:\Test\AccessibleRepos\NotAccessibleSolution\NuGet.Config will be ignored without any warning or error. ``` -dotnet nuget config path C:\Test\AccessibleRepos\NotAccessibleSolution +dotnet nuget config paths C:\Test\AccessibleRepos\NotAccessibleSolution C:\Test\AccessibleRepos\NuGet.Config C:\Test\NuGet.Config @@ -131,11 +131,9 @@ If the specified `WORKING_DIRECTORY` doesn't exist, an error is displayed indica Prints out a description of how to use the command. -- -v|--verbosity <LEVEL> +- --show-path -Sets the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. The default is minimal. - -When the verbosity level is detailed or diagnostic, the source(NuGet configuration file path) will be show besides the configuration settings. +Indicate that the NuGet configuration file path will be show besides the configuration settings. #### Examples @@ -183,7 +181,7 @@ packageRestore: - Get all the NuGet configuration settings that will be applied, when invoking NuGet command in the current directory. Show the source(nuget configuration file path) of each configuration settings/child items. ``` -dotnet nuget config get all -v d +dotnet nuget config get all --show-path packageSources: add key="source1" value="https://test/source1/v3/index.json" file: C:\Test\Repos\Solution\NuGet.Config @@ -209,10 +207,10 @@ http://company-squid:3128@contoso.com" ``` -- Get `http_proxy` from config section, when invoking NuGet command in the current directory. Show the source(nuget configuration file path) of this configuration setting. +- Get `http_proxy` from config section, when invoking NuGet command in the current directory. Show the nuget configuration file path of this configuration setting. ``` -dotnet nuget config get http_proxy +dotnet nuget config get http_proxy --show-path http://company-squid:3128@contoso.com" file: C:\Test\Repos\Solution\NuGet.Config @@ -318,7 +316,7 @@ dotnet nuget config unset defaultPushSource --configfile C:\Users\username\AppDa ``` ## Future Work -1. The `dotnet nuget config path/get` is a community ask. We will discuss if adding this command into NuGet.exe CLI, in the future. +1. The `dotnet nuget config paths/get` is a community ask. We will discuss if adding this command into NuGet.exe CLI, in the future. 2. NuGet.exe [config command](https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-config) is implemented. But the behavior is confusing: the `set` command will set the property which appears last when loading(for all writable files), so it's not updating the closest NuGet configuration file, but the user-wide NuGet configuration file.(Related code: https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Configuration/Settings/Settings.cs#L229) @@ -327,12 +325,8 @@ But we might need to change this behavior in the future. Considering this will be a breaking change, we will only consider doing it in main version change, if there are enough votes. ## Open Questions -1. Shall we use `dotnet nuget config path` or `dotnet nuget config paths` to get all configuration file paths? - -2. `WORKING_DIRECTORY` is changed from an option to an argument. So we have `dotnet nuget config path <WORKING_DIRECTORY>` and `dotnet nuget config get <ALL|CONFIG_KEY> <WORKING_DIRECTORY>`. Is it okey if we have two arguments in the second command? And if it's key, only the second argument could be optional, right? - -3. To show configuration files locations, is it better to use `--verbosity` option or some option named like `--show-path`? (git command is using `--show-origin` for similar purpose) +1. `WORKING_DIRECTORY` is changed from an option to an argument. So we have `dotnet nuget config paths <WORKING_DIRECTORY>` and `dotnet nuget config get <ALL|CONFIG_KEY> <WORKING_DIRECTORY>`. Is it okey if we have two arguments in the second command? And if it's key, only the second argument could be optional, right? ## Considerations 1. Will this command help with diagnosing incorrect setting format? @@ -363,4 +357,10 @@ packageSourceMapping: packageRestore: add key="enabled" value="False" add key="automatic" value="False" -``` \ No newline at end of file +``` + +4. Shall we use `dotnet nuget config path` or `dotnet nuget config paths` to get all configuration file paths? +<br />Since it returns multiple paths, we will use `dotnet nuget config paths`. + +5. To show configuration files locations, is it better to use `--verbosity` option or some option named like `--show-path`? (git command is using `--show-origin` for similar purpose) +<br />`--show-path` is better. Verbosity is something to apply to logging, not so much the output of a command like this. Also in most cases of the .NET CLI, the verbosity doesn't do anything unless it's a command that ends up running MSBuild. \ No newline at end of file From 779cfc85bdff9887f47ae36d5705151667a80dcb Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Mon, 12 Dec 2022 10:18:48 -0800 Subject: [PATCH 29/30] fix a typo --- proposed/2022/dotnet-nuget-config-spec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index af6a2e4f6e..a18ca38a21 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -133,7 +133,7 @@ Prints out a description of how to use the command. - --show-path -Indicate that the NuGet configuration file path will be show besides the configuration settings. +Indicate that the NuGet configuration file path will be shown besides the configuration settings. #### Examples From 45f081f6198b6134066656a1ed230359e0e1dfcf Mon Sep 17 00:00:00 2001 From: Heng <liu.heng@microsoft.com> Date: Mon, 12 Dec 2022 12:10:52 -0800 Subject: [PATCH 30/30] address feedback --- proposed/2022/dotnet-nuget-config-spec.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/proposed/2022/dotnet-nuget-config-spec.md b/proposed/2022/dotnet-nuget-config-spec.md index a18ca38a21..5c9cf7bcfd 100644 --- a/proposed/2022/dotnet-nuget-config-spec.md +++ b/proposed/2022/dotnet-nuget-config-spec.md @@ -326,7 +326,6 @@ Considering this will be a breaking change, we will only consider doing it in ma ## Open Questions -1. `WORKING_DIRECTORY` is changed from an option to an argument. So we have `dotnet nuget config paths <WORKING_DIRECTORY>` and `dotnet nuget config get <ALL|CONFIG_KEY> <WORKING_DIRECTORY>`. Is it okey if we have two arguments in the second command? And if it's key, only the second argument could be optional, right? ## Considerations 1. Will this command help with diagnosing incorrect setting format? @@ -363,4 +362,8 @@ packageRestore: <br />Since it returns multiple paths, we will use `dotnet nuget config paths`. 5. To show configuration files locations, is it better to use `--verbosity` option or some option named like `--show-path`? (git command is using `--show-origin` for similar purpose) -<br />`--show-path` is better. Verbosity is something to apply to logging, not so much the output of a command like this. Also in most cases of the .NET CLI, the verbosity doesn't do anything unless it's a command that ends up running MSBuild. \ No newline at end of file +<br />`--show-path` is better. Verbosity is something to apply to logging, not so much the output of a command like this. Also in most cases of the .NET CLI, the verbosity doesn't do anything unless it's a command that ends up running MSBuild. + + +6. `WORKING_DIRECTORY` is changed from an option to an argument. So we have `dotnet nuget config paths <WORKING_DIRECTORY>` and `dotnet nuget config get <ALL|CONFIG_KEY> <WORKING_DIRECTORY>`. Is it okey if we have two arguments in the second command? And if it's okey, only the second argument could be optional, right? +<br /> Confirmed with .NET sdk folks. There is no problem of having two arguments in the command and the second argument could be optional. \ No newline at end of file