Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

System.ArgumentException when trying to debug a Blazor Web App #19

@bakerhillpins

Description

@bakerhillpins

When trying to use the debugger on a Pi where you're downloading a Blazor Web App the call to var builder = WebApplication.CreateBuilder(args); results in:

System.ArgumentException: 'The path must be absolute. (Parameter 'root')'

Took me a bit to figure out what was going on here. A brand new Blazor Web App using VS 17.7.4 doesn't have this issue. But the one I generated previously (several months ago) did. It turns out that the key to getting this exception or not lies in the launchSettings.json file. Specifically, newer Blazor apps created with the VS template create a different set of profiles than older ones.

Older VS Blazor Apps would create a profile named the same as the Project:

"profiles": {
  "MyNewBlazorProjectName": {
    "commandName": "Project",
    "dotnetRunMessages": true,
    "environmentVariables": {
      "DOTNET_ENVIRONMENT": "Development"
    }
  }

The newer template creates an http and an https profile instead:

  "profiles": {
    "http": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "dotnetRunMessages": true,
      "applicationUrl": "http://localhost:5151"
    },
    "https": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "dotnetRunMessages": true,
      "applicationUrl": "https://localhost:7007;http://localhost:5151"
    },

The Pi Debugger app specifically looks for the project named profile and then adds in ASP .NET environment variables. When the profile named for the project doesn't exist this is skipped.

The addition of the "ASPNETCORE_ENVIRONMENT": "Development" envt variable causes this throw.

I'm putting this in as an issue so others may understand what's going on. I'm looking into how to deal with this but my project focus has shifted for a few months so I don't know if I'll get more opportunity to dabble here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions