发布ASP.NET Core 程序到 IIS
参考:https://docs.microsoft.com/en-us/aspnet/core/publishing/iis
环境:Win10 64位+IIS10。经测试,在Win7 64位II7.5也是可以发布的。
注意:截止到2017-3-4,IIS 不支持部署ASP.NET Core 1.1 类库的程序,只支持1.0类库程序,如果程序用到的类库升级到了1.1,请降级到1.0。
IIS 配置(IIS configuration)
Enable the Web Server (IIS) server role and establish role services.
Windows desktop operating systems
Navigate to Control Panel > Programs > Programs and Features > Turn Windows features on or off (left side of the screen). Open the group for Internet Information Services and Web Management Tools. Check the box for IIS Management Console. Check the box for World Wide Web Services. Accept the default features for World Wide Web Services or customize the IIS features to suit your needs.
Windows Server operating systems
For server operating systems, use the Add Roles and Features wizard via the Manage menu or the link in Server Manager. On the Server Roles step, check the box for Web Server (IIS).
Install the .NET Core Windows Server Hosting bundle
- Install .NET Core Windows Server Hosting on the server. The bundle will install the .NET Core Runtime, .NET Core Library, and the ASP.NET Core Module. The module creates the reverse-proxy between IIS and the Kestrel server. Note: If the server doesn't have an Internet connection, obtain and install the Microsoft Visual C++ 2015 Redistributable before installing the .NET Core Windows Server Hosting bundle.
- Restart the server or execute net stop was /y followed by net start w3svc from a command prompt to pick up a change to the system PATH.
Configure the website in IIS
- On the target IIS server, create a folder to contain the application's published folders and files, which are described in Directory Structure.
- In IIS Manager, create a new website. Provide a Site name and set the Physical path to the application's deployment folder that you created. Provide the Binding configuration and create the website.
- Set the application pool to No Managed Code(无托管代码). ASP.NET Core runs in a separate process and manages the runtime.
- Open the Add Website window.
-
Configure the website.
- 在应用程序池控制面板中,在网站的应用程序池上单击鼠标右键,从弹出的菜单中选择基本设置。
- 设置.NET CLR 版本"成无托管代码**。
从Visual Studio 中导出网站
-
工程上单击鼠标右键,从弹出的的菜单中选择Publish:
-
Profile 中选择Custom:
-
Settings 中的File Publish Options 选择Delete all existing files prior to publish: