ASP.NET 核心项目的发布命令仅包含 DLL 文件

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

我正在尝试发布一个ASP.NET核心1.0项目,以便能够将其部署到Azure(或其他托管环境)稍后。

我的文件夹结构如下(不确定是否重要):

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

root 文件夹我 运行 发布命令如下:

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

这将创建一个包含 publish 命令输出的文件夹,但它 仅包含程序集 (DLL 文件)和一个名为 refs 的文件夹,其中包含引用的大会。

我的问题是:如何创建一个完整的发布包,包括HTML、JavaScript、CSS、配置文件等所有静态资源?

我的 project.json 文件中是否缺少某些内容,或者 publish 命令的某些参数?我一定是遗漏了什么,但我想一定有某种方法可以指定 src 文件夹等应该包含在输出中?

我的 project.json 文件如下所示:

{
  "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/"
  }
}

您需要像这样在 project.json 中添加 publishOptions 部分:

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