Azure-pipelines-tasks: NuGet 2.0.7 broke ability to restore from feeds outside account/collection using credentials

Created on 22 Sep 2017  路  6Comments  路  Source: microsoft/azure-pipelines-tasks

2.0.7 NuGet task is unable to restore when using a custom NuGet.config file and providing credentials to access externals feeds.
The generated temporary NuGet config file is not a valid XML for NuGet.

Most helpful comment

This is currently breaking all our builds, and there are many :O

All 6 comments

This is currently breaking all our builds, and there are many :O

Using version 2.0.8 here and experiencing the same problem.
Managed to work around the problem with restoring packages from external feeds by using preauthenicated urls (Not good as access keys gets checked into source control). Should get people there, but set a very low expiration time on those keys!

However this only moved the problem further ahead in the process for me. There is also problems getting out url and credentials for pushing packages to an external feed.
It fails with this:

##[warning]Can\'t find loc string for key: Error_ApiKeyNotSupported
##[error]Error: Error_ApiKeyNotSupported

Same as in issue #5383

Following this issue, and the temporary solution there, brought me back to having problems with the temporary nuget.config generated.

Error log:

System.AggregateException: One or more errors occurred. ---> System.IO.InvalidDataException: Unable to parse config file 'd:\a\1\Nuget\tempNuGet_108.config'.
   at NuGet.Configuration.Settings.ReadSettingsValue(XElement element, Boolean isPath)
   at NuGet.Configuration.Settings.ReadSection(XContainer sectionElement, ICollection`1 values, Boolean isPath)
   at NuGet.Configuration.Settings.GetNestedValues(String section, String subSection)
   at NuGet.Configuration.PackageSourceProvider.ReadCredential(String sourceName)
   at NuGet.Configuration.PackageSourceProvider.ReadPackageSource(SettingValue setting, Boolean isEnabled)
   at NuGet.Configuration.PackageSourceProvider.LoadPackageSources()
   at NuGet.Commands.PackageSourceProviderExtensions.ResolveAndValidateSource(IPackageSourceProvider sourceProvider, String source)
   at NuGet.Commands.CommandRunnerUtility.ResolveSource(IPackageSourceProvider sourceProvider, String source)
   at NuGet.Commands.PushRunner.<Run>d__0.MoveNext()

+1 Same here using v2.0.8 in VSTS. This is a blocking issue as there is no way to revert to using 2.0.6. We can't restore any packages from our company-wide Nexus-server.

Comparing the build logs of the Nuget task from v2.0.6 to v2.0.8, you can see the 2.0.6 version actually fires three commands:

  • [command] nuget.exe sources Remove ...
  • [command] nuget.exe sources Add ...
  • [command] nuget.exe restore ...

The 2.0.8 version skips the 'sources remove' and 'sources add' commands and only fires the restore command:

  • [command] nuget.exe restore ...

Running on a hosted agent in VSTS.
Authenticating to external Nexus server using basic auth (configured in service endpoint).
Here's the full log (verbosity detailed):

2017-09-25T07:44:15.9938444Z [command]C:\Windows\system32\chcp.com 65001
2017-09-25T07:44:16.0018458Z Active code page: 65001
2017-09-25T07:44:16.0558445Z Detected NuGet version 4.0.0.2283 / 4.0.0
2017-09-25T07:44:16.0608446Z SYSTEMVSSCONNECTION exists true
2017-09-25T07:44:16.0618444Z bf7d39d2-b281-4639-9ee1-fa7da07938fc exists true
2017-09-25T07:44:16.0648443Z Saving NuGet.config to a temporary config file.
2017-09-25T07:44:16.0738446Z Using authentication information for the following URI: <redacted>
2017-09-25T07:44:16.0908455Z [command]d:\a\_tool\NuGet\4.0.0\x64\nuget.exe restore d:\a\1\s\<redacted>.sln -Verbosity Detailed -NonInteractive -ConfigFile d:\a\1\Nuget\tempNuGet_18316.config
2017-09-25T07:44:16.6987150Z NuGet.Configuration.NuGetConfigurationException: NuGet.Config is not valid XML. Path: 'd:\a\1\Nuget\tempNuGet_18316.config'. ---> System.Xml.XmlException: '<redactedFeedName>' is an unexpected token. The expected token is '='. Line 5, position 41.
2017-09-25T07:44:16.6987150Z    at System.Xml.XmlTextReaderImpl.Throw(Exception e)
2017-09-25T07:44:16.6997154Z    at System.Xml.XmlTextReaderImpl.ParseAttributes()
2017-09-25T07:44:16.6997154Z    at System.Xml.XmlTextReaderImpl.ParseElement()
2017-09-25T07:44:16.6997154Z    at System.Xml.XmlTextReaderImpl.ParseElementContent()
2017-09-25T07:44:16.6997154Z    at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
2017-09-25T07:44:16.6997154Z    at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
2017-09-25T07:44:16.6997154Z    at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
2017-09-25T07:44:16.6997154Z    at NuGet.Configuration.XmlUtility.GetDocument(String fullPath)
2017-09-25T07:44:16.6997154Z    at NuGet.Configuration.XmlUtility.GetOrCreateDocument(XDocument content, String fullPath)
2017-09-25T07:44:16.6997154Z    at NuGet.Configuration.Settings.<>c__DisplayClass20_0.<.ctor>b__0()
2017-09-25T07:44:16.6997154Z    at NuGet.Configuration.Settings.<>c__DisplayClass66_0.<ExecuteSynchronized>b__0()
2017-09-25T07:44:16.6997154Z    --- End of inner exception stack trace ---
2017-09-25T07:44:16.6997154Z    at NuGet.Configuration.Settings.<>c__DisplayClass66_0.<ExecuteSynchronized>b__0()
2017-09-25T07:44:16.7007172Z    at NuGet.Common.ConcurrencyUtilities.ExecuteWithFileLocked(String filePath, Action action)
2017-09-25T07:44:16.7007172Z    at NuGet.Configuration.Settings..ctor(String root, String fileName, Boolean isMachineWideSettings)
2017-09-25T07:44:16.7007172Z    at NuGet.Configuration.Settings.ReadSettings(String root, String settingsPath, Boolean isMachineWideSettings)
2017-09-25T07:44:16.7007172Z    at NuGet.Configuration.Settings.LoadUserSpecificSettings(List`1 validSettingFiles, String root, String configFileName, IMachineWideSettings machineWideSettings, Boolean useTestingGlobalPath)
2017-09-25T07:44:16.7007172Z    at NuGet.Configuration.Settings.LoadDefaultSettings(String root, String configFileName, IMachineWideSettings machineWideSettings, Boolean loadAppDataSettings, Boolean useTestingGlobalPath)
2017-09-25T07:44:16.7007172Z    at NuGet.CommandLine.Command.Execute()
2017-09-25T07:44:16.7007172Z    at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)
2017-09-25T07:44:16.7217140Z ##[error]Error: d:\a\_tool\NuGet\4.0.0\x64\nuget.exe failed with return code: 1
2017-09-25T07:44:16.7217140Z ##[error]Packages failed to restore
2017-09-25T07:44:16.7217140Z ##[section]Finishing: NuGet restore

@vvillasanteg , @furier , @hfurubotten , @jcats ,
We have just deployed a hotfix with #5456 that should resolve this issue. Apologies for the inconvenience and If you continue to experience issues please reach out and we will work to triage with you.
Keith

Can verify that our builds are working again, and we are able to get them to flow as usual. Took a while to revert back from all the workarounds from yesterday, but from v2.0.9 everything seems to be working as expected here. Thanks!

Can confirm v2.0.9 is working as expected again!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jared-hexagon picture jared-hexagon  路  3Comments

richard-ob picture richard-ob  路  3Comments

timfish picture timfish  路  3Comments

TheRealEdwardCullen picture TheRealEdwardCullen  路  3Comments

ThomasBarnekow picture ThomasBarnekow  路  3Comments