[英]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.