简体   繁体   English

如何在nuget.config中设置相对路径?

[英]how to set relative path in nuget.config?

I currently have the following nuget.config file. 我目前有以下nuget.config文件。 With automatic package restore it will create a package folder that is one level up from my solution folder. 使用自动软件包还原,它将创建一个软件包文件夹,该文件夹比我的解决方案文件夹高一级。 For example if my solution folder is on my desktop, the package folder will be generated within a /lib folder on my desktop. 例如,如果我的解决方案文件夹在我的桌面上,则包文件夹将在我的桌面上的/lib文件夹内生成。 I would like for it to generate the /lib folder within my solution folder. 我希望它在我的解决方案文件夹中生成/lib文件夹。 How do I change the relative path to accomplish this? 如何更改相对路径以实现此目的?

<configuration>
  <solution>
    <add key="disableSourceControlIntegration"
      value="true" />
  </solution>
  <config>
    <add key="repositoryPath"
      value="../lib" />
  </config>
</configuration>

For example, 例如,

Bad: \\desktop\\lib\\ 错误:\\ desktop \\ lib \\

Good: \\desktop\\mysolution\\lib\\ 好:\\ desktop \\ mysolution \\ lib \\

I tried this: 我尝试了这个:

  <config>
    <add key="repositoryPath"
      value="/lib" />
  </config>

..and the package restore directory becomes c:\\lib which is unexpected behavior. ..,程序包还原目录变为c:\\lib ,这是意外行为。

另外,在该路径中使用“ lib”路径后,请确保将NuGet.Config文件添加到解决方案目录下。

I discovered that if I remove 我发现如果我删除

  <config>
    <add key="repositoryPath"
      value="../lib" />
  </config>

...from nuget.config ...来自nuget.config

Or 要么

if I complete delete nuget.config (and use all defaults) 如果我完成删除nuget.config (并使用所有默认值)

That the default behavior will be to create and add packages to this folder: 默认行为是创建软件包并将其添加到此文件夹:

\\desktop\\mysolution\\packages\\ \\ desktop \\ mysolution \\ packages \\

and while that is not named ' lib ' it hardly matters - my key issue was to get the packages in to the solution folder. 尽管它没有命名为' lib ',但这并不重要-我的关键问题是将软件包放入解决方案文件夹。

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

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