根据文档https://learn.microsoft.com/en-us/nuget/schema/msbuild-targets,似乎msbuild现在支持2个特定的NuGet目标:
关于所需的依赖项,我正在使用
而且
Pack
和Restore
。我已经成功使用了Restore
,但无法使用Pack
。
这是传统的.Net项目支持还是仅限于.Net Core?我没有找到任何明确说明的文档。错误 MSB4057:项目中不存在目标“Pack”。
关于所需的依赖项,我正在使用
PM> nuget help
NuGet Version: 4.1.0.2450
usage: NuGet <command> [args] [options]
Type 'NuGet help <command>' for help on a specific command.
而且
C:\Git>msbuild /version
Microsoft (R) Build Engine version 15.1.1012.6693
Copyright (C) Microsoft Corporation. All rights reserved.
15.1.1012.6693
随着
Microsoft Visual Studio Professional 2017
Version 15.2 (26430.12) Release
VisualStudio.15.Release/15.2.0+26430.12
Microsoft .NET Framework
Version 4.6.01586
NuGet.Build.Tasks.Pack
NuGet包,但如果不向csproj添加更多由“sdk-style”项目默认的属性,则可能无法“足够好地”工作。 但是,如果您只创建“逻辑”NuGet包,则已经支持此功能,只是没有模板而已。这已经是许多库构建的方式(例如Newtonsoft.Json)。 - Martin Ullrich