如何在Visual Studio 2017 RC中从.NET Core MSBuild项目创建NuGet包? [英] How do you create a NuGet package from a .NET Core MSBuild project in Visual Studio 2017 RC?
问题描述
现在我们已经从project.json
正式迁移回.csproj
,您实际上如何生成NuGet包输出?
Now that we have an official migration from project.json
back to .csproj
, how do you actually generate a NuGet package output?
我不知道是否只有我一个人,但是我很难理解官方文档页面.唯一提到的是从命令行调用msbuild
,但这对我来说并不是真正的工作,而且我更希望您可以直接在.csproj
文件本身中指定此步骤.
I don't know if it's just me but I find it hard to understand the official documentation pages. The only mention is about calling msbuild
from the command line, but it's not really working for me, and besides I was more hoping that you could just specify this step directly in the .csproj
file itself.
一个使用.csproj
文件执行此操作的完整示例,将不胜感激.
A complete example of how to do this using .csproj
files would be greatly appreciated.
更新:最终使MSBuild通过从命令行运行它来输出程序包.技巧是按照文档页面中的说明在PropertyGroup
中填写所有程序包元数据.但是,我仍然更希望将pack作为正常构建过程的一部分来运行.
Update: Finally got the MSBuild to output the package by running it from the command line. The trick was fill in a PropertyGroup
with all the package metadata as described in the doc pages. However, I still would much prefer to run pack as part of the normal build process.
更新:在
Update: Found a much better resource for understanding the new .csproj
format in the .NET Blog page.
推荐答案
我正在将 .NET Core NuGet软件包与 MSBuild 打包在 Visual Studio 2017中RC ,请按照以下步骤操作:
I'm packing a .NET Core NuGet package with MSBuild in Visual Studio 2017 RC using following steps:
- 使用 .NET Core和Docker(Preview)组件安装 Visual Studio 2017 .
- 通过
New -> Project -> C# -> .NET Core -> Console App (.NET Core)
创建以下软件包信息. - 右键单击 .NET Core项目以选择 Edit ProjectName.csproj 选项,以在 Visual中打开 .csproj 文件Studio 2017 .
-
使用以下软件包信息在 PropertyGroup 节点下保存文件:
- Install Visual Studio 2017 with .NET Core and Docker (Preview) component.
- Create a following package information through
New -> Project -> C# -> .NET Core -> Console App (.NET Core)
. - Right-Click the .NET Core project to choose Edit ProjectName.csproj option to open the .csproj file in Visual Studio 2017.
Save a file under the PropertyGroup node with the following package information:
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
<PackageId>TestNetCorePackage</PackageId>
<PackageVersion>1.0.0</PackageVersion>
<Authors>Weiwei</Authors>
<Description>Test .NET Core package</Description> <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>First release</PackageReleaseNotes>
<Copyright>Copyright 2016 (c) Contoso Corporation. All rights reserved.</Copyright>
<PackageTags>Net Core</PackageTags>
</PropertyGroup>
打开 VS 2017 RC的开发人员命令提示符,然后键入cd *your project file path*
命令以导航到您的项目文件路径.
Open Developer Command Prompt for VS 2017 RC and type cd *your project file path*
command to navigate to your project file path.
键入msbuild ProjectName.csproj /t:pack
,这是打包 .NET Core程序包的命令.它将在项目路径的 bin \ debug 文件夹中生成.
Type msbuild ProjectName.csproj /t:pack
, which is the command to pack your .NET Core package. It will generate in bin\debug folder in your project path.
这篇关于如何在Visual Studio 2017 RC中从.NET Core MSBuild项目创建NuGet包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!