0

The following task fails in my Azure Devops pipeline.

- task: DotNetCoreCLI@2
  inputs:
    command: 'restore'
    feedsToUse: 'config'
    nugetConfigPath: 'WinFormsCoreMain\NuGet.Config'

with errors like

 "D:\a\1\s\MySnap.Main.sln" (Restore target) (1) ->
       "D:\a\1\s\SBD.Core.MySnap.UI\SBD.Core.MySnap.UI.csproj" (_GenerateRestoreGraphProjectEntry target) (6:6) ->
         C:\Program Files\dotnet\sdk\7.0.200\NuGet.targets(679,5): error : NuGet.Config is not valid XML. Path: 'D:\a\1\Nuget\tempNuGet_6479.config'. [D:\a\1\s\SBD.Core.MySnap.UI\SBD.Core.MySnap.UI.csproj]
       C:\Program Files\dotnet\sdk\7.0.200\NuGet.targets(679,5): error :   The '@' character, hexadecimal value 0x40, cannot be included in a name. Line 8, position 46. [D:\a\1\s\SBD.Core.MySnap.UI\SBD.Core.MySnap.UI.csproj]

WinFormsCoreMain\NuGet.Config exists

The pipeline so far is

trigger:
- master

pool:
  vmImage: 'windows-2022'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'
  
  Major: '2'
  Minor: '0'
  Patch: '0'

steps:
- task: NuGetToolInstaller@1
  inputs:
    versionSpec: '>=4.3.0'
    checkLatest: false

- task: DotNetCoreCLI@2
  inputs:
    command: 'restore'
    feedsToUse: 'config'
    nugetConfigPath: 'WinFormsCoreMain\NuGet.Config'

I upgraded to using DotNetCoreCli@2 after my old pipeline recently stopped working.

I also upgraded my projects to being either .net7 or framework4.8 figuring the only way out is forward.

[Update]

Investigating advice at help.

The issue can be fixed using the new NugetAuthenticate task.

Nuget authenticate

So how do I format the service connection credentials?

I guess I use information from within my Nuget Package Manager -> Packages Sources ?

I tried adding a name

unexpected property

Now I am checking the help

I have updated the steps as follows but there is no improvement

steps:
- task: NuGetAuthenticate@1
  inputs:
    forceReinstallCredentialProvider: true
- task: NuGetToolInstaller@1
  inputs:
    versionSpec: '>=5.2'
    checkLatest: false

- task: DotNetCoreCLI@2
  inputs:
    command: 'restore'
    feedsToUse: 'config'
    nugetConfigPath: 'WinFormsCoreMain\NuGet.Config'

[Update]

NuGet.Config looks like this ( with obfuscations)

Nuget.Config

Checking DevExpress advice.

[Update[

I tried commenting out the "SBDCommonFeed@Local" packageSource and the restore task was able to run.

SBDCommonFeed is the name of a feed in my artifacts. Why do I need to comment it out to avoid this particular error?

Kirsten
  • 15,730
  • 41
  • 179
  • 318
  • 1
    It says that your nuget.config doesn't contain valid XML. What does the file actually look like? – Daniel Mann Mar 05 '23 at 01:18
  • @DanielMann Good point. I updated the question and discovered that the issue is to do with a package source that is an artifact.. – Kirsten Mar 05 '23 at 10:10

1 Answers1

1

According to the failed build error message:

NuGet.targets(679,5): error : NuGet.Config is not valid XML. Path: 'D:\a\1\Nuget\tempNuGet_6479.config'

NuGet.targets(679,5): error : The '@' character, hexadecimal value 0x40, cannot be included in a name

It appears, that some special characters https://github.com/NuGet/Home/issues/7948 (including the "@" one) are not allowed within a name of the "packageSources" of a static and dynamically generated NuGet.config files.

So, if you are allowed to modify the YAML/NuGet.config file(s), try to avoid the "@" char in the package source name(s).

Mikhail
  • 9,186
  • 4
  • 33
  • 49