Search code examples
azure-devopsnugetartifactory

How to configure TFS2018 build vb.net with Nuget dependencies in Artifactory


I am trying to configure a VB.Net project that has a reference to NuGet package that is stored in our Artifactory repository. I am trying to configure a build in TFS 2018 and I think that there maybe several ways to configure the build in TFS.

I used the .net desktop app template and then modified it. I have it configured as Use NuGet 4.4.1 NuGet restore Build Solution Publish Symbols Copy Files to …. Publish Artifact: drop enter image description here

It’s failing at the NuGet restore: The nuget command failed with exit code(1) and error(Errors in packages.config projects Processed: ##vso[task.issue type=error;]The nuget command failed with exit code(1) and error(Errors in packages.config projects%0D%0A Unable to find version '1.0.8' of package 'WPSArchiver-AnyCPU'.%0D%0A C:\Users\TFSBuild1_SVCACCT.nuget\packages: Package 'WPSArchiver-AnyCPU.1.0.8' is not found on source 'C:\Users\TFSBuild1_SVCACCT.nuget\packages\'.%0D%0A https://api.nuget.org/v3/index.json: Package 'WPSArchiver-AnyCPU.1.0.8' is not found on source 'https://api.nuget.org/v3/index.json'.%0D%0A https://xxxxxxxxx.yyyy.com:8443/artifactory/api/nuget/wps-csat-nuget-local: The V2 feed at 'https:// xxxxxxxxx.yyyy.com:8443/artifactory/api/nuget/wps-csat-nuget-local/Packages(Id='WPSArchiver-AnyCPU',Version='1.0.8')' returned an unexpected status code '401 Unauthorized'.) task result: Failed Packages failed to restore

So it looks like it does try to access our local instance of Artifactory, but it is getting a '401 Unauthorized' enter image description here As you can see in the image above I created a “Credentials for feeds…” For this I created a Nuget authentication

Should I use different build steps? How can I troubleshoot the authentication request. I know that the account that I am using is valid.


Solution

  • It looks like the Feed URL in above service connection for local Artifactory server is not complete. The source URL pointing to Artifactory should be like this http://severname:8081/artifactory/api/nuget/<repository key>.

    In your case you can try changing the Feed URL in above screen to https://xxxxxxxxx.yyyy.com:8443/artifactory/api/nuget/wps-csat-nuget-local

    The Feed URL should be the same with the packageSources you defined in nuget.config file.

    You can modify the setting for Credentials for feeds in the Service connection section of in project settings.

    Project settings--> Service connections under Pipelines-->Select your connection(CSAT Artifactory)--> Update the Feed URL.

    If it is still not able to authenticate, you can try using the API Key for the Password field of the artifactory connection.

    Hope above help!