【问题标题】:The 'Version' attribute is not declared in nuspec filenuspec 文件中未声明“版本”属性
【发布时间】:2017-08-14 16:11:01
【问题描述】:

当我尝试使用 VSTS 打包 .net 核心解决方案时,我收到 The 'Version' attribute is not declared 错误。我的 nuspec 文件如下所示:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
  <metadata minClientVersion="3.3.0">
    <id>YYY.AspNetCore.CustomMapper</id>
    <version>0.0.1</version>
    <authors>build@YYYYYY.com</authors>
    <owners>YYY YYY</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>YYY.AspNetCore</description>
    <tags>YYY</tags>
    <contentFiles>
        <files include="wwwroot\**" buildAction="EmbeddedResource" copyToOutput="true" />
        <files include="Areas\CustomMapper\readme.txt" buildAction="EmbeddedResource" copyToOutput="true" />
    </contentFiles>
    <dependencies>
    <group>
        <dependency id="EntityFramework" Version="6.1.0" />
        <dependency id="Microsoft.AspNetCore" Version="1.1.0" />
        <dependency id="Microsoft.AspNetCore.Mvc" version="1.1.0" />
        <dependency id="Microsoft.AspNetCore.StaticFiles" version="1.1.0" />
        <dependency id="Microsoft.Extensions.Logging.Debug" version="1.1.0" />
        <dependency id="YYY.Web.AspNetCore" version="1.0.1" />
        <dependency id="SimpleInjector.Integration.AspNetCore" version="4.0.10" />
        <dependency id="SimpleInjector.Integration.AspNetCore.Mvc" version="4.0.10" />
    </group>
  </dependencies>
  </metadata>
  <files>
    <file src="wwwroot\**" target="content\wwwroot" />
    <file src="Areas\CustomMapper\readme.txt" target="" />
    <file src="bin\Release\net452\win7-x86\YYY.CustomMapper.dll" target="lib\net452" />
    <file src="bin\Release\net452\win7-x86\YYY.CustomMapper.Data.dll" target="lib\net452" />
    <file src="bin\Release\net452\win7-x86\YYY.CustomMapper.Provider.dll" target="lib\net452" />
    <file src="bin\Release\net452\win7-x86\YYY.CustomMapper.Services.dll" target="lib\net452" />
    <file src="bin\Release\net452\win7-x86\YYY.CustomMapper.WebApi.dll" target="lib\net452" />
    <file src="bin\Release\net452\win7-x86\YYY.CustomMapper.Backend.WebApi.dll" target="lib\net452" />
    <file src="bin\Release\net452\win7-x86\YYY.CustomMapper.Provider.Common.dll" target="lib\net452" />
    <file src="bin\Release\net452\win7-x86\YYY.AspNetCore.CustomMapper.dll" target="lib\net452" />
  </files>
</package>

谁能帮我解释一下为什么会出现这个错误?

【问题讨论】:

  • 不确定,但您可能还需要设置主要版本?所以不是 0.0.1,而是尝试 1.0.0 作为第一次迭代?真的不确定。
  • 实际上,问题是“版本”属性区分大小写。我将版本属性更改为 EntityFramework 和 Microsoft.AspNetCore 的版本,现在已修复。
  • 很抱歉,我是 Stack Overflow 的新手,但此时您是否应该编写并接受自己的答案?
  • @Sharif Mamun 我遇到了同样的问题。没有您的回答,我仍然会寻找解决方案。谢谢

标签: .net nuget azure-devops visual-studio-2017 azure-pipelines


【解决方案1】:

实际上,问题在于依赖元素的“版本”属性区分大小写。我将版本属性更改为 EntityFramework 和 Microsoft.AspNetCore 的版本,现在已修复。 nuspec 现在如下所示:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
  <metadata minClientVersion="3.3.0">
    <id>YYY.AspNetCore.CustomMapper</id>
    <version>0.0.1</version>
    <authors>build@YYYYYY.com</authors>
    <owners>YYY YYY</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>YYY.AspNetCore</description>
    <tags>YYY</tags>
    <contentFiles>
        <files include="wwwroot\**" buildAction="EmbeddedResource" copyToOutput="true" />
        <files include="Areas\CustomMapper\readme.txt" buildAction="EmbeddedResource" copyToOutput="true" />
    </contentFiles>
    <dependencies>
    <group>
        <dependency id="EntityFramework" version="6.1.0" />
        <dependency id="Microsoft.AspNetCore" version="1.1.0" />
        <dependency id="Microsoft.AspNetCore.Mvc" version="1.1.0" />
        <dependency id="Microsoft.AspNetCore.StaticFiles" version="1.1.0" />
        <dependency id="Microsoft.Extensions.Logging.Debug" version="1.1.0" />
        <dependency id="YYY.Web.AspNetCore" version="1.0.1" />
        <dependency id="SimpleInjector.Integration.AspNetCore" version="4.0.10" />
        <dependency id="SimpleInjector.Integration.AspNetCore.Mvc" version="4.0.10" />
    </group>
  </dependencies>
  </metadata>
  <files>
    <file src="wwwroot\**" target="content\wwwroot" />
    <file src="Areas\CustomMapper\readme.txt" target="" />
    <file src="bin\Release\net452\win7-x86\YYY.CustomMapper.dll" target="lib\net452" />
    <file src="bin\Release\net452\win7-x86\YYY.CustomMapper.Data.dll" target="lib\net452" />
    <file src="bin\Release\net452\win7-x86\YYY.CustomMapper.Provider.dll" target="lib\net452" />
    <file src="bin\Release\net452\win7-x86\YYY.CustomMapper.Services.dll" target="lib\net452" />
    <file src="bin\Release\net452\win7-x86\YYY.CustomMapper.WebApi.dll" target="lib\net452" />
    <file src="bin\Release\net452\win7-x86\YYY.CustomMapper.Backend.WebApi.dll" target="lib\net452" />
    <file src="bin\Release\net452\win7-x86\YYY.CustomMapper.Provider.Common.dll" target="lib\net452" />
    <file src="bin\Release\net452\win7-x86\YYY.AspNetCore.CustomMapper.dll" target="lib\net452" />
  </files>
</package>

【讨论】:

  • 澄清:他指的是version属性dependency元素,它们不能是Version,而必须是小写的version。它欺骗了我,因为我从其他一些 PackageReferences 复制过去但没有抓住它。此外,错误消息非常缺乏。
  • 我实际上做了一个复制粘贴,然后在这种区分大小写方面遇到了困难。那个时候.Net Core也没有足够的例子来求助!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-10-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多