Is it possible to conditionally set the default virtual directory in a Visual Studio Web Setup/Installer Project?

62 Views Asked by At

I'm working on a C# app in Visual Studio 2022 and I have added a Visual Studio Web Setup/Installer project. Once I added the project, I right-clicked it and selected View > File System. In the File System window, I right-clicked the Web Application Folder and selected Properties. In the Properties window, I scrolled to the bottom and entered the name of my virtual directory that I have configured/associated with the application under Default Website in IIS.

This will work fine for my development/test environment when I install the .msi, but once the app gets deployed to the production environment (i.e. the .msi is installed), the virtual directory/application is different (not by choice, especially my choice) and I'd like to have the virtual directory value on the setup wizard to default based on the environment. In other words, if the .msi is installed on the development/test environment, I'd like for the virtual directory on the setup wizard to MyAppTest, while production should have a virtual directory in the setup wizard set to MyAppProd.

I'm able to manually type in the value, but I'd like to have it default because I may not be the person installing it and people don't always read instructions.

Is there something that can be done to make this work in IIS or maybe with a custom installer class? I have seen another post about using Orca, but that's a bit more involved and I was hoping to keep it fairly simple. Also, Wix really isn't an option, for what it's worth.

Just some extra info, I'm using "Textboxes (A)" in the User Interface for the setup project. All of the "Edit" items are hidden and I have set the first one, Edit1, to populate TARGETAPPPOOL. I tried setting the second one to TARGETVDIR, which appears to set the value, but it's not conditional based on environment.

Thanks!

0

There are 0 best solutions below