简体   繁体   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

I have a .Net Core 1.0 class library that uses a Nuget package that is hosted in a Visual Studio Team Services Nuget feed. 我有一个.Net Core 1.0类库,它使用一个托管在Visual Studio Team Services Nuget feed中的Nuget包。

We use the Visual Studio Team Services to build the class library and have a build definition with a build step that does a dotnet restore on the project. 我们使用Visual Studio Team Services构建类库,并使用构建步骤构建定义,该构建步骤在项目上执行dotnet restore The command fails with the following errors: 该命令失败,并显示以下错误:

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).

Obviously it fails because FeedName requires that we authenticate to it, which is why we also have this nuget.config file alongside our project.json : 显然它失败了,因为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>

This works if we use the Nuget Installer build step, but with dotnet restore it does not. 如果我们使用Nuget安装程序构建步骤,这可以工作,但是使用dotnet restore它不会。

Please help, this is the missing part we need to continue using Visual Studio Team Services to build our projects. 请帮助,这是我们需要继续使用Visual Studio Team Services来构建我们的项目所缺少的部分。

You can refer to this link for details: .NET Core . 有关详细信息,请参阅此链接: .NET Core

.NET Core doesn't currently support encrypted credentials. .NET Core目前不支持加密凭据。 To use VSTS NuGet feeds with .NET Core applications, you'll need to specify a Personal Access Token in plain text. 要将VSTS NuGet源与.NET Core应用程序一起使用,您需要以纯文本格式指定个人访问令牌。

You can now use a dotnet core build step to restore, build, test, and run other custom dotnet command. 您现在可以使用dotnet核心构建步骤来还原,构建,测试和运行其他自定义dotnet命令。

在此输入图像描述

Below are all the commands available to use 以下是可以使用的所有命令

在此输入图像描述

Selecting restore command will enable you to select nuget package source as shown below. 选择restore命令将允许您选择nuget包源,如下所示。

在此输入图像描述

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

相关问题 使用 Visual Studio 2017 构建 Docker 失败,因为使用私有 nuget 源在 dotnet 还原期间超时 - Docker build with Visual Studio 2017 failed because timeout during dotnet restore using private nuget feed 如何使用Private Linux Hosted Build Agent从VSTS进行Dotnet发布? - How to Dotnet Publish from VSTS with Private Linux Hosted Build Agent? 在Visual Studio Team Services构建步骤中选择Nuget Packager版本 - Choose Nuget Packager version in Visual Studio Team Services build step Visual Studio Team Services - 等待可用的代理 - Visual Studio Team Services - Waiting for an available agent 使用私有NuGet提要(VSTS CI Build),.NET Core NuGet还原失败 - .NET Core NuGet restore fails with private NuGet feed (VSTS CI Build) Visual Studio Team Services生成程序包还原因project.json netstandard1.0目标而失败 - Visual Studio Team Services Build Package Restore failing with project.json netstandard1.0 target 如何将“dotnet restore”与需要进行身份验证的提要一起使用? - How to use 'dotnet restore' with a feed that need to authenticate with? 如何在Visual Studio Team Services中发布和访问nuget包 - How can I publish and access nuget packages within Visual Studio Team Services 如何恢复 Visual Studio nuget 包? - How to restore visual studio nuget packages? 如何将Visual Studio代码连接到Visual Studio Team Services - How to connect Visual Studio Code to Visual Studio Team Services
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM