且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

NuGet 包还原无法使用自定义源提示输入凭据

更新时间:2022-06-03 05:05:59

我现在有这个工作.这就是我为使其正常工作所做的工作.首先,出现命令:

I have this working now. This is what I did to get to get it to work. First, it appears the command:

NuGet.exe source Update -Name {feedname} -UserName {myusername} -Password {mypassword}

是正确的方法.需要注意的是,当您运行nuget.exe 源更新"命令时,nuget.exe 将在与正在执行的 nuget.exe 相同的目录中查找 NuGet.config 文件(如果它存在).如果它存在,它会将更改存储在那里.如果它存在,它会将更改存储在位于 %AppData%\NuGet 目录中的 NuGet.config 文件中.

IS the right way to go about it. The caveat is that, when your run the "nuget.exe source Update" command, nuget.exe will look for a NuGet.config file in the same directory as the nuget.exe being executed if it exists. IF it exists, it will store the changes there. If it does NOT exist, it will store the changes in the NuGet.config file located in the %AppData%\NuGet directory.

额外的警告是,当包还原作为构建的一部分执行时,它查看 %AppData%\NuGet 目录中的 NuGet.config 文件并忽略 NuGet.config正在执行的 nuget.exe 所在目录中的文件(我不确定这是错误还是故意的).

The additional caveat is that, when Package Restore gets executed as part of the build, it only looks at the NuGet.config file in the %AppData%\NuGet directory and ignores the NuGet.config file that is in the same directory of the nuget.exe being executed (I'm unsure if this is a bug or intentional).

因此,您应该使用位于没有 NuGet.config 文件的目录中的 nuget.exe 运行此命令,以确保将更改存储在正确的 NuGet.config 中%AppData%\NuGet 目录中的文件.

So, you should run this command using a nuget.exe that is in a directory that does not have a NuGet.config file in it to ensure the changes get stored in the correct NuGet.config file in the %AppData%\NuGet directory.