C
C#14mo ago
Spaxter

✅ launchSettings.json being ignored completely

All of a sudden, my .NET Visual Studio project has stopped respecting my launchSettings.json file. No matter what profile I run the app with, it uses the ports 5000 and 5001. I have no idea how this happened or why. launchSettings.json
{
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true,
"useSSL": true
},
"WSL": {
"commandName": "WSL2",
"launchBrowser": true,
"launchUrl": "https://localhost:7272/swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "https://localhost:7272;http://localhost:5109"
},
"distributionName": ""
}
},
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:48027",
"sslPort": 44314
}
}
}
{
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true,
"useSSL": true
},
"WSL": {
"commandName": "WSL2",
"launchBrowser": true,
"launchUrl": "https://localhost:7272/swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "https://localhost:7272;http://localhost:5109"
},
"distributionName": ""
}
},
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:48027",
"sslPort": 44314
}
}
}
9 Replies
phaseshift
phaseshift14mo ago
I cant recall exactly, but the behaviour changes a bit depending upon whether your debug target launches 'the project' or iis express. Check the debug drop-down next to the build config option
Spaxter
SpaxterOP14mo ago
My debug target is WSL, I'm not sure which dropdown you want me to check. This is all I see in the "Debug" dropdown you described
No description
No description
phaseshift
phaseshift14mo ago
this thing
No description
Spaxter
SpaxterOP14mo ago
No description
Iron
Iron14mo ago
Make sure you have set your launch profile as the 'Active profile' in Visual Studio by right-clicking on the project in the Solution Explorer and selecting 'Set as StartUp Project'. Then, right-click on the project and select 'Properties', go to 'Debug', and ensure that you have selected the correct launch profile as the 'Launch profile'. Check that the path to 'launchsettings.json' in your project is correct. 'launchsettings.json' is typically located in the root folder of your project, under a folder called 'Properties'. Make sure that you have not overwritten the settings in 'launchsettings.json' in your code or elsewhere. It may be that you have hard-coded a different path for your application to start on, and therefore 'launchsettings.json' is being ignored.
Spaxter
SpaxterOP14mo ago
I tried setting the project as startup project, did not change anything. I also checked the properties, but all is shows me is this, and that just brings me to a UI where I can see all profiles defined in launchsettings.
No description
Spaxter
SpaxterOP14mo ago
The launchsettings is in the same directory it has always been in, the 'Properties' one. And I can not imagine that I would've overriden anything in my code.
walid_4.ab439581062
Do you have a master global json with any ports configurations? Ensure there’s no stray ASPNETCORE_URLS variable set at the system or user level that could be overriding your configuration. Also try cleaning and building again
Spaxter
SpaxterOP14mo ago
Apparently I was adding IConfiguration as a singleton in my Program.cs. Commenting that line out solved it. No idea why but I guess it fixed my issue
Want results from more Discord servers?
Add your server