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.
Related
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.
I developed a windows service in C#. and my project has Installer, and Setup project.
the setup project, installs service very well and it doesn't have any problem, but when I change project and create other setup, the new setup doesn't install new service, because it's already exist!!!
is any way to create setup that it uninstalls the service then install it?
The problem is that upgrades in VS2008 setups and later use installer classes and an install sequence which is 1) Install newer product over older product, use file version checking, run install custom actions 2) Remove the old product running uninstall custom actions and getting rid of files that are no longer used. VS 2005 wasn't like this. So the installer class custom action that installs the service is running when the service already exists. Sometimes you can revert to the VS 2005 upgrade mechanism that removes ALL the older installed files first, including databases etc, so keep that in mind. You can do that by modifying the MSI file with Orca, InstallExecuteSequence table, and re-sequence the RemoveExistingProducts action to immediately after InstallValidate. Otherwise do both these:
Always install the service binary to a fixed location (that means not the browsable Program Files folder). The uninstall custom action for the service should have a condition of NOT UPGRADINGPRODUCTCODE so that an upgrade doesn't try to uninstall it (but a straight uninstall will). It needs to be in a fixed location because this upgrade solution doesn't install or uninstall the service - it just updates the binary - but obviously you don't want service entries referring to a service that has changed location.
In the upgrade have a condition of NOT PREVIOUSVERSIONSINSTALLED on the install custom action for the service. This means it will not try to re-install the service (which is why you get the "already exists" error) but it will update the exe if you have incremented its file version.
If you search the MSDN setup forum http://social.msdn.microsoft.com/Forums/en-US/home?forum=winformssetup for PREVIOUSVERSIONSINSTALLED many of the posts are to do with this issue and there is more discussion and explanation.
Editorial: Installer classes are not required because Windows Installer can do all this for you, which is why this is only ever an issue with VS setup projects. Moving to a tool that uses MSIs ServiceInstall and ServiceControl tables will get you out of the need for any code to install/uninstall/stop/start services.
You could do it by properly configuring MSI properties. Click on Installer project and press F4 to view MSI's properties window.
When you go to properties you could see two type of properties that are Upgrade code and Product Code. Every Time you create/release a new Windows service installer make sure to keep the same Upgrade code but change the Product Code.
Change DetectNewerInstalledVersions property to true.
Set RemovePreviousVersions to true.
Now Change the version number to a higher version from previous release, if your previous release version was 1.0.2, change the new version to 1.0.3.
When you install a MSI with abovementioned settings, MSI will check if any other product installed with same Upgrade code, if it finds a product then it will check if the new installation has a higher version. If all the conditions are satisfied it will first remove the existing(Older) version and install the newer version.
I'm very new to Setup project in Visual Studio, I've just tried creating a one, it deployed my files as I configured in the setup project. But after testing the install file (.msi), there was something I can't understand:
There is no entry in the Add/Remove programs list in Control Panel but I tried re-running the setup and it showed a dialog saying that I couldn't setup because there was another version which has already been installed in the target computer, I should uninstall that version first, but I couldn't find an entry in Add/Remove programs and there is also no uninstall.exe file. I tried searching for all entries which contains my application executable file name in Registry and deleted these entries but It still shows me that dialog. (There must be some way through which it can detect another version installed on the target machine).
How I create an uninstall.exe for my deployed application in Setup project??? I thought it should be created automatically for me when I build my Setup project.
Your help would be highly appreciated. Thanks.
There is no uninstall.exe when you are using msi packages to install applications. If you double click the msi of an already installed application you get the choice to do a repair or an uninstall.
What name did you give to your installation package? Maybe you left the default name or gave it some "weird" name different from your application and that's why you can't find it. In 7 you can sort the installed programs by install date and check what's been installed last, don't remember if it's possible in XP.
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.
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