Wednesday, May 20, 2020

Unable to restore organization's internal nuget package in devops

My company has its own nuget feed and we were facing issues while using packages in the feed in other repositories.

 

To be able to build such a project on devops, several configurations are required.

 

1.      Nuget Feed Configurations

a.       Allow collection scoped builds for the project

                                                  i.      On the project consuming the artifact, click the settings Gear in bottom-left of screen, then click settings in the 'Pipelines' section

                                                ii.      Ensure that 'Limit Job authorization scope to current project' is turned off

b.      Set the Pipeline's build job to use a Project Collection scope

                                                  i.      Click 'Pipelines' under 'Pipelines' in the main Navigation on the left

                                                ii.      Choose your pipeline and click 'Edit'.

                                              iii.      Click the 'Options' tab at the top then choose 'Project Collection' under 'Build job authorization scope' on the right

c.       Set permissions on the artifact

                                                  i.      Click on the 'Artifacts' icon on the far left nav, choose your artifact in the dropdown, then click the cog on the top-right

                                                ii.      Click on the permissions tab and ensure that 'Project Collection Build Service (<project collection name>)' has appropriate permissions (mine are set at 'Contributor' and that seems to work)

2.      Project configuration in visual studio

a.       Add nuget.config in the project and add a package source to your organization's nuget feed

b.      Add referenced dlls to source control

                                                  i.      Click on view all files in solution explorer

                                                ii.      Nuget restore on solution

                                              iii.      Build solution

                                              iv.      Expand bin/debug or bin/release folder depending on the intended release configuration in devops pipeline (better yet, both)

                                                v.      Right click on the referenced dll and click ‘Add ignored items to source control’ command

                                              vi.      Check in and sync the project with devops repo

3.      Pipeline configurations in devops

a.       Edit devops pipeline’s restore nuget packages task

                                                  i.      Set ‘Feeds to use’ setting to ‘Feeds in my nuget.config’

                                                ii.      Select ‘Path to nuget.config’ as the path to added nuget.config file

Use nuget.config in the project and add a package source to your organization's nuget feed

In devops nuget restore taksk mention set 'Feeds to Use' as 'Feeds in my nuget.config' and select the added nuget.config file

 

References:

https://developercommunity.visualstudio.com/content/problem/795493/403-error-during-nuget-restore.html




No comments:

c# httpclient The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch

 If we get this error while trying to get http reponse using HttpClient object, it could mean that certificate validation fails for the remo...