gpt4 book ai didi

visual-studio - 如何在 Visual Studio 中的 NuGet 打包之前修改 .nuspec 文件

转载 作者:行者123 更新时间:2023-12-05 04:01:26 24 4
gpt4 key购买 nike

如今,Visual Studio 通过自动化创建 .nuspec 文件的过程使创建 NuGet 包变得更加容易。这意味着版本依赖等是自动创建的,您可以在此处简单地设置文本值:

enter image description here

因此,在构建 NuGet 包时,大部分工作已经完成。但是,在构建 .nuspec 文件之前,我需要添加一些外部程序集。我知道我可以在输出的 .nuspec 文件的文件集合中添加外部文件(在 obj\Release 中):

enter image description here

我的问题是,在 .nuspec 创建后但在 msbuild 或 Visual Studio 调用 pack 命令之前,我应该使用什么构建事件或其他方式来编辑它?或者,我应该在之后运行一个单独的构建过程吗?

注意:一个好处是找到一个我可以调用的工具来添加文件集合。如果没有它,我猜我将需要编写 powershell 代码来添加文件...

最佳答案

您可以在 csproj 文件中使用 Pack 元素:https://learn.microsoft.com/en-us/nuget/reference/msbuild-targets#including-content-in-a-package

将这样的东西添加到您的项目中:

<ItemGroup>
<Content Pack="True"
PackagePath="lib\netcoreapp2.2"
Include="C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All\2.1.2\Microsoft.AI.DependencyCollector.dll" />
</ItemGroup>

这会将 Microsoft.AI.DependencyCollector.dll 库添加到您的包中:

package content

这样您就可以将任何您喜欢的内容添加到您的图书馆。

关于visual-studio - 如何在 Visual Studio 中的 NuGet 打包之前修改 .nuspec 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55426151/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com