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

How do I publish a .NET Core ASP.NET website that targets framework net461?

我需要为以框架net461为目标的IIS发布.NET核心ASP.NET网站。

我试过了:

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

但这会导致项目输出为.exe(以及.dlls的dotnet核心依赖项,如microsoft.aspnetcore.authorization.dll)。我需要在Windows Server 2008 R2上发布到IIS。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"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": {}
},

谢谢你的帮助!


使用.NET核心(自包含的应用程序)为IIS提供exe输出是非常好的。

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

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

将IIS指向C:\temp
et461-site
(必须有web.config文件),将app pool clr版本更改为No Managed Code版本,站点工作。