gpt4 book ai didi

.net - 如何使用 dotnet 命令创建 nuget 元包?

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

我有一堆项目的解决方案:

ProjectA.csproj
ProjectB.csproj
ProjectC.csproj

这些都单独打包为 nuget 包:
dotnet pack ProjectA.csproj --version-suffix 1.0.0    ===> ProjectA-1.0.0.nupkg
dotnet pack ProjectB.csproj --version-suffix 1.0.0 ===> ProjectB-1.0.0.nupkg
dotnet pack ProjectC.csproj --version-suffix 1.0.0 ===> ProjectC-1.0.0.nupkg

版本号由我们的构建服务器使用 gitversion.exe 自动提取

现在我想制作一个 nuget 元包,它会自动引用所有三个 nupkg。

我可以用 nuspec 文件来做到这一点,但是当我们的版本号发生变化时,我需要手动编辑它。

我可以制作第四个项目 ProjectAll.csproj,它引用了其他三个项目。但这会让我在使用这些包的应用程序的输出中留下一个空的 DLL。

最好的方法是什么?

最佳答案

我不知道这是否是一个“ secret ”,但对于大多数命令,dotnet CLI 只是 msbuild 的包装器。这包括包,意味着 NuGet's documentation on the MSBuild pack target是相关的。如果您向下滚动查看每个标题,或者只是搜索“构建输出”一词,您将找到 Output assemblies部分。那里说:

IncludeBuildOutput: A boolean that determines whether the build output assemblies should be included in the package.



因此,在您的项目文件中,您可以包含以下内容:

<Project Sdk="whatever. I can't be bothered looking it up and I haven't memorized it.">
<PropertyGroup>
<TargetFramework>same as your other projects. Most restrictive TFM if different projects have different TFMs</TargetFramework>
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\path\to\ProjectA.csproj" />
<ProjectReference Include="..\path\to\ProjectB.csproj" />
<ProjectReference Include="..\path\to\ProjectC.csproj" />
<ItemGroup>
</Project>

关于.net - 如何使用 dotnet 命令创建 nuget 元包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60576108/

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