Azure Pielines:由于依赖项不符合 xsd,使用依赖项打包 csproj 失败?

问题描述

我有以下 .nuspec

<?xml version="1.0" encoding="utf-8"?>
<package>
  <Metadata>
    <id>$id$</id>
    <version>$version$</version>
    <title>$title$</title>
    <authors>$author$</authors>
    <owners>$author$</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>$description$</description>
    <releaseNotes>Alpha release.</releaseNotes>
    <copyright>copyright 2021</copyright>
    <tags>Some tag</tags>
    <dependencies>
      <group targetFramework="netstandard2.0">
        <dependency id="Microsoft.Extensions.Logging" version="3.1.15" />
      </group>
  </dependencies>
  </Metadata>
</package>

以及以下管道任务定义:

- task: NuGetCommand@2
  inputs:
    command: 'pack'
    packagesToPack: '$(Build.Repository.LocalPath)\<project Folder>\<project name>.csproj'
    versioningScheme: 'off'
    includeSymbols: true
    nugetConfigPath: $(Build.Repository.LocalPath)\<project Folder>\nuget.config

虽然失败并出现以下错误

system.invalidOperationException:命名空间“http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd”中的元素“group”有 命名空间 ' at 中的无效子元素 'depdenency' NuGet.Packaging.Manifest.c.b__20_0(对象 发件人,ValidationEventArgs e) 在 System.Xml.Schema.XmlSchemaValidator.ValidateElementContext(XmlQualifiedname elementName,Boolean & invalidElementInContext) 在 System.Xml.Schema.XmlSchemaValidator.ValidateElement(String localName,String namespaceUri、XmlSchemaInfo schemaInfo、String xsitype、String xsiNil、字符串 xsiSchemaLocation、字符串 xsiNoNamespaceSchemaLocation) 在 System.Xml.Schema.XNodeValidator.ValidateElement(XElement e) 在 System.Xml.Schema.XNodeValidator.ValidateNodes(XElement e) 在 System.Xml.Schema.XNodeValidator.ValidateElement(XElement e) 在 System.Xml.Schema.XNodeValidator.ValidateNodes(XElement e) 在 System.Xml.Schema.XNodeValidator.ValidateElement(XElement e) 在 System.Xml.Schema.XNodeValidator.ValidateNodes(XElement e) 在 System.Xml.Schema.XNodeValidator.ValidateElement(XElement e) 在 System.Xml.Schema.XNodeValidator.ValidateNodes(XElement e) 在 System.Xml.Schema.XNodeValidator.ValidateElement(XElement e) 在 System.Xml.Schema.XNodeValidator.Validate(XObject 源, XmlSchemaObject partialValidationType,Boolean addSchemaInfo) at NuGet.Packaging.Manifest.ValidateManifestSchema(XDocument 文档, String schemaNamespace) 在 NuGet.Packaging.Manifest.ReadFrom(Stream 流,Func`2 propertyProvider,Boolean validateSchema) 在 NuGet.CommandLine.ProjectFactory.ProcessNuspec(PackageBuilder 构建器, 字符串 basePath) 在 NuGet.CommandLine.ProjectFactory.CreateBuilder(String basePath,NuGetVersion 版本,字符串后缀,布尔型 buildIfNeeded, PackageBuilder 构建器)在 NuGet.Commands.PackCommandRunner.BuildFromProjectFile(字符串路径)
在 NuGet.CommandLine.PackCommand.ExecuteCommand() 在 NuGet.CommandLine.Command.ExecuteCommandAsync() 在 NuGet.CommandLine.Command.Execute() 在 NuGet.CommandLine.Program.MainCore(String workingDirectory,String[] 参数))

构建日志是:

NuGet 版本:5.8.0.6930 正在尝试从“.csproj”构建包。 MSBuild 自动检测:使用 msbuild 版本 来自“C:\Program Files (x86)\Microsoft Visual”的“16.9.0.16703” Studio\2019\Enterprise\MSBuild\Current\bin'。使用选项 -MSBuildVersion 强制 nuget 使用特定版本的 MSBuild。从 'D:\a\1\s\bin\Debug\netstandard2.0'。使用“.nuspec”作为元数据。

我真的很困惑为什么它使用这么旧的 xsd,我可以在本地构建这个解决方案,在本地打包,然后在本地推送,然后从私人提要中读取它就好了。 ..但是当我尝试使用管道自动化它时,它只是不喜欢我的依赖项节点。关于我做错了什么的任何线索?

解决方法

我是个白痴!

在我在这里发布的版本中,我删除了一个依赖节点项以使其更易于阅读,但是第二个依赖节点被拼写为“depnedency”,所以这完全是愚蠢的。将其重命名为“依赖项”解决了该问题。

希望解析器会说,而不是告诉我我的 xsd 是错误的。我想它对我的信任比它应该的要多。