1

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

Sergey Slepov
  • 1,861
  • 13
  • 33
  • That's exactly why Microsoft didn't waste their time on moving those legacy project types to the new project format. – Lex Li Apr 23 '20 at 02:44

1 Answers1

0

The ASP.NET team have responded:

This is not possible, sdk-based projects are not suited for traditional aspnet/webapi projects and it is likely you'll see a long trail of issues if you try to use them.

I was so close to getting it to work!

Sergey Slepov
  • 1,861
  • 13
  • 33