Ume*_*dam 5 nuget nuget-package-restore
我有目录结构,如 -
Projects
.nuget
NuGet.exe
NuGet.config
NuGet.targets
**packages (I want to download package for different solution HERE ONLY)**
Sources
Applications
App1
App1.sln (Solution File)
**packages (NuGet downloads packages here first then copies to expected folder, WHY??)**
App1 (Porject Directory)
App1.csproj
App2
App2.sln (Solution File)
**packages (NuGet downloads packages here first then copies to expected folder, WHY??)**
App2 (Porject Directory)
App2.csproj
Run Code Online (Sandbox Code Playgroud)
我使用以下代码在每个解决方案中引用了.nuget文件夹
Project("{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}") = ".nuget", ".nuget", "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx}"
ProjectSection(SolutionItems) = preProject
..\..\..\.nuget\NuGet.Config = ..\..\..\.nuget\NuGet.Config
..\..\..\.nuget\NuGet.exe = ..\..\..\.nuget\NuGet.exe
..\..\..\.nuget\NuGet.targets = ..\..\..\.nuget\NuGet.targets
EndProjectSection
EndProject
Run Code Online (Sandbox Code Playgroud)
在每个项目文件(.csproj)中,我引用了常见的NuGet.targets,
<Import Project="..\..\..\..\.nuget\NuGet.targets" Condition="Exists('..\..\..\..\.nuget\NuGet.targets')" />
Run Code Online (Sandbox Code Playgroud)
在NuGet.config中,我添加了以下行,以便它(必须)仅在EXPECTED文件夹中复制包
<add key="repositoryPath" value="..\packages" />
Run Code Online (Sandbox Code Playgroud)
我已经使用TFS 映射了Projects文件夹,并且由于上述问题,它要求我在这两个位置添加文件
NuGet 将根据当前解决方案的目录查找NuGet.config 文件。
因此,如果 Projects 目录位于 c:\Projects 中,那么采用 App1 解决方案时,您的 App1.sln 文件将位于 c:\Projects\Sources\Applications\App1 目录中。现在 NuGet 将在以下位置查找 NuGet.config 目录:
c:\Projects\Sources\Applications\App1\.nuget\NuGet.Config
c:\Projects\Sources\Applications\App1\NuGet.Config
c:\Projects\Sources\Applications\NuGet.Config
c:\Projects\Sources\NuGet.Config
c:\Projects\NuGet.Config
c:\NuGet.Config
Run Code Online (Sandbox Code Playgroud)
之后,它会在机器范围内查找,但我现在会忽略这些。
查看您的目录结构,NuGet 将不会检查 Projects.nuget 目录。它不是任何解决方案目录的父级。
我会考虑将带有repositoryPath 设置的NuGet.Config 文件放在Sources 目录或Projects 目录中(而不是在.nuget 目录中)。或者有两个 NuGet.Config 文件,一个位于 App1.nuget 目录中,一个位于 App2.nuget 目录中。
| 归档时间: |
|
| 查看次数: |
154 次 |
| 最近记录: |