I am creating a desktop app that needs to install an SDF file to the SpecialFolder.CommonDocuments folder (C:\Users\Public\documents in Win 7). In a Visual Studio desktop Deployment Project, how do I specify this folder in the File System Editor?
I tried creating a custom folder in the File System Editor and pointing it to the CommonDocuments folder in the Properties pane, like this:
Unfortunately, that specification won't build. I don't want to hard-code a folder path, since it varies between Windows versions. So, how do I specify the CommonDocuments folder in the FileSystem Editor? Thanks for your help.
I figured this one out and documented it for internal purposes. So, I'll just reprint that writeup here:
Visual Studio deployment projects don't support the CommonDocuments folder directly, but we can add that support by using the Launch Conditions Editor, which has a "Search Target Machine" task. We will use the task to search the Windows registry for the path to the Public Documents folder and assign the result to an installer property (actually a variable) called COMDOCFOLDER. We will then use that variable to set the path to a custom folder in the File System Editor.
Here are the steps to perform the task. First, open the Launch Conditions Editor in a Visual Studio deployment project:
Right-click 'Search Target Machine' and select 'Add Registry Search' from the Context menu. A new item will appear (see 1 above). Name it Get Common Documents Folder. In the properties pane (See 2 above), set the 'Property' property (the name of our variable) to COMDOCFOLDER, set the 'Root' property (the Registry root key to search) to vsdrrHKLM, and set the 'RegKey' property (The Registry key to find) to SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders. Notice that we omitted the root key from the 'RegKey' Property. Finally, set the 'Value' property (The name of the value we are searching for within the registry key) to Common Documents. The COMDOCFOLDER variable will now hold the path to the Public Documents folder.
Next, go to the File System Editor in the Visual Studio deployment project:
Right-click 'File System on Target Machine' and select 'Add Special Folder > Custom Folder' from the context menu. A new item will appear (see 1 above). Rename the item Common Documents. In the properties pane (See 2 above), set the 'Property' property to COMDOCFOLDER. I set the 'DefaultLocation' property to the hard-coded value of the CommonDocuments folder for Windows Vista and later; this value would only be used if the COMDOCFOLDER property returned a null value, which shouldn't happen. The installer now has a Common Documents folder that points to the Public Documents folder, as specified in the Windows Registry.
There is more information in this Microsoft Support How-To.
The answer of David Veeneman is great! Helped a lot.
A little correction:
Right-click 'File System on Target Machine' and select 'Add Special Folder > Custom Folder' from the context menu. A new item will appear (see 1 above). Rename the item Common Documents. In the properties pane (See 2 above), set the 'Property' property to
[COMDOCFOLDER]
Those square brackets are necessary, otherwise you'll receive exception while executing the installer.
Related
Is it possible to change the DefaultLocation proprty based on a user choice on a visual stuio 2013 setup project?
I have inserted a radio button dialog in User interface but I don't know how to use the selected button property to change the DefaultLocation propetry, if it is possible.
There already is a usr choice to specify the output directory. The user interface sequence has an InstallFolder dialog where you specify the Application Folder (as it's called in the File System view). That's the way the user browses to a location that is not the default of [ProgramFilesFolder][Manufacturer][ProductName] .
If you want to change the default location and base it on a search then this should work, assuming you have a registry entry defining the location:
Create a custom folder in the file system view, and give it a default location that's the same as the Application Folder setting, and an uppercase Property there called (for example) MYPATH. Put your files there, not Application Folder.
Add a registry search, in Search Target machine in launch conditions, and refer to the key and registry location, and with the Property MYPATH.
At install time the search will set the path to the value in the registry and install the files there.
The problem is that Visual Studio setup projects don't offer all the capabilities of Windows Installer, although other tools do. With other tools you could run code to set the location, just as an example.
For some of my Visual Studio solutions it is creating two DLL files in the bin folder which both appear to have exactly the same name, but when I look at their properties one is an 'Application extension (.dll)' and the other a 'CONFIG File (.config)'.
Why do they both have the same name and why isn't the config one called 'ProjectName.config'?
The file names created by VS are ProjectName.dll and ProjectName.dll.config.
If you are using Windows, it is most likely hiding common file extensions. This makes it appear that the files have the same name. To see the actual name:
Open the folder in Explorer
Navigate to View -> Folder Options -> Advanced
Clear the checkbox for the option "Hide extensions for known file types"
Now you should be able to see the full name of the file along with any extension. More details are available on the following page: Show or hide file name extensions.
For more information about .config files, see Configuration Files.
I have Visual Studio Setup project. And I want to install one of my file to some directory on drive C. How am I supposed to do it?
An example:
I'm installing my app in C:\MyApp. And one file, settings.ini, to C:\Settings\MyAppSettings\
You can try using the WindowsVolume property:
go to File System Editor
right-click the "File System on Target Machine" tree item and select "Add Special Folder" -> "Custom Folder" context menu
rename the new folder to something friendly, for example "C Drive"
select the folder
in its Properties pane set DefaultLocation to [WindowsVolume]
in this custom folder add the folder structure you want (MyApp, Settings etc.)
As this turned up quite high in the Google results - anyone looking to put the file onto a drive that is not the Windows volume (ie a network drive, or if Windows is not on C drive):
Follow the answer provided by #Cosmin above (add special folder in installer's file system), but put the literal drive path in.
Eg set DefaultLocation to c:\MyApp or z:\desired\location.
I've recently created an application for my brother to use, it has several entries stored in the registry that it uses. I created a Setup Application in VS2010 so he can install the application to his PC with ease and set the entries to some default values for him, which he has changed. e.g.
I have a entry called "SummaryFolder" and the value of "Successfully Installed" - so when it was installed it would have the default value. He will have changed this by now to an actual folder on his PC.
Now I've just made a change to the program and added a couple more registry entries, modified the setup application and added in the new entries for installing. I've changed the build number of the setup app, so when he installs the app, it actually UPDATES his existing version. The problem I'm having is that the existing registry entries he has from the initial installation has been overwritten with the default "Successfully Installed" values, hence removing the folder he set.
So my question is: How can I specify for the setup program to only add the registry entries if they DON'T already exist ??? I want to have the installer to be as simple as possible for him.
Many thanks for any help.
You can try this approach:
select your setup project in Solution Explorer
click Launch Conditions editor button at the top of Solution Explorer
add a new registry search and configure it to search for your registry entry
set the search property to something meaningful, for example SUMMARY_FOLDER_REG (only uppercase letters so its a public property)
in the Registry Editor select your registry value
in its Properties pane set the Condition field to the negated search property:
NOT SUMMARY_FOLDER_REG
This way the registry entry is installed only if the search doesn't find anything.
I have a windows setup project that installs a service. All works well except for one thing: The default directory offered to the user during install is of the form "C:\Program Files\Microsoft\ProgramName". I am trying to modify this so that instead of "Microsoft" we would have our company's name.
I found the application folder property of the setup project, and it has a DefaultLocation property of "[ProgramFilesFolder][Manufacturer][ProductName]". So, it looks like all I need to do is set the "Manufacturer" property and I'll be all set. However, I can not find a way to set this property! I had hoped it would take it from the company name in the AssemblyInfo of the primary output project, but it did not.
I could remove "[Manufacturer]" from the DefaultLocation and replace it with our literal company name, but that seems like a hack.
How do I set the Manufacturer name?
Note that I am not using a full-blown WiX project. I have simply added a windows setup project to my solution.
Thanks in advance for any help.
Click on your setup project in Visual Studio, open the Properties and you will notice that there are a number of Properties that you can set like Manufacturer, SupportURL, etc.
Note if you're confused/frustrated doing this seemingly trivial thing: if you open properties by right-clicking on the project and clicking "Properties" in the right-mouse menu, you will get the wrong dialog box. You need to select the project, but then navigate to the properties tag. One way to navigate to the properties tag is from the "View" menu, select "Properties Window".