我正在尝试发布 ASP.NET Core 1.0 项目,以便稍后能够将其部署到Azure(或其他托管环境)。
我的文件夹结构如下(不确定是否重要):
|_Root
|_Foo
|_Bar -> contains project.json
从 root 文件夹中运行publish命令,如下所示:
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/"
}
}
答案 0 :(得分:3)
您需要在project.json中添加publishOptions
部分,如下所示:
"publishOptions": {
"include": [
"wwwroot",
"Views",
"web.config",
"appsettings.json",
"appsettings.*.json",
"..."
]
}