我正在尝试按照this guide创建我的第一个nuget包。我在nuget pack
子目录中生成了一个nuspec文件和一个MSBUILD目标文件,并且都包含在csrpoj的构建输出中。我现在按照bin
目录中的建议在我的nuspec文件上运行> nuget pack MyPackage.nuspec
Value cannot be null or an empty string.
Parameter name: value
,我收到以下错误。
<?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<licenseUrl>http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE</licenseUrl>
<projectUrl>http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE</projectUrl>
<iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
<copyright>Copyright 2016</copyright>
<tags>source version tfs git</tags>
<packageTypes>
<packageType type="Dependency" />
</packageTypes>
</metadata>
<files>
<!-- Include everything in \build -->
<file src="build\**"
target="build" />
</files>
</package>
错误似乎很清楚,但不能为null的值不是。这是我当前的nuspec文件的一个示例。
<div class="entry">
<?php the_excert(); ?>
<a href="<?php the_permalink(); ?>">Read More</a>
</div>
答案 0 :(得分:5)
在我的项目文件上运行nuget pack会产生更多有用的信息
The element 'metadata' in namespace 'http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd' has invalid child element 'packageTypes' in namespace 'http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd'. List of possible elements expected: 'references, contentFiles, dependencies, developmentDependency, frameworkAssemblies, summary, language' in namespace 'http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd'.
添加以下命名空间后没有任何更改。
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
删除packageTypes elemtn导致进一步的进展。
Authors is required.
Description is required.
填写作者和说明,这只留下警告。
WARNING: 1 issue(s) found with package 'SourceVersion'.
Issue: Remove sample nuspec values.
Description: The value "Summary of changes made in this release of the package." for ReleaseNotes is a sample value and should be removed.
Solution: Replace with an appropriate value or remove and it and rebuild your package.
填写ReleaseNotes内容,然后允许创建包而不会出错。
注意:直接在nuspec文件上运行nuget pack仍然会在从上面进行这些更改后给出相同的错误。但是运行nuget pack MyPackage.csproj
现在对我来说工作正常,这对我来说已经足够了。