我希望从多个 .csproj 创建一个 nuget 包。
例如:我有两个 .csproj,其中之一依赖于其他外部包,例如 NewtonSoft。
dotnet new classlib -o ClassLibrary1
dotnet new classlib -o ClassLibrary2
cd ClassLibrary1
dotnet add package Newtonsoft.Json
Run Code Online (Sandbox Code Playgroud)
我希望发布一个包含 ClassLibrary1.dll 和 ClassLibrary2.dll 的单个 nuget 包,并且生成的 .nuspec 列出了依赖项 Newtonsoft.Json。
我尝试做这样的事情:创建了一个虚拟 .csproj 并添加了对 ClassLibrary1 & 2 的引用,并使用 -IncludeReferencedProjects: Ex:- 创建了一个 nuget 包
dotnet new classlib -o dummyNuget
dotnet add reference ClassLibrary1.csproj
dotnet add reference ClassLibrary2.csproj
nuget pack dummyNuget.csproj -IncludeReferencedProjects
Run Code Online (Sandbox Code Playgroud)
它生成以下 .nuspec 文件,缺少 NewtonSoft 依赖项。
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>dummynuget</id>
<version>1.0.0</version>
<authors></authors>
<description>Description</description>
<dependencies /> …Run Code Online (Sandbox Code Playgroud)