[英]Nuget.config ignored completely no matter what
我想指定在nuget還原中存儲包的位置。 當然,這是在MSDN上記錄的,當然,它永遠不會工作....
我有一個存儲在D:\\ Development \\ Test \\ Test.sln中的測試解決方案
根據他們的文檔 ,nuget不再查找解決方案文件夾中的.nuget文件夾。 相反,它現在在解決方案文件夾中查找,或者在鏈中向上看。 所以我可以存儲一個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.