对于我的大多数项目,我有以下约定:
/src
/Solution.sln
/SolutionFolder
/Project1
/Project2
/etc..
/lib
/Moq
moq.dll
license.txt
/Yui-Compressor
yui.compressor.dll
/tools
/ILMerge
ilmerge.exe
您会注意到,我没有在源文件夹中保留外部库。我对使用NuGet也很感兴趣,但不希望在源文件夹内使用这些外部库。NuGet是否有一个设置来改变所有包加载到的目录?
这些答案都不适合我(Nuget 2.8.6),因为缺少一些提示,我会尝试在这里添加它们,因为它可能对其他人有用。
阅读以下资料后:
https://docs.nuget.org/consume/NuGet-Config-Settings
https://github.com/NuGet/Home/issues/1346
看来
To make working Install-Package properly with different
repositoryPath you need to use forward slashes, it's because they are using Uri object to parse location.
Without $ on the begining it was still ignoring my settings.
NuGet caches config file, so after modifications you need to reload solution/VS.
I had also strange issue while using command of NuGet.exe to set this option, as it modified my global NuGet.exe under AppData\Roaming\NuGet and started to restore packages there (Since that file has higher priority, just guessing).
如。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<config>
<add key="repositorypath" value="$/../../../Common/packages" />
</config>
</configuration>
你也可以使用NuGet命令来确保语法是正确的,就像这样:
NuGet.exe config -Set repositoryPath=$/../../../Common/packages -ConfigFile NuGet.Config