JetBrains / teamcity-nuget-support

TeamCity NuGet support
Apache License 2.0
43 stars 11 forks source link

Use credentials provider with VS / MSBuild build steps #28

Open pjt33 opened 4 years ago

pjt33 commented 4 years ago

https://www.jetbrains.com/help/teamcity/using-teamcity-as-nuget-feed.html says

You can use TeamCity NuGet feeds to restore packages in your builds: when the NuGet Installer or NuGet Publish build step is used, TeamCity will use the credentials provider to automatically authenticate requests to the private TeamCity NuGet feeds.

This appears to be literally true: the credentials provider is used automatically with NuGet Installer build steps. But if you instead have a VS or an MSBuild build step with Restore among the targets, the credentials provider does not appear to be used unless you explicitly add a "NuGet feed credentials" build feature to the project.

It would be useful to have the credentials provider applied automatically regardless of the choice of build step, or at least to have a global configuration parameter to enable this.


Cross-reference: https://github.com/JetBrains/teamcity-documentation/issues/62

pjt33 commented 4 years ago

I'm told this is a bug, not a missing feature.

When I tried this by just adding the feed to NuGet.config and using the existing build configuration, the step

Runner type: Visual Studio (sln) (Microsoft Visual Studio solution (.sln) runner)
Execute: If all previous steps finished successfully
Solution file path: PROJECT.sln
Working directory: same as checkout directory
Visual Studio: Microsoft Visual Studio 2019
Targets: Restore,Rebuild,Android\PROJECT_FRONTEND:PackageForAndroid Configuration: Release
Platform: default
Command line parameters: -verbosity:normal

failed with error message:

[RestoreTask] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets(124, 5): No se puede cargar el índice de servicio para el origen http://SERVER:8000/httpAuth/app/nuget/feed/PROJECT/FEED/v3/index.json. El código de estado de la respuesta no indica un resultado correcto: 401 ().

I initially solved the problem by adding a "NuGet feed credentials" build feature for the listed feed, and then after re-reading the documentation I disabled the build feature and split the build step into one "Nuget Installer" step and the existing "Visual Studio (sln)" step without the Restore target. Both of these workarounds were successful.