ASP – Build Differences Compared to the CLI

Rider ASP Build-Issues (Linux). Since first starting with Rider there has been an issue which has plagued me. Building web-apps in Rider sometimes give different behaviour compared to building them using the CLI (command-line interface). It is also worth noting that this issue does not seem to affect all systems. However, I have now experienced this through three versions of Ubuntu and multiple versions of Rider. Jetbrains support has thus far been responsive but not offered any solutions.

At the time of writing the version of Rider used was 20.3.2 and the operating system Ubuntu 20.04.

Page not found (404) with a default web-app.

When creating a default web application gives page is not found (404) when building with Rider. Surprisingly, this is true with and without Re-Sharper enabled in the build settings. Consequently, the same result is seen is both scenarios.

Create A Default Web Application

Rider Default Web App Creation
Create a Default Web App With Rider

Build Using Default Settings (Re-Sharper Enabled)

Rider Web Application - Build With Rider - Using Re-Sharper - Rider ASP Build-Issues (Linux)
Rider Web Application – Build With Rider – Using Re-Sharper

Build Using Rider with Re-Sharper Disabled

Web-App Build With Rider - No Re-Sharper
Web-App Build With Rider – No Re-Sharper

Build Using the CLI

Build a default web application using the CLI
Build a default web application using the CLI

Page not found – Workarounds – Rider ASP Build-Issues (Linux)

Workaround 1. Build using the command line and attach the debugger separately

Workaround 2. Setup Razor Runtime Compilation

  • Add Nuget Package: Microsoft.AspNetCore.Mvc.RazorRuntimeCompilation
  • Add an extra line to launchSettings.Json (Properties folder)
Install Razor Runtime Compilation
Install Razor Runtime Compilation

Add:

"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:19595",
      "sslPort": 44314
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "Website": {
      "commandName": "Project",
      "dotnetRunMessages": "true",
      "launchBrowser": true,
      "applicationUrl": "https://localhost:5001;http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development",
        "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
      }
    }
  }
}
Another Oddity – The library ‘libhostpolicy.so’ not found.

After setting up Razor run time compilation as described above, if the application has never been built using the command line it will now launch correctly. However, if the application has already been built using the command line it will fail; saying The library ‘libhostpolicy.so’ is not found.

Rider - libhostpolicy.so not found - Rider ASP Build-Issues (Linux)
Rider – libhostpolicy.so not found

To fix this, clean and then rebuild the solution. Both options are in the Build menu.

Rider With Razor Run Time Compilation - Linux
Rider With Razor Run Time Compilation – Linux

Models Not Found after Scaffolding 2 Factor Authentication – Rider ASP Build-Issues (Linux)

For full details on the process to reach this point is found in these two articles:

Build Errors in Rider not found using the command line - Rider ASP Build-Issues (Linux)
Build Errors in Rider not found using the command line
2 Factor Scaffold Build CLI
2 Factor Scaffold Build CLI

Models Not Found after Scaffolding 2 Factor Authentication – Workaround

Build using the command line and attach the debugger separately.

Leave a Comment

Your email address will not be published. Required fields are marked *