Page 1 of 1

Visual Studio 2022 setzt ASPNETCORE_URLS und ASPNETCORE_HTTPS_PORT zwangsweise, wodurch meine Kestrel-Konfiguration besc

Posted: 17 Jan 2025, 09:24
by Anonymous
Visual Studio 2022 fügt weiterhin Umgebungsvariablen ein – ASPNETCORE_URLS und ASPNETCORE_HTTPS_PORT – die ich nie in meiner launchSettings.json deklariert habe. Dies steht in Konflikt mit meiner benutzerdefinierten Kestrel-Konfiguration.
Hier ist eine minimale Konsolen-App, um es zu beweisen:

Code: Select all

using System.Net;

namespace LaunchTrouble;
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine($"ASPNETCORE_URLS - {Environment.GetEnvironmentVariable("ASPNETCORE_URLS")}");
Console.WriteLine($"ASPNETCORE_HTTPS_PORT - {Environment.GetEnvironmentVariable("ASPNETCORE_HTTPS_PORT")}");

Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
// webBuilder.UseStartup();
webBuilder.UseKestrel(options =>
{
options.Listen(IPAddress.Any, 5111);
options.Listen(IPAddress.Any, 5222, listenOpts =>
{
listenOpts.UseHttps();
});
});

// Basic pipeline to avoid Startup overhead
webBuilder.Configure(_ => {});
})
.Build()
.Run();
}
}
Und hier ist meine launchSettings.json:

Code: Select all

{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"Dev": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Protokolle von Visual Studio (F5 im „Dev“-Profil):

Code: Select all

ASPNETCORE_URLS - https://localhost:5001/;http://localhost:5000/