繁体   English   中英

无论如何,Nuget.config都完全忽略了

[英]Nuget.config ignored completely no matter what

我想指定在nuget还原中存储包的位置。 当然,这是在MSDN上记录的,当然,它永远不会工作....

我有一个存储在D:\\ Development \\ Test \\ Test.sln中的测试解决方案

根据他们的文档 ,nuget不再查找解决方案文件夹中的.nuget文件夹。 相反,它现在在解决方案文件夹中查找,或者在链中向上看。 所以我可以存储一个nuget.config

  • d:\\开发\\测试\\ Nuget.Config
  • d:\\开发\\ 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点击解决方案,选择'恢复nuget包',结果相同:零包恢复到我指定的存储库路径。

所以作为最后一次尝试,我尝试从命令行进行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 Studio\2019\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,但是再次,ZERO包恢复在我指定的包文件夹中!

我真的希望任何人都可以告诉我这应该是什么神秘的方式。

当我在该子文件夹或下面加载解决方案时,存储在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条目 - 根据文档 ,“仅使用PackageReference的项目”使用此设置。 我建议你尝试添加一个globalPackagesFolder条目。

尝试这个

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <config>
        <add key="repositoryPath" value=@"D:\Development\test\packages" />
    </config>
</configuration>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM