2016-06-22 51 views
1

我無法從asp.net核心Web應用程序(RC2)中的Visual Studio Team Services源中安裝/還原nuget包。我收到以下內容:使用asp.net核心rc2從Visual Studio Team Services獲取未授權的nuget包

error: Response status code does not indicate success: 401 (Unauthorized).

我在運行Visual Studio 2015年社區Update 2和的NuGet版本3.4.4。我可以在其他項目類型中安裝/恢復此源中的包。

我是否需要做其他事情才能將我的證書傳遞給一個asp.net核心Web應用程序?

重現步驟:

從Team Services包標籤我選擇 「連接到飼料」,並複製NuGet包的源地址

在Visual Studio中 - >工具 - > NuGet包管理器 - >軟件包管理器設置 - >打包源代碼並添加來自vso的源提要url

然後從我的ASP.NET Core Web應用程序(.NET Framework)項目中右鍵單擊引用 - (軟件包已列出) - >點擊並安裝

在輸出:

Installing NuGet package xxxxx 
Successfully installed xxxxx to WebApplication1 
========== Finished ========== 

然後,它會嘗試恢復在這一點上,我得到這個包:

error: Response status code does not indicate success: 401 (Unauthorized). 
error: Failed to retrieve information from remote source 

而且裏面的Web項目的引用 - 包已經警告圖標 - NU1001無法解析依賴關係xxxxx

+0

您是否從VS的右上角登錄您的VSTS帳戶?你能分享你的步驟來重現這個問題嗎? –

+0

@ Eddie-MSFT - 爲什麼要登錄?在NuGet上託管的Feed不需要任何授權。我寧願認爲這可能是一個代理需要授權的問題,在這種情況下登錄並不重要? @HPaxton - 如果您嘗試使用'dotnet restore'從命令行恢復,您是否看到相同的問題?你可以檢查併發布你正在使用的Feed嗎?如果你做了'dotnet restore',它會顯示最後使用的feed。 – Pawel

+0

@Pawel他/她使用的是一個私人飼料的視覺工作室在線飼料。 –

回答

3

我可以在我的身邊重現您的問題,以下是我使用恢復軟件包解決方法:

  1. 要從「VS \ Tools中VSTS飼料資源\ NuGet包管理器\包源」。
  2. 從VSTS門戶網站打開「軟件包」選項卡。
  3. 選擇要連接的饋送,然後點擊「連接到饋送」選項。
  4. 在對話框中選擇「個人訪問令牌」方法。
  5. 在對話框中複製生成的命令。
  6. 在您的機器上以管理員身份運行CMD。
  7. 將複製的命令粘貼到CMD中。
  8. 在命令後面添加「-StorePasswordInClearText」參數。
  9. 運行該命令。
  10. 重新啓動VS.
  11. 安裝和恢復軟件包。
+0

我有同樣的問題,所以我按照你的方式使用PAT代替。現在至少我得到了一個不同的錯誤,如下所示。 來源的密碼解密失敗: 'https://****.pkgs.visualstudio.com/_packaging/myfeed/nuget/v3/index.json'在此平臺上不受支持。可以使用明文密碼來代替。 – SamDevx

+0

@SamDevx檢查步驟8.我也得到了這個錯誤信息,沒有第8步。 –

+0

對不起,我的不好,現在有效。你的解決方法非常有用!這裏的關鍵是按照您的建議使用PAT,但使用-StorePasswordInClearText開關進行修改。我終於可以繼續這個項目了。但在某些時候,他們(nuget或.NET Core團隊)需要解決這個可怕的問題。 – SamDevx

1

我在VSTS構建定義的NuGet Restore任務中遇到類似問題(無身份驗證)。解決方案是在項目的根目錄中添加一個NuGet.config文件,並引用官方和我的自定義提要。也許它也可以幫助你的核心項目。

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 

    <packageSources> 
    <clear /> 
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> 
    <add key="RmlrTools" value="https://<MyProjectName>.pkgs.visualstudio.com/DefaultCollection/_packaging/<MyFeedName>/nuget/v3/index.json" /> 
    </packageSources> 
    <!-- used to store credentials --> 
    <packageSourceCredentials /> 
    <!-- Used to specify which one of the sources are active --> 
    <activePackageSource> 
    <!-- this tells only one given source is active --> 
    <add key="NuGet official package source" value="https://nuget.org/api/v2/" /> 
    <!-- this tells that all of them are active --> 
    <add key="All" value="(Aggregate source)" /> 
    </activePackageSource> 
    <!-- Used to disable package sources --> 
    <disabledPackageSources /> 
    <!-- 
    Used to specify default API key associated with sources. 
    See: NuGet.exe help setApiKey 
    See: NuGet.exe help push 
    See: NuGet.exe help mirror 
    --> 
    <!--<apikeys> 
    <add key="http://MyRepo/ES/api/v2/package" value="encrypted_api_key" /> 
    </apikeys>--> 
</configuration> 
1

此外,here是文檔顯示如何在「.NET Core」一節中執行此操作。

相關問題