NuGet.Config 不是有效的 XML。Path 运行 DotNetCoreCli

huangapple go评论62阅读模式
英文:

NuGet.Config is not valid XML. Path running DotNetCoreCli

问题

以下是代码部分的翻译:

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

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

[Update]

Investigating advice at [help][2].

> The issue can be fixed using the new NugetAuthenticate task.

[![Nuget authenticate][3]][3]

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][4]][4]

Now I am checking the [help][5]

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][6]][6]

Checking [DevExpress advice][7].

[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?

  [1]: https://stackoverflow.com/questions/75597699/error-nu5049-the-pack-command-for-sdk-style-projects-is-not-supported
  [2]: https://%20https://developercommunity.visualstudio.com/AzureDevOps?port=1025&fsid=e8b7eeed-2c5b-4b1f-aef3-95e5979c08b6&viewtype=all&q=NuGet.Config%20is%20not%20valid%20XML.%20Path%20running%20DotNetCoreCli
  [3]: https://i.stack.imgur.com/kBrcR.png
  [4]: https://i.stack.imgur.com/CTKLf.png
  [5]: https://learn.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops&tabs=yaml#nuget-service-connection
  [6]: https://i.stack.imgur.com/tzOV0.png
  [7]: https://docs.devexpress.com/GeneralInformation/400604/installation/install-devexpress-controls-using-nuget-packages/integrate-nuget-to-popular-continuous-integration-systems

请注意,我已经忽略了代码部分并提供了非代码内容的翻译。

英文:

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\s\MySnap.Main.sln" (Restore target) (1) ->
       "D:\a\s\SBD.Core.MySnap.UI\SBD.Core.MySnap.UI.csproj" (_GenerateRestoreGraphProjectEntry target) (6:6) ->
         C:\Program Files\dotnet\sdk.0.200\NuGet.targets(679,5): error : NuGet.Config is not valid XML. Path: 'D:\a\Nuget\tempNuGet_6479.config'. [D:\a\s\SBD.Core.MySnap.UI\SBD.Core.MySnap.UI.csproj]
       C:\Program Files\dotnet\sdk.0.200\NuGet.targets(679,5): error :   The '@' character, hexadecimal value 0x40, cannot be included in a name. Line 8, position 46. [D:\a\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.Config 不是有效的 XML。Path 运行 DotNetCoreCli

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

NuGet.Config 不是有效的 XML。Path 运行 DotNetCoreCli

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 不是有效的 XML。Path 运行 DotNetCoreCli

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?

答案1

得分: 1

根据构建错误信息:

NuGet.targets(679,5): error : NuGet.Config 不是有效的 XML。路径:'D:\a\1\Nuget\tempNuGet_6479.config'

NuGet.targets(679,5): error : 字符'@',十六进制值0x40,不能包含在名称中

看起来,一些特殊字符 https://github.com/NuGet/Home/issues/7948(包括“@”字符)不允许出现在静态和动态生成的 NuGet.config 文件的“packageSources”名称中。

因此,如果允许修改 YAML/NuGet.config 文件,请尽量避免在包源名称中使用“@”字符。

英文:

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).

huangapple
  • 本文由 发表于 2023年3月4日 06:41:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/75632440.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定