c# Check if there is a file on server with specific name - c#

I making a program and wanted to make an update function... So lets say I make one update and put it on my dropbox.. When someone click on update, the program will check if there any file with different name (no same version) on the server and if there is, then start to download it.. Is it possible?
And my second problem I installed my program on my computer but when start the installer again it says:
Another version of this product is already installed. Installation cof this version cannot continue. To configure or remove the existing version of this product use add/remove programs on the control panel.
I want when I run second time installer a confirmation message appear if he want to delete previous version to install this one (I need this for the update)

You could create a web service that provides an index / manifest of a directory that you want to synchronize. The web service could also provide methods for uploading and downloading the synchronized files and folders.
If you are using a Visual Studio Setup Project (.msi) you can simply change the installer version. Visual Studio sees the change and asks you if you want to change the product code. You would say 'yes'. The installer should then remove previous versions before installing the latest. You would also want DetectNewerInstalledVersion = true and RemovePreviousVersions = true.
Not sure if it works for this scenario but you may want to look at a ClickOnce deployment. It may solve both of your problems. ClickOnce Deployment

Related

How to uninstall automatically while installing new version in msi file

I have made a msi project for my software in VS2015. I have made a.Net based desktop application. My requirement is that I would like to handle 2 cases :--
1- If our software is installed already, and user try to install it, it should automatically un-install existing software and delete database file (created by my application).
2- If installed version is lower then it should only uninstall application and leave my database file as it is.
Now in my setup project I have added Custom actions for install and un-install where I have given path of my dll and set Installer Class property to true. In this dll I have made a class inherited from System.Configuration.Install.Installer and handle Install , beforeInstall, uninstall like below :--
public partial class SetupManager : System.Configuration.Install.Installer
{
public SetupManager()
{
InitializeComponent();
this.BeforeInstall += SetupManager_BeforeInstall;
//this.Committed += new InstallEventHandler(DarkMailInstaller_Committed);
}
private void SetupManager_BeforeInstall(object sender, InstallEventArgs e)
{
MessageBox.Show("In Install event");
}
}
Now in un-install, I delete DB. it is working fine if I am un-installing from control panel and it removes my DB file as well.
But if I want to upgrade my product, before getting hit in my override function Like install or BeforeInstall it shows error "Another Version of this product is already installed. Installation of this version can not be continue. To configure or remove the existing version of product, use add/remove program of control panel".
Now I have searched on internet and it seems if I update my package code or product version, it should be able to install over it. Now I have following issues :--
1- In VS 2015, I dont have any property in setup project where I can set product version or package code ?
2- I have tried to edit it using Orca but even then if I try to install edited MSI file (with updated version number, package code and product code), I am facing same error.
3- I dont know why this this error is coming before executing Before-install event ?
4- I have found "RemoveExistingProducts" would be helpful in this case. But I can not find this property / action in VS2015. Where can I find it ?
Can some body please help me to solve this issue ?
In a Visual Studio setup project it's the RemovePreviousVersions property of the setup project, in with the other properties like Manufacturer, Version etc.
Increment the setup version's project version, accept the changes.
Set RemovePreviousVersions to true.
The UpgradeCode needs to be the same, so don't change it.
Increment the file versions of the binaries you need to be updated.
If you select the setup project in solution explorer and do F4 you should see the relevant properties.
Don't worry about PackageCode because Visual Studio creates a new one with every build, as it should.
Visual Studio custom actions all run after the files have been installed (despite the "before" name), so there's nothing you can do to influence the course of the installation. In any case you don't need them.
What you get is an MSI that will install as a fresh install to new customers. It will also upgrade an older product as it installs, and the Windows Installer overwrite rules mean that a data file updated by the application will not be replaced.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa370531(v=vs.85).aspx
The generated MSI will have a RemoveExistingProducts sequenced towards the end of the install. Basically you don't need to worry about the internals of PackageCodes and so on because Visual Studio hides them.

How to skip folder selection form when update installed application via Windows Installer setup project

