Opo*_*sse 12 visual-studio nuget nuget-server
我的工作有私人NuGet回购.我可以从它和nuget.org安装软件包.当私有仓库中存储了一个依赖于nuget.org托管的软件包的软件包时,我遇到了问题.
例如,我的私人仓库托管了一个包P1.P1依赖于P2,它托管在nuget.org上.如果使用我的私人仓库作为源进行"安装包P1",我将收到一条错误消息,说它无法找到依赖关系P2.这是有道理的,因为它在私人仓库中寻找P2,但它在nuget.org上托管.到目前为止,解决方法是从nuget.org安装P2,然后从私人仓库安装P1.虽然这在技术上是有效的,但是很难将NuGet卖给团队的其他成员.
无论如何我可以运行具有多个源的安装包吗?我已经尝试将列表传递给-Source参数,但到目前为止已经得到了
NuGet.config由visual studio管理,因此每次在Visual Studio中运行nuget命令时,我对其所做的任何更改都将被删除.我尝试在解决方案级别添加一个额外的nuget.config文件,但据我所知,它被忽略了.我已经尝试了几次install = package命令的访问,但它们通常看起来像这样:
Install-Package P1 -Source https://api.nuget.org/v3/index.json,http://privatefeed.com
Run Code Online (Sandbox Code Playgroud)
这里是NuGet.config文件的参考,但改变它似乎是徒劳的.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Private Nuget" value="http://privatefeed.com" />
</packageSources>
<disabledPackageSources>
<add key="Microsoft and .NET" value="true" />
</disabledPackageSources>
<activePackageSource>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</activePackageSource>
</configuration>
Run Code Online (Sandbox Code Playgroud)
使用NuGet.exe,您可以重复执行 -Source
选项以指定多个程序包源。
例:
nuget install P1 -Source https://api.nuget.org/v3/index.json -Source http://privatefeed.com
Run Code Online (Sandbox Code Playgroud)
似乎不可能使用Package Manage Console(PowerShell)指定多个源。但是,如果未-Source
指定,则使用NuGet.Config文件。配置文件可以具有多个软件包源,并且文件本身可以与团队共享。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Private Nuget" value="http://privatefeed.com" />
</packageSources>
</configuration>
Run Code Online (Sandbox Code Playgroud)
在解决方案所在的目录中另存为NuGet.Config,并将其添加到版本控制中。
请注意,您可能必须重新加载Visual Studio才能使配置更改生效。
现在,您无需配置即可安装软件包-Source
。
例:
Install-Package P1
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3521 次 |
最近记录: |