4
votes

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.

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

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

Please help, this is the missing part we need to continue using Visual Studio Team Services to build our projects.

2

2 Answers

4
votes

You can refer to this link for details: .NET Core.

.NET Core doesn't currently support encrypted credentials. To use VSTS NuGet feeds with .NET Core applications, you'll need to specify a Personal Access Token in plain text.

1
votes

You can now use a dotnet core build step to restore, build, test, and run other custom dotnet command.

enter image description here

Below are all the commands available to use

enter image description here

Selecting restore command will enable you to select nuget package source as shown below.

enter image description here