【问题标题】:How to consume VSTS internal package server with VSTS build agent "Hosted Linux Preview"?如何使用 VSTS 构建代理“Hosted Linux Preview”使用 VSTS 内部包服务器?
【发布时间】:2017-06-19 10:22:08
【问题描述】:

由于某种原因,我必须使用构建代理“Hosted Linux Preview”,所以我只能使用“dotnet restore”而不是“nuget restore”,而现在我们的团队有基于 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 文件的权限,我该如何处理?

【问题讨论】:

    标签: azure-pipelines nuget-server azure-pipelines-build-task dotnet-restore


    【解决方案1】:

    查看Use dotnet with Team Services feeds链接后,现在可以成功消费feed了。

    步骤:

    1. 确保已正确分配提要的权限(转到 VSTS > 构建和发布 > 包 > 管理/设置 > 权限)
    2. 向帐户添加 PAT(转到个人设置/我的个人资料 > 安全 > 个人访问令牌 > 添加“VSTS-Nuget-Packaging”(或您自己命名),允许打包(读取、写入和管理)>记下凭证
    3. 修改 Nuget.Config 如下
    4. 在 VSTS 构建步骤“dotnet restore”中设置,添加一个 --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>
    

    【讨论】:

    • @starain-MSFT :) 是的
    猜你喜欢
    • 2018-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-26
    • 1970-01-01
    • 1970-01-01
    • 2018-08-14
    相关资源
    最近更新 更多