As the title describes, I am trying to skip the folder selection form when update the installed application via setup project in visual studio(casue the user already selected folder path when they installed the app). I googled online and find a way to disable folder form: http://www.codeproject.com/Tips/437285/Visual-Studio-Deployment-Setup-Disable-Installatio. However, How to know if it is installation or upgrade? If we know it is upgrade, how to get the installation path?
Thanks in advance!
I do not find any approaches to skip that folder form. This should be the reason that many installer tools exist in the market. Since my app is very small, I simply disabled the folder selection dialog. For anyone who are interested, please check this URL: http://www.codeproject.com/Tips/437285/Visual-Studio-Deployment-Setup-Disable-Installatio
If you saved the original install location in the registry, for example by saving [TARGETDIR] in a registry item, then you can retrieve it during an upgrade. You find out you're doing an upgrade because it will set a property called PREVIOUSVERSIONSINSTALLED. The problem is that there is no way to wire it all up in a VS setup project. You want the browse dialog there (not deleted) but you want to skip it if PREVIOUSVERSIONSINSTALLED has been set, and there's no support in VS setup projects for that. You'd need to go into the ControlEvent table in the MSI file and figure out how to skip the browse dialog, as well as have the Back button skip over if necessary, and that's just very difficult.
What's the actual issue? Visual Studio upgrades are complete installs that uninstall the previous product and install the new one wherever the user wants, so why is it necessary to install in the same location as the previous install?

Visual Studio Setup Project not removing DLL

