如何发布面向框架net461的.NET Core ASP.NET网站?

时间:2016-09-27 16:01:55

标签: .net asp.net-core .net-core asp.net-core-1.0

我需要为IIS发布面向框架net461的.NET核心ASP.NET网站。

我试过了:

dotnet publish --runtime active --output "C:\stuff\" --configuration Release

但是这会导致项目输出为 .exe (以及.nets核心依赖项的.dll,如Microsoft.AspNetCore.Authorization.dll)。我需要在Windows Server 2008 R2上发布到IIS。

"buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true,
    "warningsAsErrors": true
},
"dependencies": {
"Microsoft.AspNetCore.Diagnostics.Elm": "0.1.0",
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Authorization": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Hosting": "1.0.0",
"Microsoft.AspNetCore.Hosting.Abstractions": "1.0.0",
"Microsoft.AspNetCore.Http.Extensions": "1.0.0",
"Microsoft.AspNetCore.Localization": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Routing": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.Session": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Caching.SqlServer": "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"
},

"frameworks": {
    "net461": {}
},

感谢您的帮助!

1 个答案:

答案 0 :(得分:3)

使用.Net Core(Self-contained application)为IIS获取exe输出完全正常。

我使用以下命令发布测试站点:

dotnet publish --configuration Release --output "C:\temp\net461-site"

将IIS指向C:\temp\net461-site(必须有web.config个文件),将App Pool CLR版本更改为No Managed Code,该网站可以运行。