msbuild - 用于多个框架的 Nuget 包
问题描述
我正在尝试制作针对多个框架的 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 文件相同
解决方案
nuget.exe 不支持打包 PackageReference 项目,SDK 项目始终是 PackageReference。
您应该使用dotnet pack
或msbuild -t:pack
推荐阅读
- tooltip - amCharts 中的 tooltipText 适配器
- c# - Visual Studio Code 未显示建议
- visual-studio-code - 在 Linux 上使用 VSCode 调试 Vala
- linux - 远程 - SSH 未连接到 VSCode 中的远程 Linux 服务器?
- python - 我将如何一起运行这两个文件。一个gui文件和一个主脚本
- javascript - 当视频的当前时间大于某个值时执行函数
- docker - GOOGLE_APPLICATION_CREDENTIALS 在 Cloud Run Container 中未定义
- excel - VB.NET - 删除 Activecell 的“命名范围”
- excel - 将“Control + A”插入文本框
- git - GitHub,但大文件转到 Google Drive