How to create a NuGet package from a .NET Core MSBuild project in Visual Studio 2017 RC?

Now that we have the official migration from project.json back to .csproj , how do you actually generate the output of the NuGet package?

I don’t know if this is the only thing, but it’s hard for me to understand the official pages of the documentation . The only mention of invoking msbuild from the command line, but this does not work for me, and furthermore, I hoped more that you could just specify this step directly in the .csproj file.

A complete example of how to do this using .csproj files will be considered.

Update: Finally, I got MSBuild to output the package by running it from the command line. The trick filled the PropertyGroup all the package metadata, as described on the pages of the document. However, I still prefer to run the package as part of the normal build process.

Update: Find a much better resource for understanding .csproj new format . NET Blog Page .

+3
source share
1 answer

I am packaging a .NET Core NuGet package with MSBuild in Visual Studio 2017 RC using the following steps:

  • Install Visual Studio 2017 using the .NET Core component and Docker (Preview) .
  • Create the following package information via New -> Project -> C# -> .NET Core -> Console App (.NET Core) .
  • Right-click the .NET Core project to select Change the ProjectName.csproj parameter to open the .csproj file in Visual Studio 2017 .
  • Save the file to 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 the Developer Command Prompt for VS 2017 RC and enter the command cd *your project file path* to go to the path to the project file.

  • Type msbuild ProjectName.csproj /t:pack , which is the command to package the .NET Core package. It will be created in the bin \ debug folder in your project path.

+2
source

Source: https://habr.com/ru/post/1263632/


All Articles