Visual-studio – Creating folders in a Visual Studio Installer Setup project

setup-projectvisual studiowindows-installer

I've built a Visual Studio (2010) Installer Setup project to deploy a basic WinForms app and I need my installer to create a couple of directories based on the OS that its running on. For example, when the installer is run on Windows XP (and earlier), I need to create:

Application Folder\NewFolder

If the installer is running on Vista or later, I need to create the directory below the Common Application Data Folder (i.e., C:\ProgramData) like this:

Common Application Data Folder\NewFolder

I see that I can add a "Custom Folder" via View -> "File System" but I'm not sure how to declare the DefaultLocation property for this new folder. It defaults to a value of [TARGETDIR] but I'm uncertain how to specify the location of the directory that I want to create. Can this be done with a Visual Studio Installer Setup project or am I out of luck?

Best Answer

This is not supported by Visual Studio setup projects.

Other setup authoring tools support this through a type 51 custom action (property set with formatted text).

Basically, your default TARGETDIR can point to one location and a type 51 custom action can change it to another location during install. This custom action can be conditioned with VersionNT property.