How to manage updates of WPF app with Visual Studio Installer - c#

I have WPF application who is possible to update when is have new version. For create installer I will use Visual Studio Installer. I understand how to auto update my app, but this is not exactly what I want.
I want when user check is want to "Automatically check for updates" only then is check do is have new updates. Like in the picture
My question is: Is it possible with Visual Studio Installer to manage update for application. When user is checked then if is possible to update to new version. If user not checked then the application is not check for new version.
Im sorry for my bad English. Thanks in advice.

It's not very clear whether you want that checkbox in the installer itself or in the app. All the instances I've seen are in the app. There's no point in putting the check in the installer because the user does that just once, and updates may be generated after the product has been installed. You cannot run the same install again! So this check is added to the app, and the implementations I've built do a web service call to the company web site (passing in the installed product's version, ProductCode, UpgradeCode) and if there is an update the app downloads it. The user may or may not be able to install the upgrade if it requires elevated privilege and the user has limited privileges.
The supported upgrade mechanism with VS setups is to increment the setup project's version property, accept the requested changes, rebuild the entire MSI with incremented file versions for the files you need updating, and set RemovePreviousVersions to true to upgrade the entire product.

Related

Detect All Users .msi

I wrote a C# program in Visual Studio that uses the Setup & Deployment Project to create an .msi installer. The "InstallAllUsers" value is set to "True", so it'll install "Everyone" by default, but the users can change it to "Just Me" during setup.
It's just a basic installer - nothing fancy.
My question is this: after they install the program, is there a way to tell which option they chose? Is there a registry key that I can dig for that will tell me whether they chose "Everyone" or "Just Me" during install? I'm not programmatically adding any registry keys, and I can find the "Uninstall" key for my program, but I don't know if there's a value in there that will tell me.
* EDIT *
For a clearer picture:
As I make changes to my program, I increment the version numbers and give the updated .msi to the users, and they just rerun the installer. There was originally only supposed to be a couple of users, so I didn't make a complicated updater. Now there are many users, and the updater is in-the-works. For now, the current users are happy with the process - I give them a new .msi and they run it again - except for one thing: the installer doesn't "remember" their settings from the last time they ran the installer (their words, not mine). I can get the directory of their last install from the "Uninstall" regisrty value and set it with TARGETDIR, so I've got the installation path covered. But I'm trying to figure out if the user changed "Everyone" to "Just Me" the last time around.
One way could be check for current logged in user in registry and see if it has the software listed in in installed software list under HKEY_CURRENT_USER\SOFTWARE\*
There's an example here of enumerating products to find out which context they were installed in. If you know the ProductCode you can just do the MsiGetProductInfo part.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa368279(v=vs.85).aspx
There are APIs for this, so it is more advisable than guessing based on what might be in the registry.
The installation folder properties window in Visual Studio setup projects has an InstallAllUsersVisible property you should set to False. Otherwise it's going to be a nightmare when you do an upgrade with RemoveExistingProducts=True because that requires the upgrade to be in the same context as the original install. You'll find people trying to do an upgrade with All users of an installed Just me product and it will not work.
I don't like per-user installs due to all the problems relating to upgrades, patching, etc... Accordingly I managed to migrate per-user installs to a per-machine during a major update install using Installshield and their built-in ISSetAllUsers custom action plus some re-sequencing of various standard actions. The description can be found here: windows Installer - uninstalling previous version when the versions differ in installation policy (per-user, per-machine)
If you want to migrate all installs to a per-machine install, you could replicate this approach using Phils suggestion to read the current installation context via your own custom action and then run this custom action in place of the ISSetAllUsers custom action that Installshield provides. Then you can follow the rest of the procedure from the link above.

Update Prompt for ClickOnce using Visual Studio

Just had 2 questions.
1) I am writing a simple program in C# just to test out how to set up updating, However the program automatically updates ( I am using ClickOnce) and I was wondering is there any way to prompt the user to update?
2) I am publishing my project to a localhost, and I have published it about five times (v 1_0_0_1 - 1_0_0_5) and the folders are stored as such, however, when I publish, it changes ALL of the different versions, not just the latest one. I am trying to allow version control where I can allow a user to go back to a previous version.
Thanks in advance!!!
After the user installs your app for the first time, every time after that when the application is started it will check for an update. If there is an update it will ask the user if they want to update to that version.
This happens by default and you can even prevent them from opening the application if they select not to update. (Preventing the program from opening if the user does not update is not the default configuration but can be set in the publishing wizard or properties of the application)
Also you should know that publishing the application will not cause you to lose or overwrite all of your previous deployed versions. They are all still there under root/Application Files. You will see the latest version though because the app will look at the manafest file and that will tell the app which version to run. If you wanted to push out a later version you would change the manifest to point to that version.
However, a single user will not be able to choose which version they want. Once they choose to update they will be on that version until you push out a different one. This is for security and compatibility so that your users are on the same version once they choose to update and you don't have a bunch of different people running different versions whenever they feel like it!

