9

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?

Chris
  • 5,876
  • 3
  • 43
  • 69
  • 1
    To me, NuGet is a tool to manage dependencies, meaning libraries. You create a package, and then reference it somewhere else. What does it mean to "reference" a web site? – Alex Buyny Jan 05 '17 at 03:51
  • 7
    @AlexBuyny NuGet packages can be used as a delivery mechanism for websites. Octopus uses them, for example, to handle delivery and versioning: http://docs.octopusdeploy.com/display/OD/Packaging+Web+Apps – Chris Jan 05 '17 at 15:24

2 Answers2

5

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.

smn.tino
  • 2,272
  • 4
  • 32
  • 41
Alex Buyny
  • 3,047
  • 19
  • 25
  • Thanks! I wish it didn't require manual enumeration, but since it's already somewhat required for `dotnet publish`, that may be a satisfactory solution for now. – Chris Jan 18 '17 at 19:47
4

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

Community
  • 1
  • 1
Chris
  • 5,876
  • 3
  • 43
  • 69