Template: set ASPNETCORE_WEBROOT in launchSettings.json instead of WebRootPath once on net11

Open Beginner friendly
#773 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
backend

Research direction

Read the template's Program.cs and launchSettings.json, and confirm the template has moved to the .NET 11 SDK before changing them. Move the ASPNETCORE_WEBROOT setting and its comment into the launch profile, then remove WebRootPath from Program.cs. Done means a fresh clone still starts without wwwroot, while standard web-root overrides remain available.

Written by the indexing model from the issue text.

Description

The template's Program.cs sets the web root in code:

var builder = WebApplication.CreateBuilder(new WebApplicationOptions
{
    Args = args,
    // Explicit declaration prevents ASP.NET Core from erroring if wwwroot doesn't exist at startup:
    WebRootPath = "wwwroot"
});

Setting WebRootPath there overrides ASPNETCORE_WEBROOT and --webroot, so a project can't point a second instance (for example one run by a tool alongside the dev instance) at a different web root without changing code.

Setting it in the launch profile keeps the fresh-clone protection and leaves the standard override working:

"environmentVariables": {
  "ASPNETCORE_ENVIRONMENT": "Development",
  // Explicit, so ASP.NET Core doesn't error when wwwroot doesn't exist yet on a fresh clone.
  "ASPNETCORE_WEBROOT": "wwwroot"
}

and Program.cs drops WebRootPath.

This needs the .NET 11 SDK. Before it, dotnet run fails to apply a launch profile that contains comments ("'/' is an invalid start of a property name"), fixed by dotnet/sdk#54820 and not backported to 10.0.x. So: once the template moves to net11, move the setting to launchSettings.json, with the comment.

Dominant language
C#
Stars
81
Forks
24
PR merge metrics
No merged PRs in 30d

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from IntelliTect/Coalesce

All issues in IntelliTect/Coalesce

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.