Nuget.config 无论如何完全忽略
Nuget.config ignored completely no matter what
我想指定包在 nuget 恢复中的存储位置。当然,这在 MSDN 上有记录,当然,它永远行不通....
我在D:\Development\Test\Test.sln
中存储了一个测试解决方案
根据他们的 documentation,nuget 不再查找解决方案文件夹内的 .nuget 文件夹。相反,它现在会在解决方案文件夹中查找,或在链的更上层查找。所以我可以在
中存储一个 nuget.config
- D:\Development\Test\Nuget.Config
- D:\Development\Nuget.Config
- D:\Nuget.Config
好吧,我尝试了所有这三个,然后重新启动 Visual studio 次,我数不清了。
我还读到,他们在实施 nuget 时做得很糟糕,nuget.config 中的拼写错误导致默默地忽略了 nuget 文件。所以我想,一定是这样,我打错了。所以我下载了 nuget.exe(最新的稳定版 5.0.2)并发出了配置 nuget 的命令,将我的包放在我想要的位置。
nuget config -set repositoryPath=D:\Development\test\packages -configfile ..\nuget.config
这是 XML 的样子:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="D:\Development\test\packages" />
</config>
</configuration>
使用 nuget.exe 配置 Nuget.config 后,我再次尝试了之前的任何位置 (D:\;D:\Development\;D:Development\Test),重新启动 visual studio每次更改位置,richt点击解决方案,选择'restore nuget packages',同样的结果:零个包被恢复到我指定的仓库路径。
因此,作为最后一次尝试,我尝试从命令行进行 nuget 恢复:
D:\Development\test>nuget restore test.sln -ConfigFile ..\nuget.config
MSBuild auto-detection: using msbuild version '16.1.76.45076' from 'C:\Program Files (x86)\Microsoft Visual Studio19\Community\MSBuild\Current\bin'.
Restoring packages for D:\Development\test\test\test.csproj...
Restoring packages for D:\Development\test\ClassLibrary1\ClassLibrary1.csproj...
Committing restore...
Committing restore...
Generating MSBuild file D:\Development\test\ClassLibrary1\obj\ClassLibrary1.csproj.nuget.g.props.
Generating MSBuild file D:\Development\test\test\obj\test.csproj.nuget.g.props.
Writing assets file to disk. Path: D:\Development\test\ClassLibrary1\obj\project.assets.json
Writing assets file to disk. Path: D:\Development\test\test\obj\project.assets.json
Restore completed in 603,63 ms for D:\Development\test\ClassLibrary1\ClassLibrary1.csproj.
Restore completed in 603,6 ms for D:\Development\test\test\test.csproj.
NuGet Config files used:
D:\Development\nuget.config
它甚至提到它使用了我的 nuget.config,但同样,在我指定的包文件夹中恢复了零包!
我真的希望有人能告诉我这应该以什么神秘的方式起作用。
试试这个
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value=@"D:\Development\test\packages" />
</config>
</configuration>
存储在 E:
子文件夹中的这个 nuget.config
在 Visual Studio 2019 年对我有用,当我在该子文件夹或以下子文件夹中加载解决方案时:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="D:\NugetPackages" />
<add key="globalPackagesFolder" value="D:\NugetPackages" />
<add key="dependencyVersion" value="Highest" />
</config>
</configuration>
主要区别在于我还有一个指向同一文件夹的 globalPackagesFolder
条目 - 根据 the docs 此设置由 "projects using PackageReference only" 使用。我建议您尝试添加一个 globalPackagesFolder
条目。
我想指定包在 nuget 恢复中的存储位置。当然,这在 MSDN 上有记录,当然,它永远行不通....
我在D:\Development\Test\Test.sln
中存储了一个测试解决方案根据他们的 documentation,nuget 不再查找解决方案文件夹内的 .nuget 文件夹。相反,它现在会在解决方案文件夹中查找,或在链的更上层查找。所以我可以在
中存储一个 nuget.config- D:\Development\Test\Nuget.Config
- D:\Development\Nuget.Config
- D:\Nuget.Config
好吧,我尝试了所有这三个,然后重新启动 Visual studio 次,我数不清了。
我还读到,他们在实施 nuget 时做得很糟糕,nuget.config 中的拼写错误导致默默地忽略了 nuget 文件。所以我想,一定是这样,我打错了。所以我下载了 nuget.exe(最新的稳定版 5.0.2)并发出了配置 nuget 的命令,将我的包放在我想要的位置。
nuget config -set repositoryPath=D:\Development\test\packages -configfile ..\nuget.config
这是 XML 的样子:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="D:\Development\test\packages" />
</config>
</configuration>
使用 nuget.exe 配置 Nuget.config 后,我再次尝试了之前的任何位置 (D:\;D:\Development\;D:Development\Test),重新启动 visual studio每次更改位置,richt点击解决方案,选择'restore nuget packages',同样的结果:零个包被恢复到我指定的仓库路径。
因此,作为最后一次尝试,我尝试从命令行进行 nuget 恢复:
D:\Development\test>nuget restore test.sln -ConfigFile ..\nuget.config
MSBuild auto-detection: using msbuild version '16.1.76.45076' from 'C:\Program Files (x86)\Microsoft Visual Studio19\Community\MSBuild\Current\bin'.
Restoring packages for D:\Development\test\test\test.csproj...
Restoring packages for D:\Development\test\ClassLibrary1\ClassLibrary1.csproj...
Committing restore...
Committing restore...
Generating MSBuild file D:\Development\test\ClassLibrary1\obj\ClassLibrary1.csproj.nuget.g.props.
Generating MSBuild file D:\Development\test\test\obj\test.csproj.nuget.g.props.
Writing assets file to disk. Path: D:\Development\test\ClassLibrary1\obj\project.assets.json
Writing assets file to disk. Path: D:\Development\test\test\obj\project.assets.json
Restore completed in 603,63 ms for D:\Development\test\ClassLibrary1\ClassLibrary1.csproj.
Restore completed in 603,6 ms for D:\Development\test\test\test.csproj.
NuGet Config files used:
D:\Development\nuget.config
它甚至提到它使用了我的 nuget.config,但同样,在我指定的包文件夹中恢复了零包!
我真的希望有人能告诉我这应该以什么神秘的方式起作用。
试试这个
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value=@"D:\Development\test\packages" />
</config>
</configuration>
存储在 E:
子文件夹中的这个 nuget.config
在 Visual Studio 2019 年对我有用,当我在该子文件夹或以下子文件夹中加载解决方案时:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="D:\NugetPackages" />
<add key="globalPackagesFolder" value="D:\NugetPackages" />
<add key="dependencyVersion" value="Highest" />
</config>
</configuration>
主要区别在于我还有一个指向同一文件夹的 globalPackagesFolder
条目 - 根据 the docs 此设置由 "projects using PackageReference only" 使用。我建议您尝试添加一个 globalPackagesFolder
条目。