Nuget包用于多个框架

问题描述 投票:1回答:1

我正在努力使nuget包定位多个框架。但它不起作用。 csproj文件:

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

运行命令:

C:\Repos\Random\TestStuff\.nuget\nuget pack "C:\Repos\Random\TestStuff\TestPackaging\TestPackaging.csproj"

它给了我错误:

错误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>

每件事都很好。我错过了什么?改变我运行它的位置没有区别。

编辑:运行命令

C:\Repos\Random\TestStuff\.nuget\nuget pack "C:\Repos\Random\TestStuff\TestPackaging\TestPackaging.csproj" -build

给出不同的错误:

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'.

与nuspec文件相同

msbuild nuget .net-standard
1个回答
2
投票

nuget.exe不支持打包PackageReference项目,SDK项目总是PackageReference。

你应该使用dotnet packmsbuild -t:pack包装


0
投票

在csproj SDK样式文件中使用nupsec xml属性定位多个框架。将此TargetFrameworks(带有's')添加回csproj:

<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>

Edit the manifest,在定义TargetFrameworks的ProjectGroup中添加以下行:

<files>
  <file src="bin\Release\net462\TestPackaging.dll" target="lib\net452\TestPackaging.dll" />
  <file src="bin\Release\netstandard2.0\TestPackaging.dll" target="lib\netstandard2.0\TestPackaging.dll" />
</files>

构建项目,dll进入各自的目录,nuget get用两个目标框架的源文件构建。

© www.soinside.com 2019 - 2024. All rights reserved.