我正在尝试在网站上上传一个新的 NuGet 包。
https://www.nuget.org/packages/manage/upload
第一次尝试时,我收到一个错误,提示我需要指定许可证。
我不想但是……好吧。
所以,我第一次尝试使用指定的许可证失败了。我阅读了链接的文档并尝试了多次。
我尝试使用一个<license>属性并在包中包含一个 license.txt 文件。
这些是我对 .nuspec 文件的尝试以及我收到的错误:
<license type="MIT"/>
=> Error: Unsupported license type 'MIT'.
(I know it is wrong but I found this "example" here: https://github.com/NuGet/Home/wiki/Packaging-License-within-the-nupkg)
<license type="expression">MIT</license>
=> Error: To provide a better experience for older clients when a license expression is specified, must be set to 'https://licenses.nuget.org/MIT'.
<license type="expression">BSD-2-Clause OR MIT</license>
=> Error: To provide a better experience for older clients when a license expression is specified, must be set to 'https://licenses.nuget.org/BSD-2-Clause%20OR%20MIT'.
<license type="expression">https://licenses.nuget.org/MIT</license>
=> Error: Invalid license metadata: The license expression 'https://licenses.nuget.org/MIT' contains invalid characters.
Run Code Online (Sandbox Code Playgroud)
我也试过我的 license.txt 没有成功。
我正在做的是:修改包含在生成的 mylibrary.nupkg 中的 mylibrary.nuspec 文件,添加<license>字段。
为什么?因为这个VS Studio 项目使用nuget.exe mylibrary.csproj 文件生成包,并且它不包含许可证。
我将nuget.exe 更新到最新的5.1 版本,但我不想修改VS 解决方案或项目。
任何的想法 ?
M.H*_*san 24
编辑.csproj文件。添加以下内容:
使用许可证文件:
<PropertyGroup>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
</PropertyGroup>
<ItemGroup>
<None Include="licenses\LICENSE.txt" Pack="true"
PackagePath="LICENSE.txt"/>
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)
使用 PackageLicenseExpression:
<PropertyGroup>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
有关更多详细信息,请参阅