Skip to content

Suddenly "dotnet watch" runs in "Production" environment #44363

@Apollo3zehn

Description

@Apollo3zehn

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Yesterday I first read about the new Ubuntu packages (https://devblogs.microsoft.com/dotnet/dotnet-6-is-now-in-ubuntu-2204/), today morning I updated my system (Kubuntu 22.04) and then I suddenly had the problem of missing SDKs. I thought it was maybe related to the new Ubuntu packages and conflicting versions. So I removed the old packages and cleanly reinstalled the SDK from the Ubuntu repository. I was also able to install the wasm-tools workload but now "dotnet watch" runs in "Production" environment and breaks my app. I am not 100% sure it is due to the Ubuntu provided SDK but it is very likely.

I tried to revert to the Microsoft package source to get the old behavior but I failed to find proper instructions to do so. Then I tried the Snap version and that fails with a segmentation fault ...

The only (maybe) related issue I found is this one (dotnet/core#7715)

As a workaround I extended my tasks.json with a new environment variable:

{
    "version": "2.0.0",
    "options": {
        "env": {
            "ASPNETCORE_ENVIRONMENT": "Development"
        }
    },
    "tasks": [
        ...

Expected Behavior

I expect that dotnet watch runs in the "Development" environment.

Steps To Reproduce

  • Run dotnet new blazorwasm --hosted.
  • Open the project in vscode
  • Add Console.WriteLine("The current environment is " + Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")); to Program.cs in the Server project
  • Run "watch" task (Ctrl+Shift+P -> "Run task" -> "watch")

The output is The current environment is <empty>

and a few lines later:

info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production

Exceptions (if any)

No response

.NET Version

6.0.108

Anything else?

dotnet --info:

.NET SDK (reflecting any global.json):
 Version:   6.0.108
 Commit:    4e3a463d2b

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         ubuntu.22.04-x64
 Base Path:   /usr/lib/dotnet/dotnet6-6.0.108/sdk/6.0.108/

global.json file:
  Not found

Host:
  Version:      6.0.8
  Architecture: x64
  Commit:       55fb7ef977

.NET SDKs installed:
  6.0.108 [/usr/lib/dotnet/dotnet6-6.0.108/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.NETCore.App]

Download .NET:
  https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Author FeedbackThe author of this issue needs to respond in order for us to continue investigating this issue.area-commandlinetoolsIncludes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPIfeature-hot-reloadThis issue is related to the Hot Reload feaature

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions