dotnet / dotnet/sdk

Change in argument handling in `dotnet run` between 9.0.103 and 9.0.200

Open
#46,912 2 comments 0 reactions 0 assignees View on GitHub
Area-WebSDK untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Describe the bug
There seems to be a regression/change of behavior in how `dotnet run` handles command line arguments.

I have an ASP.NET core application targeting .NET 9. We have migrated from SDK 9.0.103 to 9.0.200 last week and immediately started having issues with our test pipelines. I tracked the issue to the behavior of `dotnet run`.

Our command line: `dotnet run --environment UiTests --urls https://localhost:7139`

In 9.0.103, this produced the following output (parts omitted for brevity):
```
Using launch settings from [path]\launchSettings.json...
Building...
[11:57:51 INF] User profile is available. Using '[user profile]\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
[11:57:52 WRN] The ASP.NET Core developer certificate is not trusted. For information about trusting the ASP.NET Core developer certificate, see https://aka.ms/aspnet/https-trust-dev-cert
[11:57:52 INF] Now listening on: https://localhost:7139
[11:57:52 INF] [app] application 'Started'
[11:57:52 INF] Application started. Press Ctrl+C to shut down.
[11:57:52 INF] Hosting environment: UiTests
[11:57:52 INF] Content root path: [root path]
```

In 9.0.200, this has changed:
```
Using launch settings from [path]\launchSettings.json...
Building...
[11:59:36 INF] User profile is available. Using '[user profile]\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
[11:59:37 WRN] The ASP.NET Core developer certificate is not trusted. For information about trusting the ASP.NET Core developer certificate, see https://aka.ms/aspnet/https-trust-dev-cert
[11:59:37 INF] Now listening on: https://localhost:7139
[11:59:37 INF] [app] application 'Started'
[11:59:37 INF] Application started. Press Ctrl+C to shut down.
[11:59:37 INF] Hosting environment: Development
[11:59:37 INF] Content root path: [root path]
```

Note the difference in `Hosting environment`. It looks like in 9.0.200, the `--environment` was not passed to the application being run.

If I change the command line to `dotnet run -- --environment UiTests --urls https://localhost:7139`, we get the expected output:
```
Using launch settings from [path]\launchSettings.json...
Building...
[12:02:14 INF] User profile is available. Using '[user profile]\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
[12:02:14 WRN] The ASP.NET Core developer certificate is not trusted. For information about trusting the ASP.NET Core developer certificate, see https://aka.ms/aspnet/https-trust-dev-cert
[12:02:14 INF] Now listening on: https://localhost:7139
[12:02:14 INF] [app] application 'Started'
[12:02:14 INF] Application started. Press Ctrl+C to shut down.
[12:02:14 INF] Hosting environment: UiTests
[12:02:14 INF] Content root path: [root path]
```

I wasn't able to find any documentation about this change, in fact, [this documentation](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-9.0#set-environment-on-the-command-line) still contains the old format without the `--` separator. Is this change expected? If so, I think this is a breaking change that should be documented somewhere. If not, I guess this is a bug report.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.