Creating a service installer that reinstalls over the top - visual-studio-2010

I have a service and a VS installer/setup project.
The installer installs/registers and uninstalls/unregisters the windows service fine.
In order to install without uninstalling I have RemovePreviousVersions set to True and I increment the version on the setup project properties and it prompts to also change the ProjectCode. All of this allows me to run the installer over the top of the previous one.
However during the install when it tries to register the service it complains that the service is already registered "Error 1001. The specified service already exists"
Should I test for this in my installer and not register the service again? This feels wrong because I expected it to uninstall the older version before installing the new version.
What bugs me is that when I right click the project and select "Install" from inside VS, it does all of this exactly correct without even having to increment versions etc.

Try setting a condition in custom action - install in your setup project:
Not (Installed OR PREVIOUSVERSIONSINSTALLED)
You already have installed service in your system, you just need to update binary files.

Related

Cannot add Application Insights - Failed to install package 'Microsoft.Web.Infrastructure'

I try to monitor the memory usage of my CloudService and stumbled upon Application Insights.
When I try to add it I get following error message:
right click on WebProject -> Add Application Insights Telemetrik
Insert Subscription-Data -> click Add-Button
Now the error occurs when VS tries to install 'Microsoft.ApplicationInsights.Web.2.0.0'
We are using VS2015 and Windows 10
Edit:
The fun thing is I can install Microsoft.ApplicationInsights.Webversion 2.0.0 via the nuget-console. But when I afterwards try to add the ApplicationInsights again it throws the same error and the package-manager-console displays:
The package at \Path\To\Project\packages\Microsoft.Bcl.1.0.14 failed to uninstall. Restart Visual Studio to finish the process.
Things you can try:
close VS, and start it once as admin. You may have old auto-updated extensions, etc that haven't been cleaned up until you run as admin. then close that admin VS and go back to your normal non-admin VS.
clear out your nuget packages in your solution, and then doing a full re-build to ensure that all of the current packages in your project are correctly and fully installed. when we try to install the AI nuget packages programmatically, Nuget tries to validate all of the existing packages and sometimes something goes wrong there validating things that already installed
then try re-adding AI through the tool.
if you still get the error, look in the directory shown in the error message, and comment and let me know if (a) that folder exists at all and (b) if it does exist, what's in it?
If things are still failing, you should be able to add the Microsoft.ApplicationInsights.Web nuget package manually from nuget package manager, and after that is done, right click the "ApplicationInsights.config" file that was added by the nuget package install, and you should see a "configure application insights" option that will let you pick your account, subscription, and AI resource, and that will get updated in the config file for you. If none of that works, you can send me a mail to jgardner # microsoft and i can try to track down more details for you.
Edit to add: If you get this error about Microsoft.Bcl, then your project is probably targeting .NET 4.0 and this is probably an issue we just found today. hypothetically, if you manually install microsoft.bcl into the project first, then that specific error for that specific package should go away? (we're working on verifying this specific dependency and fixing this asap).
A simple Visual Studio restart fixed the issue for me.

Update a bootstrapper application using msi package without duplicates in ARP window

Is it possible to upgrade an application installed through a Wix burn bootstrapper installer using the updated .msi, without getting duplicates in the "Add remove programs" window?
My scenario:
I have two msi packages bundled with some dependencies in a bootstrapper application. Lets call them "application" and "templates"
I would like to send an update of only the templates without having to include everything else in the update.
The purpose of the "Add remove programs" window is to allow the user to uninstall programs. Bundles will only uninstall MSIs that it has installed. So if you install a bundle and then manually upgrade one the MSIs that was installed by that bundle, then uninstalling the bundle will not uninstall that upgraded MSI. The behavior here is correct because it is allowing the user to uninstall everything that was installed.
Related bundles were added for these kinds of scenarios but their behavior was not documented so I can't recommend how to solve this problem with them.
The other option is to provide a newer bundle that includes the updated package along with the original versions of all the other packages. If you can make the packages available for download then the size of the bundle will still be small.

VS 2010 Setup Project is NOT removing previous versions

I am using a setup project in VS 2010 to install a windows form application I have created. The setup project works great, however, if I update the application and change the version number and upgrade code of the setup project it does not update the application on the user's machine when the setup project is run again. It will go through the install steps and say that the installation was successful, however, the application that is on the user's computer remains exactly the same and is not the newer version. Oddly enough, if you were to run the setup project again an error will come up saying that this version of the application is already installed and that you must use the add/remove programs to remove the current version to continue with the installation. Has anyone else experienced this issue before. I have heard that this may not be possible using the setup project in VS 2010, but I am hoping that is not the case as this method has worked great for me with the exception of this issue.
You should not be changing the UpgradeCode property, this will have exactly the effect that you are seeing:
Caution
The UpgradeCode should only be set for the first version; it should never be changed for subsequent versions of the application, nor should it be changed for different language versions. Changing this property will keep the DetectNewerInstalledVersion and RemovePreviousVersions properties from working properly.
( via https://wayback.archive.org/web/20121029130031/https://msdn.microsoft.com/en-us/library/465253cd(v=vs.100).aspx )
Assuming you want to remove the old version and replace it with the new one (as opposed to having them installed side-by-side, which is actually what you're doing) you should change the Version (of both the MSI and the file(s) being updated) and the ProductCode (of the MSI) and set RemovePreviousVersions to True.
I encountered same problem.
and I resolved with changing those four.
(I used Visual Studio Community 2019)
[setup project]
・Version
[.Net project]
・Assembly Version
・Assembly File Version
・GUID

Visual Studio: How to automatically uninstall previous installed version?

I have a simple Web Setup project that reads from a Deployable Project.
Even though I have set the Setup to DetectNewerInstalledVersion to false I always get that annoying alert box that a previous installation exists and I need to go to the Control Panel and find the software to remove it...
Is there a way to add a script in a new new installation Dialog that could say A previous version was found, press NEXT to uninstall it. ?
Older versions are uninstalled automatically if you increase your Product Version and change the Package Code. This needs to be done each time you modify the setup project and build a new package.
If you keep the same version and Product Code, older builds cannot be uninstalled automatically. They are detected by Windows Installer before your new package is actually launched. So you need to uninstall them manually.
In my case I found out that the setup project wasn't part of the configuration manager.
Therefore, it wasn't rebuld on solution rebuilds and setup file with the new version and ProductCode wasn't generated.
The solution is simply to right click on the setup project and click rebuild.
Hope this help to future readers :)
The answer is not to use the Visual Studio setup project that's already integrated. I'm having the exact same problem: it won't remove previous versions even though I up the version, set it to remove previous version, check for previous version and rebuild, I can install but the files aren't updated. There are some good tools for this out there, check out bitrock, inno setup or wix.
Also Visual Studio 2010 was the last version with setup project support. It's not included in 2012.
I struggled with this for a long time but it is very simple.
Go to manage VS Extensions (VS2019) and install 'Microsoft Visual Studio Installer Project' v0.9.9
Right click on your installer project and go to properties. Keep the UpgradeCode variable in the properties window the same for different versions of the same product.
Change your ProductCode variable between different builds.
Now when you install the product with the same UpgradeCode already on the system, the installer will upgrade your existing product and you will only have one program in the Add/Remove window.
Create a .bat file
Write this code:
wmic product where name="SetupProgramName" call uninstall /nointeractive
cd Debug
setup.exe
Put this file in installer directory.

WIX uninstall error

Whenever I try to uninstall my WIX installation via Add/Remove Programs or the uninstall shortcut I put down with the installation, I keep getting the following error:
a network error occurred while attempting to read from the file c:\windows\installer\MyProduct.msi
But if I use the original installer and select uninstall then it is fine. Why is this happening as obviously you can't expect customers to hang onto the original installer if they need to uninstall my product!
After some testing it seems that if I install then uninstall straight away then it is fine, but if I log off or restart the computer then I get the error.
Update: Once an install is finished I run a custom action to delete a folder which temporarily holds some database files used during the install. After digging around it seems that the uninstall is trying to access these files, why would it be doing that, it has nothing to do with uninstallation?
"C:\Windows\Installer" folder is the Windows Installer cache. It's used to store MSI packages for installed products. These packages are used by Windows Installer when performing a repair or modify operation on the product.
In your case the uninstall process needs some files which are missing. The MSI in Windows Installer cache is not complete (it's just a stripped down version), so you are prompted for the original package.
Usually this behavior is triggered by custom actions which try to use files that are not available during uninstall. Try creating an uninstall log to see what triggers this.

Resources