Problem Background
I'm creating a tool, tha generates MVC solutions(*.sln) and building(with msbuild) them so they could be deployed. Tool requires .NET Framework 4.5.2.
Now I want to generate ASP.NET Core MVC application. Such applications could be run under 4.5.X, but I'm unsure if msbuild could handle project.json(so i'm using packages.config) and I cannot install .NET Core as every tutorial indicate as prerequisite for developing ASP.NET Core. Currently I'm planning to deploy generated applications on Windows.
The Problem:
So instead of .NET Core project I've created a simple console application:
There I've installed there all packages needed, like:
<package id="Microsoft.AspNetCore.Mvc" version="1.0.1" targetFramework="net452" />
And SelfHosted the application using Kestrel:
public class Program {
static void Main() {
var host = new WebHostBuilder()
.UseKestrel()
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
}
I've added Controller with a View. When I do a request, controller is hit, but View cannot be compiled in runtime:

Is this behavior related to the fact I'm using Console Application and not ASP.NET Core Web Application? Is it possible to create a full-featured MVC application as a simple console application?
UPDATE:
I think I've found a workaround inspired from reading github issues:
public void ConfigureServices(IServiceCollection services) {
services.AddMvc()
.AddRazorOptions(options => {
var previous = options.CompilationCallback;
options.CompilationCallback = context => {
previous?.Invoke(context);
var refs = AppDomain.CurrentDomain.GetAssemblies()
.Where(x => !x.IsDynamic)
.Select(x => MetadataReference.CreateFromFile(x.Location))
.ToList();
context.Compilation = context.Compilation.AddReferences(refs);
};
});
}
That seems to make Razor to render my view. But I'm not sure yet if it can be accepted as a solution.

netcopreapp1.0obviously.NET Core Windows Server Hostingto use your IIS as a reverse proxy tokestrel.