我正在Ubuntu 14.04上运行.NET Core 1.1.0,目标是将Web API托管在Ubuntu上的Docker中。我想在Ubuntu上构建我的软件包,但某些NuGet引用托管在内部NuGet存储库(Artifactory)上。添加程序包源后,此方法在Windows上的VS2015中运行良好,但是在运行时:
I am running .NET Core 1.1.0 on Ubuntu 14.04, with the goal of hosting my Web APIs in Docker on Ubuntu. I want to build my packages on Ubuntu, but some of the NuGet references are hosted on an internal NuGet repository (Artifactory). This works fine in VS2015 on Windows after I add the package source, but when I run:
dotnet restore在Ubuntu上,托管在公共NuGet repo上的软件包可以很好地下载,但是Artifactory上的软件包失败:
on Ubuntu, the packages hosted on the public NuGet repo download fine, but those on Artifactory fail:
error: Unable to resolve 'Mercury.BaseModel (>= 1.1.0)' for '.NETCoreApp,Version=v1.1'.我在 \home\< user>>找到了一个NuGet配置文件; \.nuget\NuGet\NuGet.Config 并添加Artifactory存储库,如下所示:
I found a NuGet config file at \home\<user>\.nuget\NuGet\NuGet.Config and added the Artifactory repository as follows:
<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="nuget" value="api.nuget/v3/index.json" protocolVersion="3" /> <add key="Artifactory-DEV" value="theluggage-agct.gray/artifactory/api/nuget/nuget-institutional-development-local" protocolVersion="3"/> </packageSources> </configuration>但我仍然遇到相同的错误。
but I am still getting the same error.
在安装.NET Core SDK后,NuGet本身不起作用,我使用的是 dotnet restore -是否有类似的配置我必须为dotnet CLI编辑(必须使用NuGet吗?)还是我需要做其他事情?
NuGet itself does not work after installing the .NET Core SDK, I am using dotnet restore as mentioned - is there similar config I must edit for the dotnet CLI (which must be using NuGet?) or is there something else I need to do?
谢谢!
推荐答案毕竟,我很快发现了两个我错过的问题:
After all that I quickly identified 2 problems I had missed:
回到我自己的登录,然后出现错误:
Moving back to my own logon, I then got an error: error: Unable to load the service index for source theluggage-agct.gray/artifactory/api/nuget/nuget-institutional-development-local. error: The content at 'theluggage-agct.gray/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.
结果是我们的Artifactory NuGet回购返回的XML符合NuGet v2。我更改了配置文件,将存储库设置为v2,现在可以正常工作了。因此,从上方在
Turns out that our Artifactory NuGet repo returns XML which is NuGet v2 compliant. I changed the config file to set the repo as v2 and it is now working. So, from above, edit the file at
\home\<user>\.nuget\NuGet\NuGet.Config添加新的回购URL,并正确获取版本设置:
adding your new repo URL, and get the version setting right:
<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="nuget" value="api.nuget/v3/index.json" protocolVersion="3" /> <add key="Artifactory-DEV" value="theluggage-agct.gray/artifactory/api/nuget/nuget-institutional-development-local" protocolVersion="2"/> </packageSources> </configuration>更多推荐
如何在Ubuntu 14.04上使用dotnet CLI注册新的NuGet软件包源?
发布评论