繁体   English   中英

如何使用VSTS Nuget提要在Visual Studio Team Services托管构建代理上使用dotnet还原

[英]How to use dotnet restore on Visual Studio Team Services Hosted Build Agent with VSTS Nuget feed

我有一个.Net Core 1.0类库,它使用一个托管在Visual Studio Team Services Nuget feed中的Nuget包。

我们使用Visual Studio Team Services构建类库,并使用构建步骤构建定义,该构建步骤在项目上执行dotnet restore 该命令失败,并显示以下错误:

2016-06-28T13:07:09.0634265Z ##[warning]File name doesn't indicate a full path to a executable file.
2016-06-28T13:07:09.0644179Z Executing the following command-line. (workingFolder = C:\a\1\s)
2016-06-28T13:07:09.0644179Z dotnet restore
2016-06-28T13:07:09.0654186Z Error message highlight pattern: 
2016-06-28T13:07:09.0654186Z Warning message highlight pattern: 
2016-06-28T13:07:11.6393062Z log  : Restoring packages for C:\a\1\s\src\Company.Extensions\project.json...
2016-06-28T13:07:11.7623059Z info :   GET https://Company.pkgs.visualstudio.com/DefaultCollection/_packaging/FeedName/nuget/v2/FindPackagesById()?id='Company.Model'
2016-06-28T13:07:11.8463064Z info :   GET https://api.nuget.org/v3-flatcontainer/Company.model/index.json
2016-06-28T13:07:12.0162954Z info :   Unauthorized https://Company.pkgs.visualstudio.com/DefaultCollection/_packaging/FeedName/nuget/v2/FindPackagesById()?id='Company.Model' 254ms
2016-06-28T13:07:12.0702952Z log  : Retrying 'FindPackagesByIdAsyncCore' for source 'https://Company.pkgs.visualstudio.com/DefaultCollection/_packaging/FeedName/nuget/v2/FindPackagesById()?id='Company.Model''.
2016-06-28T13:07:12.0712954Z log  : Response status code does not indicate success: 401 (Unauthorized).
2016-06-28T13:07:12.0712954Z info :   GET https://Company.pkgs.visualstudio.com/DefaultCollection/_packaging/FeedName/nuget/v2/FindPackagesById()?id='Company.Model'
2016-06-28T13:07:12.0722952Z info :   NotFound https://api.nuget.org/v3-flatcontainer/Company.model/index.json 224ms
2016-06-28T13:07:12.1426754Z info :   Unauthorized https://Company.pkgs.visualstudio.com/DefaultCollection/_packaging/FeedName/nuget/v2/FindPackagesById()?id='Company.Model' 73ms
2016-06-28T13:07:12.1436737Z log  : Retrying 'FindPackagesByIdAsyncCore' for source 'https://Company.pkgs.visualstudio.com/DefaultCollection/_packaging/FeedName/nuget/v2/FindPackagesById()?id='Company.Model''.
2016-06-28T13:07:12.1436737Z log  : Response status code does not indicate success: 401 (Unauthorized).
2016-06-28T13:07:12.1446974Z info :   GET https://Company.pkgs.visualstudio.com/DefaultCollection/_packaging/FeedName/nuget/v2/FindPackagesById()?id='Company.Model'
2016-06-28T13:07:12.2162787Z info :   Unauthorized https://Company.pkgs.visualstudio.com/DefaultCollection/_packaging/FeedName/nuget/v2/FindPackagesById()?id='Company.Model' 72ms
2016-06-28T13:07:12.2172786Z error: Failed to retrieve information from remote source 'https://Company.pkgs.visualstudio.com/DefaultCollection/_packaging/FeedName/nuget/v2/FindPackagesById()?id='Company.Model''.
2016-06-28T13:07:12.2172786Z error: Response status code does not indicate success: 401 (Unauthorized).
2016-06-28T13:07:12.2364584Z error: Failed to retrieve information from remote source 'https://Company.pkgs.visualstudio.com/DefaultCollection/_packaging/FeedName/nuget/v2/FindPackagesById()?id='Company.Model''.
2016-06-28T13:07:12.2374607Z error:   Response status code does not indicate success: 401 (Unauthorized).

显然它失败了,因为FeedName要求我们对它进行身份验证,这就是为什么我们在project.json旁边也有这个nuget.config文件:

<?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="nuget.org" value="https://www.nuget.org/api/v2/" />
    <add key="FeedName" value="https://Company.pkgs.visualstudio.com/DefaultCollection/_packaging/FeedName/nuget/v2" />
  </packageSources>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
  <bindingRedirects>
    <add key="skip" value="False" />
  </bindingRedirects>
  <FeedName>
    <add key="Username" value="username" />
    <add key="ClearTextPassword" value="the_actual_clear_text_password" />
  </FeedName>
</configuration>

如果我们使用Nuget安装程序构建步骤,这可以工作,但是使用dotnet restore它不会。

请帮助,这是我们需要继续使用Visual Studio Team Services来构建我们的项目所缺少的部分。

有关详细信息,请参阅此链接: .NET Core

.NET Core目前不支持加密凭据。 要将VSTS NuGet源与.NET Core应用程序一起使用,您需要以纯文本格式指定个人访问令牌。

您现在可以使用dotnet核心构建步骤来还原,构建,测试和运行其他自定义dotnet命令。

在此输入图像描述

以下是可以使用的所有命令

在此输入图像描述

选择restore命令将允许您选择nuget包源,如下所示。

在此输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM