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

2.7k views Asked by At

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?

2

There are 2 answers

0
Chris On

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).

1
Alex Buyny On

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.