我有一个.Net Core 1.0类库,它使用在Visual Studio Team Services Nuget供稿中托管的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要求我们对其进行身份验证,这就是我们nuget.config
旁边还有project.json
个文件的原因:
<?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构建项目所缺少的部分。
答案 0 :(得分:3)
您可以参考此链接了解详情:.NET Core。
.NET Core目前不支持加密凭据。使用VSTS NuGet使用.NET Core应用程序提供,您需要指定一个 个人访问令牌,纯文本。
答案 1 :(得分:1)