Search code examples
asp.netasp.net-coredotnet-cli

Publish command for ASP.NET Core project only includes DLL files


I'm trying to publish an ASP.NET Core 1.0 project, in order to be able to deploy it to Azure (or other hosting environments) later on.

My folder structure is as follows (not sure if it matters):

|_Root
  |_Foo
    |_Bar -> contains project.json

From the root folder I run the publish command like so:

dotnet publish Foo/Bar -o artifacts\FooBarOutput --configuration Release

This creates a folder with output from the publish command, but it only contains assemblies (DLL files) and a folder called refs containing referenced assemblies.

My question is: how do I create a complete publish package, including all static resources such as HTML, JavaScript, CSS, configuration files, etc?

Am I missing something in my project.json file, or some parameters for the publish command? I must be missing something, but I guess there must be some way to specify that the src folder etc should be included in the output?

My project.json file looks like the following:

{
  "title": "My Web App",
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true,
    "preserveCompilationContext": true, 
    "compile": {
      "exclude": [ "bin/**", "obj/**", "node_modules/" ]
    }
  },
  "dependencies": {
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
    "System.IO.FileSystem": "4.0.1"
  },
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0"
        },
        "Microsoft.AspNetCore.Server.Kestrel": "1.0.0"
      },
      "imports": "dnxcore50"
    }
  },
  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel --server.urls=http://*:8000/"
  }
}

Solution

  • You need to add publishOptions section in your project.json like this :

    "publishOptions": {
        "include": [
            "wwwroot",
            "Views",
            "web.config",
            "appsettings.json",
            "appsettings.*.json",
            "..."
        ]
    }