Creating folders in a Visual Studio installer installation project

I built a Visual Studio installer (2010) installer installation project to deploy the main WinForms application, and I need my installer to create a couple of directories based on the OS in which it runs. For example, when the installer runs on Windows XP (and earlier), I need to create:

Application Folder\NewFolder 

If the installer is running in Vista or later, I need to create a directory under the application data shared folder (i.e. C: \ ProgramData) as follows:

 Common Application Data Folder\NewFolder 

I see that I can add "Custom Folder" through View β†’ "File System", but I'm not sure how to declare the DefaultLocation property for this new folder. The default value is [TARGETDIR], but I do not know how to specify the location of the directory that I want to create. Is it possible to do this using the Visual Studio Installer installation project or am I lucky?

+4
source share
3 answers

I finally got this working by adding both folders to my installation project via View -> File System. Then I set the condition for each folder. For the folder that I want to create on XP, I used "WindowsBuild <6000" and for the Vista / Windows 7 folder, I used "WindowsBuild> = 6000".

+3
source

This is not supported by Visual Studio installation projects.

Other settings creation tools support this with a custom action of type 51 (the property is specified by formatted text).

Basically, your TARGETDIR can by default point to one location, and a custom action of type 51 can change it to another location during installation. This custom action may be due to the VersionNT property .

+3
source

In a special folder, you can set DefaultLocation to [CommonAppDataFolder].

In XP, this will allow c: \ documents and settings \ all users \ application data

And in Win 7, this will allow c: \ ProgramData p>

0
source

Source: https://habr.com/ru/post/1379492/


All Articles