我想像打包 .NET Standard 一样打包它们
库(打包集成到 IDE 中)。
目前,只有新的 SDK 格式项目 (.net core and .net standard) 具有快速 right-click project=>pack 选项。
这种相同的行为(右键单击=>打包按钮)目前不适用于 UWP 库项目。
使用 Visual Studio 2019 执行此操作的最佳方法是什么?
涉及分发 nuget.exe 的副本?
另一种方法是使用Nuget.Build.Tasks.Pack 包。
第 1 步:使用可用的最新版本的包。
Step2:在VS中right-click project=>Unload the project=>Edit the xxx.csprj(也可以修改文件系统中的xx.csproj)将此脚本添加到<Project>标签中:
<Project xxx>
......
<!--This custom PropertyGroup will be used to specify the package.-->
<PropertyGroup>
<PackageId>packageName</PackageId>
<PackageVersion>1.2.2</PackageVersion>
<PackageOutputPath>$(Outputpath)</PackageOutputPath>
<Authors>unknown</Authors>
<!--<Title></Title>
<Description></Description>
<Copyright></Copyright>
<RequireLicenseAcceptance></RequireLicenseAcceptance>
<LicenseUrl></LicenseUrl>
<ProjectUrl></ProjectUrl>
<IconUrl></IconUrl>
<ReleaseNotes></ReleaseNotes>
<Tags></Tags>
<PackageTypes></PackageTypes>
...
<NuspecFile></NuspecFile>-->
</PropertyGroup>
</Project>
我们可以在那个PropertyGroup中指定包的ID,version,authors,outputpath(required),如果需要我们也可以在那里设置许多其他元素,比如Description, Title, ReleaseNotes, NuspecFile...。
第 3 步: 现在我们可以打开 Developer Command Prompt for VS 运行 msbuild /t:pack ... 以使用命令行打包该项目。
或者我们可以将<GeneratePackageOnBuild>true</GeneratePackageOnBuild>添加到那个PropertyGroup,然后如果我们在VS中构建(右键单击项目=>构建或构建解决方案),VS会在构建过程中自动打包该库。
关于这个话题的更多信息请参考this document,希望它有助于解决您的问题:)