【问题标题】:How to require license acceptance for NuGet package through .csproj file如何通过 .csproj 文件要求接受 NuGet 包的许可证
【发布时间】:2022-01-04 02:33:17
【问题描述】:

我正在远离 .NET Core/5/6 NuGet 包的 .nuspec 文件,但我不知道如何在 .csproj 文件中设置等效的 <requireLicenseAcceptance> 元素。

我在包中包含一个名为 license.txt 的许可证文件,例如:

<ItemGroup>
    <None Include="license.txt">
        <Pack>True</Pack>
        <PackagePath></PackagePath>
    </None>
</ItemGroup>

然后我设置以下内容:

<PropertyGroup>
    <PackageLicenseExpression></PackageLicenseExpression>
    <PackageLicenseFile>license.txt</PackageLicenseFile>
</PropertyGroup>

这会在生成的.nuspec 文件中产生以下内容:

<license type="file">license.txt</license>
<licenseUrl>https://aka.ms/deprecateLicenseUrl</licenseUrl>

我希望&lt;requireLicenseAcceptance&gt;true&lt;/requireLicenseAcceptance&gt;也包含在生成的.nuspec文件中,以便在安装包时弹出license.txt的内容。

【问题讨论】:

    标签: .net-core msbuild nuget


    【解决方案1】:

    哦。我没有意识到它可以通过项目属性进行设置,这样做揭示了我应该猜到的:元素名称几乎相同,只是前缀为“Package”。

    .nuspec:

    &lt;RequireLicenseAcceptance&gt;True&lt;/RequireLicenseAcceptance&gt;

    .csproj:

    &lt;PackageRequireLicenseAcceptance&gt;True&lt;/PackageRequireLicenseAcceptance&gt;

    【讨论】:

      猜你喜欢
      • 2020-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多