Visual Studio 2010 update registry in setup application - visual-studio

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.

Related

Visual studio setup project: default installation location based on user choce

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.

Template store path is invalid. Please make sure it exists or can be created: Unexpected path [path]

I get this on my work machine (Win7 64bit), and this happens every time I open VS2010, and this is what I've done so far:
1. set folder properties (projects, project templates and item templates) from Import & export settings.
2. set projects, project templates and item templates paths from Options/Projects & Solutions.
3. found and manually set registry value that points to the above properties.
so every time I close VS 2010, nothing seems to save and I get the above error again and I find all values that I have set back to where it was.
I began getting this error after installing TFS Power Tools, and it looked to be related to that rather than to VS2010 itself.
I fixed it by going to Tools->Options, expanding Team Foundation Server Power Tools, clicking Work Item Template, and setting the default template store path to a path of my choice.
Once I saved that the message went away and I was able to start up my IDE unharassed.

How to setup Installer project with conditional file copying

I am building a VS 2010 installer, and I want to copy files to app folder depending on what options I select in UI (UI is not simple, so the only option is to show custom dialogs in Install custom action).
The problem is that custom action is actually executed after files are copied already.
One possible solution I can think of is to install all these files into the app dir, and then delete some unnesessary files in custom action. But these files are "secure" in some way, so I don't want to copy them to filesystem, even for a short period of time.
Any thoughts?
If your files shouldn't ever be on the filesystem, you have a problem in the requirements. The .msi storage itself is an open format and can be read by many tools, so if someone knows the file it's possible for them to find and extract it manually.
I agree that it's better to avoid deleting the files after they've been installed for two reasons. One: it avoids wasted work, and two: it won't cause repair scenarios due to missing files that Windows Installer thinks should be present. You should probably figure out how to determine whether these files should be present at an earlier stage of the installation, and set properties that cause this to happen (disable components by condition, or change feature states).
Most controls in MSI dialogs use installer properties. For example, a checkbox may use a property named MY_CHECKBOX which is set to a value or it's empty, based on whether the checkbox is checked or not.
These properties can be used to condition files:
select your setup project in Solution Explorer
click File System Editor button from Solution Explorer top pane
select the file you want to condition
in its Properties pane set Condition field to the condition you want, for example
MY_CHECKBOX = "value"

Visual Studio Setup Project - conditionally install file

I have a VS 2008 Setup project. I only want to install an XML file if it does not already exist on the target system. The installer overwrite rules for non versioned files ensure that a file will never be overwritten if it has not been modified on the target system. But I want to never overwrite the file. There is a Condition property that can be set on a file in the Visual Studio installer properties for a file. What is the correct syntax for the Condition property to check for existence of file and only install if it is not there?
You will need to go to the Launch Conditions tab and search the target computer for the file you want to check for. The launch condition will let you specify the name of a property it will set to the path of the file if it exists, otherwise it will be empty. You can now use this property as the condition on your file.
I was able to use a launch condition to set a property, and use this for a conditional install of a file, so I will mark 'heavyd' as the correct answer. However, was not able to use the file search effectively, as was suggested (see comments on the answer). Instead, I used a Windows Installer Search (one of the three types of searches available in a VS 2008 Setup Project) with the MSI ComponentID, as follows (I found the technique here):
Product 1 is installed and has a file named MyFile.txt.
You use ORCA (from the Windows Installer SDK) to view the File table, and find the row that represents MyFile.txt.
You get the value of the Component_ column and then open the Component Table.
In the Component Table you find the row that has the Component_ value in the Component column, and get the ComponentID. Copy this value into clipboard. Close ORCA.
In your setup project, open the Launch Conditions Editor and add a Windows Installer Component Search. For the ComponentID property of the new search, paste the ComponentID.
Copy the Property property. It should be something like COMPONENTEXISTS1.
Open the File System Editor and select the Application Folder, then select the file you want to conditionally install.
Edit the Condition property to be COMPONENTEXISTS1 = FALSE.
Set the Transitive property to true if you want the condition to be evaluated each time the installer is run (not just the first time).
Now, MyFile.txt will only be installed if it is not already there.
There is one caveat with this technique: Doing a repair on the installation will cause the file to be deleted, even though the file is marked as Permanent! Not good. I worked around this by adding some custom actions (calling vbscript files) to backup and restore my file.
What a hassle to just achieve so simple a task: install a file once on initial install, then, never again overwrite it.
If anyone has a better solution, I am all ears.

Setting the manufacturer in a VS 2008 Setup Project

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".

Resources