Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IIS Express profile launchSettings.json does not add environment variables in the iisexpress.exe process #65

Closed
morindo opened this issue Jun 14, 2023 · 5 comments
Labels
known limitation This issue is related to a known limitation and cannot currently be fixed.

Comments

@morindo
Copy link

morindo commented Jun 14, 2023

Our current Web app csproj is currently using the great (and thank you so much) MSBuild.SDK.SystemWeb/4.0.88 Sdk and when we launch the IIS Express profile (in debug or without debugging) from VS 2022, it does add the environment variables to the iisexpress.exe process, is this normal? Notice that it is working with a default ASP.NET Core Web App default project.

This is our launchSettings.json

  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:51867/",
      "sslPort": 44301
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": false,
      "environmentVariables": {  // This does not work
        "ASPNETCORE_ENVIRONMENT": "Development",
        "AAA": "BBB"
      }
    }
  }
}
@CZEMacLeod
Copy link
Owner

@morindo Thanks for flagging this. I've done some testing and it looks like whatever logic/code VS uses to launch IISExpress, does not add the environmentVariables when in the MSBuild.SDK.SystemWeb.
It does not appear to be a difference relating to hosting dotnet core vs dotnet framework in IIS itself (which was actually my first though) but actually something in the launch code.
This bit of code is built into VS itself, so I can't easily debug or find what/why it doesn't work as expected.
I've also done a bit of testing with launchSettings.json / launch profiles for console apps, and it seems to work with both net6 and net48 (framework) and correctly set the environment variables as expected. (This is with commandName set to Project).
I'll see if I can dig into this a bit more, but it might need some help from the VS team here.

@morindo
Copy link
Author

morindo commented Jun 14, 2023

Thank you very much @CZEMacLeod for the quick response. Good hunch, I'll look into-it myself. I'll post if I find something.

@swissarmykirpan
Copy link

@morindo @CZEMacLeod any progress on this?

@morindo
Copy link
Author

morindo commented Dec 6, 2023

@swissarmykirpan unfortunately, I didn't find a way to make IISExpress use the launchSettings.json environment variable.

@morindo morindo closed this as completed Dec 6, 2023
@julealgon
Copy link

Ran into this behavior today. @CZEMacLeod should this be tagged with the known limitation label?

Additionally, is there any known workarounds to this issue besides just forcing a system-wide environment variable?

@CZEMacLeod CZEMacLeod added the known limitation This issue is related to a known limitation and cannot currently be fixed. label Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
known limitation This issue is related to a known limitation and cannot currently be fixed.
Projects
None yet
Development

No branches or pull requests

4 participants