Reputation: 12729
In Visual Studio 2015 you could easily set an MVC app to use full IIS by right clicking on the project & going to properties.
It's not clear how to do this in a vanilla .NET Core Web (MVC) project in Visual Studio 2017.
I can find nothing about this on Google - am I looking in the wrong place?
Upvotes: 4
Views: 6071
Reputation: 252
You can host it behind iis.
There are basicly four things you have to do besides having iis installed offcourse:
Install the .NET Core Windows Server Hosting bundle. It can be found here https://go.microsoft.com/fwlink/?linkid=837808
Include a dependency on the Microsoft.AspNetCore.Server.IISIntegration package in the application dependencies. Incorporate IIS Integration middleware into the application by adding the .UseIISIntegration() extension method to WebHostBuilder().
Open cmd and run dotnet publish in your project
host published application on iis. It is important that in application pool the .NET CLR version is set to 'No Managed Code'.
There is a more detailed article on how to publish your application to iis.
https://learn.microsoft.com/en-us/aspnet/core/publishing/iis
I didn't find a way to do it directly from visual studio 2017.
Update: you could use FlubuCore tool (C# fluent builder) to do step 3 and 4 for you automatically. You'd have to write flubu script that would look something like this(example is only for step 4):
protected override void ConfigureTargets(ITaskContext session)
{
session.CreateTarget("iis.install").Do(IisInstall);
}
private static void IisInstall(ITaskContext context)
{
context.Tasks().IisTasks()
.CreateAppPoolTask("SomeAppPoolName")
.ManagedRuntimeVersion("No Managed Code")
.Mode(CreateApplicationPoolMode.DoNothingIfExists)
.Execute(context);
context.Tasks().IisTasks()
.CreateWebsiteTask()
.WebsiteName("SomeWebSiteName")
.BindingProtocol("Http")
.Port(2000)
.PhysicalPath("SomePhysicalPath")
.ApplicationPoolName("SomeAppPoolName")
.WebsiteMode(CreateWebApplicationMode.DoNothingIfExists)
.Execute(context);
}
And then to integrate it with visual studio 2017 run this script with flubu dotnet cli tool in prebuild or postbuild event with command 'dotnet flubu iis.install'. I Would rather run the tool from command line explicitly.
You can find more information about flubu and how to get started here: Choice for build tool: MSBuild, NANT or something else?
Upvotes: 4