Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to package an ASP.NET Core app, using NuGet or otherwise?

I'm building a ASP.NET Core app which I can publish using dotnet publish. So far, so good.

I'm interested in packaging that app so I can publish it on a NuGet server. dotnet pack, however, doesn't seem to contain enough information to recreate the website on its own -- just the dll file.

Is there a way to create a NuGet package, through dotnet pack or some other method, or do I need to manually package the files in the output directory myself?

like image 516
Chris Avatar asked Jan 04 '17 20:01

Chris


People also ask

Does .NET core use NuGet?

NET (including . NET Core), the Microsoft-supported mechanism for sharing code is NuGet, which defines how packages for . NET are created, hosted, and consumed, and provides the tools for each of those roles.

What is NuGet package in asp net core?

NuGet is a powerful ecosystem of tools and services. It was introduced in 2010 as an open source package manager for the Microsoft development platform including . NET. NuGet is the easiest way to improve and automate your development practices.


2 Answers

You can manually configure packOptions setting in project.json file to contain folders/files that you need, for example

"packOptions": {
    "files": {
        "include": [ "wwwroot/**.*", "Views/**.*" ] --add anything else that you need in here
    }
}

Then run

dotnet pack

This worked for me. The package now contains images, js files etc.

like image 159
Alex Buyny Avatar answered Oct 19 '22 21:10

Alex Buyny


As of 1/2017, there's no way one step way to do this, though ASP.NET Core is so fresh at the moment that I'm still hoping for a newer and better answer.

The best way to create a single file package for a ASP.NET Core website is to publish your app using dotnet publish, and package the directory using a ZIP utility (or Octo.exe if you need a NuGet package for Octopus).

Current tools as of 2017/1: Octopack, which uses NuGet, cannot package .NET Core projects. NuGet itself is a minimal tool which requires a manifest or project file to work, and dotnet pack will only pack up the source files, and not assets (see the answer below for ways around that).

like image 36
Chris Avatar answered Oct 19 '22 19:10

Chris