2017-06-19 97 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