Reputation: 4390
Now that we have an official migration from project.json
back to .csproj
, how do you actually generate a NuGet package output?
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.
A complete example of how to do this using .csproj
files would be greatly appreciated.
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.
Upvotes: 3
Views: 946
Reputation: 3776
I'm packing a .NET Core NuGet package with MSBuild in Visual Studio 2017 RC using following steps:
New -> Project -> C# -> .NET Core -> Console App (.NET Core)
.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>
Open Developer Command Prompt for VS 2017 RC and type cd *your project file path*
command to navigate to your project file path.
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.
Upvotes: 2