In my ASP.NET WebAPI (not Core!) project, I would like to use the SDK-based csproj format. I converted the project and got it to build:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<OutputType>Library</OutputType>
</PropertyGroup>
Now when I run it using IIS Express, I get:
Waiting for the IIS Express worker process to start…
Worker process has been started: 22108
A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Code\MyWebApp\MyWebApp\bin\Debug\net461\'.
Failed to run as a self-contained app. If this should be a framework-dependent app, add the C:\Code\MyWebApp\MyWebApp\bin\Debug\net461\MyWebApp.runtimeconfig.json file specifying the appropriate framework.
I've seen this answer to a similar question that suggests adding a .runtime.config file but I believe it is only required for .NET Core apps.
I don't want to migrate to .NET Core at this point. All I wanted was to use the new project format to get rid of some nasty binding redirects. I.e. I only wanted to change my build tooling and leave everything as is at run time.
My launchsettings.json:
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:59119",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true
}
}
}
These are the changes I made: Pull request