NuGet打包Nuspec:值不能为null或空字符串.参数名称:value

use*_*571 8 build nuget-package nuspec

我正在为一个网站打包一堆javascript.这就是我的.nuspec样子.

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
  <metadata>
    <version>$version$</version>
    <authors>Author Person</authors>
    <owners>Company Name</owners>
    <id>PackageNameId</id>
    <title>PackageNameId</title>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Description text stuff</description>
    <copyright>Company Copyright Info</copyright>
  </metadata>
  <files>
    <file src="www\**" target="" />  <!--It just packages everything in the www folder in the same directory as this .nuspec -->
  </files>
</package>
Run Code Online (Sandbox Code Playgroud)

它只包装该www文件夹中的所有内容.该$version$标志应在TFS的NugetPackage版本标志(我正在建设)来得到更换.

我没有看到任何调用value,所以我真的不知道为什么它会抛出错误.

这是完整的错误:

Attempting to build package from 'PackageName.nuspec'.

##[error]Value cannot be null or an empty string.

##[error]Parameter name: value
Run Code Online (Sandbox Code Playgroud)

ale*_*ian 18

我怀疑你是nuget pack在你的nuspec文件而不是你的csproj文件上运行此错误.

正如我从这个开放的NuGet问题中学到的那样,<version>$version$</version>只有在调用nuget pack.csproj或.vbproj文件时,AssemblyInfo令牌替换(例如)才有效.引用NuGet文档:

直接使用项目文件是替换令牌所必需的,因为项目是令牌值的来源.如果将nuget pack与.nuspec文件一起使用,则不会发生令牌替换.