Pet*_*ter 20 nuget docker ubuntu-14.04 .net-core asp.net-core
我在Ubuntu 14.04上运行.NET Core 1.1.0,目标是在Ubuntu上的Docker中托管我的Web API.我想在Ubuntu上构建我的包,但是一些NuGet引用托管在内部NuGet存储库(Artifactory)上.添加包源后,这在Windows上的VS2015中工作正常,但是当我运行时:
dotnet restore
Run Code Online (Sandbox Code Playgroud)
在Ubuntu上,公共NuGet repo下载的软件包下载很好,但Artifactory上的软件包失败:
error: Unable to resolve 'Mercury.BaseModel (>= 1.1.0)' for '.NETCoreApp,Version=v1.1'.
Run Code Online (Sandbox Code Playgroud)
我找到了一个NuGet配置文件\home\<user>\.nuget\NuGet\NuGet.Config并添加了Artifactory存储库,如下所示:
<?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="Artifactory-DEV" value="https://theluggage-agct.gray.net/artifactory/api/nuget/nuget-institutional-development-local" protocolVersion="3"/>
</packageSources>
</configuration>
Run Code Online (Sandbox Code Playgroud)
但我仍然得到同样的错误.
安装.NET Core SDK之后NuGet本身不起作用,我正在使用dotnet restore如上所述 - 我是否必须为dotnet CLI编写类似的配置(必须使用NuGet?)或者还有其他我需要做的事情吗?
谢谢!
小智 12
Dotnet CLI还原可以使用-s作为源提要URL,因此,如果您具有带nuget.org远程存储库的Artifactory。
dotnet restore -s https://artifactory.example.com/api/nuget/nuget.org
Run Code Online (Sandbox Code Playgroud)
参考:
https://docs.microsoft.com/zh-cn/dotnet/core/tools/dotnet-restore?tabs=netcore2x
https://www.jfrog.com/confluence/display/RTF/NuGet+Repositories
Pet*_*ter 11
毕竟,我很快发现了我错过的两个问题:
sudo -i以root身份运行试图解决问题,因此我在\ home文件夹中设置的NuGet配置没有被选中.回到我自己的登录,然后我收到一个错误:
error: Unable to load the service index for source https://theluggage-agct.gray.net/artifactory/api/nuget/nuget-institutional-development-local.
error: The content at 'https://theluggage-agct.gray.net/artifactory/api/nuget/nuget-institutional-development-local' is not a valid JSON object.
error: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
Run Code Online (Sandbox Code Playgroud)事实证明,我们的Artifactory NuGet repo返回符合NuGet v2的XML.我更改了配置文件,将repo设置为v2,现在正在运行.因此,从上面编辑文件
\home\<user>\.nuget\NuGet\NuGet.Config
Run Code Online (Sandbox Code Playgroud)
添加新的repo URL,并获得正确的版本设置:
<?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="Artifactory-DEV" value="https://theluggage-agct.gray.net/artifactory/api/nuget/nuget-institutional-development-local" protocolVersion="2"/>
</packageSources>
</configuration>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15554 次 |
| 最近记录: |