2017-02-13 81 views
1

我在Ubuntu 14.04上運行.NET Core 1.1.0,目標是在Ubuntu的Docker中託管我的Web API。我想在Ubuntu上構建我的包,但是一些NuGet引用託管在內部NuGet存儲庫(Artifactory)上。之後我添加了包源此工程在Windows VS2015很好,但是當我運行:如何在Ubuntu 14.04上使用dotnet CLI註冊新的NuGet包源代碼?

dotnet restore 

在Ubuntu上,託管在公衆的NuGet回購下載精美的包裝,但那些Artifactory的失敗:

error: Unable to resolve 'Mercury.BaseModel (>= 1.1.0)' for '.NETCoreApp,Version=v1.1'. 

我發現的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> 

,但我仍然得到同樣的錯誤。

安裝.NET Core SDK後,NuGet本身無法工作,我正在使用dotnet restore - 我是否有類似的配置,我必須爲dotnet CLI(必須使用NuGet?)編輯或者是否有其他需要去做?

謝謝!

回答

2

畢竟,我很快確定了2個問題,我已經錯過了:

  1. 我用了sudo -i以root身份運行試圖解決這個問題,因爲其結果是的NuGet配置我安裝在我的\ home文件夾沒有被拾起。
  2. 移動回自己的登錄,然後我得到了一個錯誤:

    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. 
    

事實證明,我們的Artifactory的回購的NuGet返回XML是的NuGet V2標準。我改變了配置文件,將repo設置爲v2,現在它正在工作。所以,從上面,編輯該文件在

\home\<user>\.nuget\NuGet\NuGet.Config 

增加新的回購協議的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> 
+1

您也可能會發現添加的NuGet包有幫助的新DOTNET CLI支持: http://ardalis.com/how-to-add-a-nuget-package-using-dotnet-add – ssmith

+0

這是值得的知道,雖然在這裏我問的是添加一個新的包源代碼;我可以看到自己使用dotnet add,謝謝。 – Peter

+0

啊,好點。對不起,誤解了。 :) – ssmith