Visual Studio 2008 Deployment Project Issues?

I have created a successful deployment project using Windows Fourms that work as intended but there are two things that need to be solved:-
First: I have to click the setup.exe file in order for the installation to check for the perquisites, and if click the setup.msi it proceeds to install the software directly without checking anything.
Second: When i click on the setup file while the software is already installed on my PC, i get an error message "Another version of this product is already installed. Installation of this version cannot continue. To configure or remove the existing version of this product, use Add/Remove Programs on the Control Panel" while i should get a Repair and Remove options.
Can anybody help me solve this problems ?
As said by Morten, that's how it works. You want to make sure that the prerequisites are (get) installed before your product is installed.
This probably is caused by a rebuild of the deployment package after you installed it. Windows installer notices that you use a different MSI (with a different package code), that contains the same product version. This situation, apparently, is inconclusive enough to leave it up to you what to do with it. The logic of this, I think, is to prevent a "Repair" that in fact installs a different product. Inconvenient for testing, but very much desirable in production environments. If you try to install the same MSI you should get the repair/remove options.
BTW, after building a release, you can right-click the setup project in VS and choose "install". This executes a setup that kindly removes a previous installation with the same version.

Restoring Windows service programmatically

I am writing a Windows service. After installation, the Windows service copies the application and keeps it in back up at a certain path.
Now I want to reinstall later version of the Windows service.
I uninstall an older version of Windows service, then I try to install the latest version. But if it fails it needs to restore the old service from the concerned path.
How this can be achieved?
When creating an installer you need to specify the following :
Set Remove Previous Installation as True
Set Detect new version as True
Your C# program's version must increase with every deployment
You should change the version of your installer to one higher version and it will ask you to change product code, select YES.
If you do all the above steps the installer will automaticaly unstall the previous version and it will try to install the new version.
UPDATE:
To add the custom actions, follow these steps:
In Solution Explorer, right-click ServiceSetup, point to View, and then click Custom Actions.
Right-click Custom Actions, and then click Add Custom Action.
Click Application Folder, and then click OK.
Click Primary output from yourservice(Active), and then click OK. Notice that Primary output appears under Install, Commit, Rollback and Uninstall.
Create two versions of installers with all above steps. when you run secound time previous version will removed from the system and installer will install latest vesrion and also if error occured rollback will be handled by the installer.

C# WinForm application setup problem

In my VS 2008 C# WinForm application, I've made the Install.msi and
Setup.exe on my application release folder.
The client can install the application on C:\Program Files\ by running the setup.exe.
But there comes a new question, when I made a new Install.msi and Setup.exe,
the client has to remove the application via Control / Add Remove Program,
then excute the Setup.exe.
How do we fix this problem so the client's update will be more convenient?
otherwise,
how to create simple exe file like vb exe.
Thanks for help.
There are a couple of things you need to do. In the Properties for the Setup Project:
Set the RemovePreviousVersions property to TRUE.
Set the VersionNumber of the Setup Project. When doing this, you will be prompted that you will need a new product code. Just click Yes.
The VersionNumber of the installer is what the installer uses to determine if the current version is greater than the installed version. If the current version is greater, it will uninstall the previous version, then install the new version.
When you are deploying an update of your application with a VS2008 Setup Project, you must change the version of the project.
When doing so, VS2008 will ask you that if you change the version of your application it will change the product code of your application.
Mading these changes, when you will install the application on your client computer, Windows will detect that your application is an update of the older one and he will automatically overwrite the data with the new application data.
Hope it helps!
Regards,
PL

Categories

Resources