I have a problem regarding the Visual Studio Setup Project and uninstalling an application.
This is a very basic installer, installing an ApplicationLauncher.exe C# .NET 4.0 console application and an Application.Common.dll (a dependency of the application ApplicationLauncher.exe).
The installation is a success, copying both the exe and DLL into the program files folder C:\Program Files (x86)\Company\ApplicationLauncher\.
My problem comes when uninstalling the application (through the MSI) - the uninstall seems successful, however it leaves Application.Common.dll behind, and doesn't remove it as I would expect.
I've used ProcessExplorer to make sure nothing else is using the DLL, no explorer windows are open during the uninstall.
Is this the expected functionality and do I have to create a custom action to remove this DLL? Or have I done something wrong? :S
It seems I was able to fix this issue by renaming the solution and product name of the application, I'm not sure how this fixed it, but it did.
My only thoughts here is this traversed through to the installer, where the application installed into a different folder, thus not applying the same permissions to the DLL..
It's not expected, no. It will happen if you ever done any of the following with your setup and installed it:
Marked the file Permanent.
Marked the file SharedLegacyFile true.
These are project settings, but if you set either of them and do the install it will stay behind. You can unset them in the setup project but that's too late - you've marked that component permanent or sharedlegacy on the system. If you use a brand new system, like a fresh virtual machine, reset these values if they are set and rebuild the MSI and do the install/uninstall does it still happen?
I had the same problem. Then I have tried to install and unistall my app on Windows XP and that had worked.
Renaming the ProductCode is treating the symptoms not the cause. The problem occurs when the uninstaller doesn't remove the dll. The next install will use the dll again and can't remove it on an uninstall event because it's still used by the other program.
These steps hopefully solve the problem:
Install your Software
Open CMD (with admin privileges) and run:
msiexec /x {ProductCode} /L*V "C:\CustomPath\FileName.log"
The ProductCode can be found when hitting F4 on the Setup Project
Open the log file and search for the lines that look something like this:
Disallowing uninstallation of component: {6CEC09F6-9108-7062-A692-2BCBACEE3BD8} since another client exists
Disallowing uninstallation of component: {A0A0FA84-CC0D-C5C4-1F57-169788C4482D} since another client exists
Disallowing uninstallation of component: {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} since another client exists
All these components have to be removed from the registry by hand. To do this the GUID (e.g. {6CEC09F6-9108-7062-A692-2BCBACEE3BD8}) first has to be converted into a packed/compressed GUID (e.g. 6F90CEC6801926076A29B2BCCAEEB38D). I found a Website where one can run a script to do this. Find the following code on the website and replace the right side with the GUID from the log.
string inStrGUID = "{6CEC09F6-9108-7062-A692-2BCBACEE3BD8}";
Open the registry (as an administrater) and search (Edit -> Find...) for the compressed GUID (uasually it's somewhere in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\)
Delete the folder that is equal to the compressed GUID. The values inside the folder should be a path to the dll.
Once deleted select the parent folder (...\S-1-5-18\components) and hit Edit -> Find...
Repeat these steps (4-7) for all components from the log file.
It's also a good idea to delete all files still present in the original folder that weren't uninstalled.
Can one prevent this from happening?
I don't know. This really isn't that easy to reproduce. Some other post on SO have suspected the install/uninstall option in Visual Studio to be the cause of the problem but I have a different theory:
This bug might be the result of RemoveExistingProducts in InstallExecuteSequence in the Setup being executed too late and therefore not removing dlls at the right time. This bug is known for years and can be fixed by doing this. If you need help with Orca this explains how to install it.

Autoinstallaion of setup.exe

I am using visual studio 2008 and I have created setup project using the same. After deployment of the application whenever I change any of the file or even rename any file setup.exe automatically starts to reinstall the setup. In this case it should customized error.
Do anybody has idea on this??
This is the normal behavior. Windows Installer automatically performs a repair if it determines that some of the installed resources are missing.
This repair is triggered by:
launching the application through an advertised shortcut
launching a file associated with your application
To avoid it you should:
make sure that your application doesn't delete, move or rename installed files; if you need to work with files use the Application Data folder
or
make sure that the deleted file is not the key member in its component; this is controlled through the Component table
To answer your actual question, you cannot show a customized error. You can only try to avoid this behavior.

Simplifying setup and deployment in c#

I have made an application, which keeps getting updated frequently. So every time a change occurs, i've to include it's fresh builds to the setup and deployment program again and again. Is there any way to simplify the procedure? The files to be added are static in number and exist in a folder. I've heard we can write installer classes in c#, does my requirement has any thing to do with it?
I think ClickOnce doesn't suit my requirement because, for the first time i want it to run like a setup package, since it has some packages and some settings needed to be implemented on the user's machine at the time of install. Can click once help me with that? Also i want to run my application as an administrator and it references to many external dll files. So will it help my purpose?
I finally did it using clickonce deployment. I used content files to mark all the files i wanted to copy to the target computer and used clickonce deployment. Then i modified the way my program starts, so that i can lauch the installer script i wanted to run only when the app runs for the first time. Further i hosted it on IIS and had to change lot of MIME types and add new ones for the download to work over internet
Look into something called "ClickOnce" deployment. It automates a lot of what you're talking about.
EDIT: You can add custom installer actions to a ClickOnce project just like any other, to set up additional components and whatnot. As for permissions, ClickOnce will let you run as administrator if you so choose, but that sort of thing isn't recommended, and it might whine about it.
You can use ClickOnce (http://msdn.microsoft.com/en-us/library/t71a733d(VS.80).aspx) which simplify the deployment process.
Maybe you can also automate the build process using NANT (http://nant.sourceforge.net/).
HTH
Yes, you can do that.
I assume you want the client to update itself when ever there is a new version.
This needs a few changes in the client code. Essentially how it works is check for availablilty of new version at a predefined location. Update you new versions to this location. On the client side, show a message to the user if he/she wants to upgrade to the new version.
You can find a link to sample project out here and here.
You can add a Setup project in your solution inside Visual Studio and then add your other project(s) outputs, or static files to the Setup project as references. The Setup project will then detect your dependencies automatically and each time you do a Rebuild All (or you rebuild/build your Setup project) it will automatically include all the necessary files.
What type of project is it? In many cases, ClickOnce can do the job for you, at nominal effort.
Beyond that - you can usually hook your installer build into your build process; some tools will do this for you.
Installer classes run at the client - so I don't think they relate to your build process...
I would flag the files as Content in their respective properties and then in the deployment project right click the project, go to File System and then right click the folder, click Add and select Content Files from the dialog box. This should copy the newest files over every time you build the deployment project.

Categories