NuGet / Home

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

Multiple -ConfigFile Nuget.Config / misleading help text #6523

Open petsuter opened 6 years ago

petsuter commented 6 years ago

NuGet product used: NuGet.exe

NuGet version: 4.5.1.4879

OS version: win10 v1709 (16299.192)

nuget.exe help install shows:

-ConfigFile   The NuGet configuration file. If not specified, file %AppData%\NuGet\NuGet.config is used as configuration file.

But this help text is very misleading, as by default there are actually multiple Nuget.Config files that might be used. This help text does not mention them, nor that these other files are also skipped if the -ConfigFile option is specified.

Is it somehow possible to not skip them? Specifying -ConfigFile multiple times does not lead to an error, but the additional files seem to be silently ignored.

Is there a way to make nuget print the config files that are used? nuget.exe sources -Verbosity detailed does not show any information about that.

(This all gets very confusing when NuGet is run on a build server as a Windows Service, where %AppData%\NuGet\NuGet.config is actually C:\Windows\SysWOW64\config\systemprofile\AppData\Roaming\NuGet\NuGet.config, but edits to that file are redirected by Windows and hence ignored by Nuget.)

emgarten commented 6 years ago

It looks like the help in nuget.exe hasn't been updated since hierarchical config support was added. I'm marking this as up for grabs, it should be an easy fix to improve these strings.

michaeljohnstone commented 6 years ago

Thanks for posting this issue. I had exactly this problem where Nuget was "writing" to C:\Windows\SysWOW64\config\systemprofile\AppData\Roaming\NuGet\NuGet.config, but this was getting redirected by Windows. Took me hour to figure out what was going on.

donnie-msft commented 4 years ago

Hit this today. My repro:

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

Detailed repro steps so we can see the same problem

  1. Run nuget config -help

  2. Observe ConfigFile help text that says not specifying a file is supported:

-ConfigFile The NuGet configuration file. If specified, only the settings from this file will be use d. If not specified, the hierarchy of configuration files from the current directory will be used. To learn more about NuGet configuration go to https://docs.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior.

  1. Attempt to use the -configFile flag without a parameter. nuget config -configfile

  2. Observe an error message:

Missing option value for: '-configfile' NuGet.CommandLine.CommandLineException: Missing option value for: '-configfile' at NuGet.CommandLine.CommandLineParser.ExtractOptions(ICommand command, IEnumerator1 argsEnumerator) at NuGet.CommandLine.CommandLineParser.ParseCommandLine(IEnumerable1 commandLineArgs) at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)