用于多个框架的 Nuget 包

Sha*_*nas 7 msbuild nuget .net-standard

我正在尝试制作针对多个框架的 nuget 包。但它不起作用。csproj 文件:

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
   <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
   <OutputType>Library</OutputType>
   <TargetFrameworks>net452;netstandard2.0</TargetFrameworks>
   <NuGetPackageImportStamp />
 </PropertyGroup>
Run Code Online (Sandbox Code Playgroud)

运行命令:

C:\Repos\Random\TestStuff\.nuget\nuget pack "C:\Repos\Random\TestStuff\TestPackaging\TestPackaging.csproj"
Run Code Online (Sandbox Code Playgroud)

它给了我错误:

错误 NU5012:无法找到“bin\Debug\TestPackaging\bin\Debug\”。确保项目已构建。

如果我将配置更改为:

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
  <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
   <OutputType>Library</OutputType>
   <TargetFramework>netstandard2.0</TargetFramework>
   <NuGetPackageImportStamp />
 </PropertyGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)

一切正常。我错过了什么?更改我运行它的位置没有区别。

编辑:运行命令

C:\Repos\Random\TestStuff\.nuget\nuget pack "C:\Repos\Random\TestStuff\TestPackaging\TestPackaging.csproj" -build
Run Code Online (Sandbox Code Playgroud)

给出不同的错误:

Build succeeded.
0 Warning(s)
0 Error(s)

Time Elapsed 00:00:00.50
Packing files from 
'C:\Repos\Random\TestStuff\TestPackaging\bin\Debug\TestPackaging\bin\Debug'.
Could not find a part of the path 
'C:\Repos\Random\TestStuff\TestPackaging\bin\Debug\TestPackaging\bin\Debug'.
Run Code Online (Sandbox Code Playgroud)

与 nuspec 文件相同

ziv*_*kan 10

nuget.exe不支持打包PackageReference项目,而SDK项目始终是PackageReference。

您应该使用dotnet pack或打包msbuild -t:pack