2017-06-19 56 views
0

出於某種原因,我必須使用構建代理「Hosted Linux Preview」,因此我只能使用「dotnet restore」而不是「nuget restore」,現在我們的團隊已經在VSTS上構建了內部包服務器。如何使用VSTS構建代理「託管Linux預覽」來使用VSTS內部包服務器?

在「nuget restore」步驟中,可以選擇連接到服務器,但「dotnet restore」不會。

我嘗試了以下方法,但失敗了。

嘗試1添加--source https://****.pkgs.visualstudio.com/_packaging/****/nuget/v3/index.json,我在日誌中遇到錯誤:error : Unable to load the service index for source https://****.pkgs.visualstudio.com/_packaging/****/nuget/v3/index.json. [/opt/vsts/work/1/s/src/References.Mapper/References.Mapper.csproj]

嘗試2添加--configfile ../../.nuget/Nuget.Config,我得到了同樣的錯誤如上

看來,構建代理沒有授權從VSTS中檢索index.json文件,我該如何繼續?

回答

0

檢查鏈接Use dotnet with Team Services feeds後,現在我可以成功地使用該提要。

步驟:

  1. 確保飼料的權限被正確地分配(去VSTS>構建&發佈>軟件包>管理/設置>權限)
  2. 添加PAT的帳戶(去個人設置/我的個人資料>安全>個人訪問令牌>添加「VSTS-Nuget-Packaging」(或您的姓名),允許打包(讀取,寫入和管理)>保留憑證
  3. 修改Nuget。配置如下
  4. 設置在VSTS生成步驟 「DOTNET還原」,在 「參數」 添加 --configfile ../../.nuget/NuGet.Config(位置)(注意名稱是區分靈敏)

Nuget.Config樣本:

<?xml version="1.0" encoding="utf-8"?> 
    <configuration> 
     <packageSources> 
     <add key="VSTS-Package" value="[feed url]" /> 
     <add key="Nuget.org" value="https://www.nuget.org/api/v2/" /> 
     </packageSources> 
     <activePackageSource> 
     <add key="All" value="(Aggregate source)" /> 
     </activePackageSource> 
     <packageSourceCredentials> 
     <VSTS-Package> 
      <add key="Username" value="[username]" /> 
      <add key="ClearTextPassword" value="[PAT]" /> 
     </VSTS-Package> 
     </packageSourceCredentials> 
    </configuration> 
+0

@ starain-MSFT :)是的 – Elaine