对于我的大多数项目,我有以下约定:
/src
/Solution.sln
/SolutionFolder
/Project1
/Project2
/etc..
/lib
/Moq
moq.dll
license.txt
/Yui-Compressor
yui.compressor.dll
/tools
/ILMerge
ilmerge.exe
您会注意到,我没有在源文件夹中保留外部库。我对使用NuGet也很感兴趣,但不希望在源文件夹内使用这些外部库。NuGet是否有一个设置来改变所有包加载到的目录?
为了改变项目的路径使用PackageReference而不是包。配置你需要使用globalPackagesFolder
从https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file
globalPackagesFolder (projects using PackageReference only)
The location of the default global packages folder. The default is
%userprofile%.nuget\packages (Windows) or ~/.nuget/packages
(Mac/Linux). A relative path can be used in project-specific
nuget.config files. This setting is overridden by the NUGET_PACKAGES
environment variable, which takes precedence.
repositoryPath (packages.config only)
The location in which to install NuGet packages instead of the default $(Solutiondir)/packages
folder. A relative path can be used in project-specific nuget.config
files. This setting is overridden by the NUGET_PACKAGES environment
variable, which takes precedence.
<config>
<add key="globalPackagesFolder" value="c:\packageReferences" />
<add key="repositoryPath" value="c:\packagesConfig" />
</config>
我放了Nuget。配置旁边的解决方案文件,它工作。