How to read previous app.config value when we updating an installer - c#

We are working on a WPF application and we have used Install Shield Limited edition to create the installer of the application.
As per requirement we need to keep a “Key” and “Value” in the app-settings of the “app.config” file. “Value” will be dynamically generated at the time of installation and it will be different when we update to new version(installing the new versions of the application).
I found that each installation time app.config file is overwriting. How i get the old config “value” when we installing new setup.
Can i get the old value from an installer class?

You can do it in custom actions, it is like PreBuild/PostBuild actions in Visual Studio. If you are not comfortable with scripts (neither am I), you could write two executables in C#, one to be executed before overwriting the old files to get the old values, the other to be executed after installation to restore the old values.

Related

Updating application using msi fails to update dll project reference

I am creating a setup msi using a Project Output (Say Project-A), which refers another project (Say Project-B).
When i update application using new msi, dll of Project-B does not get updated though latest build contains some changes in Project-B
Note: When i uninstall the application, dll of Project-B remains in installation folder( not deleted).
It's not clear what you mean by "update ... using new msi" but the way you upgrade using Visual Studio installer projects is to increment the setup project's version and accept the changes, which include generating a new ProductCode. RemovePreviousVersions also needs setting to true. This should help and is still relevant:
https://www.simple-talk.com/dotnet/visual-studio/updates-to-setup-projects/
In addition you must increment the file versions of files you need replacing - it's not enough that they are just different.

Cant see the Recent updates after Replacing Existing files in setup project

I have created a setup project for Windows Application . I have set following property to replace the existing version with the new version.
RemovePreviousversion=True;
Productcode=change;
But when I run exe from new installed version. I cannot see my new updates. It gives me the output of previous version!
The whole Explanation is Here
I have RemovePreviousVersions set to TRUE and InstallAllUsers set to TRUE.
When I need to do a new release, I update the Version field with a new version number in the installer and VS prompts me to update the product code, to which I answer YES. I have verified that it does indeed change the product code, but the package code also gets changed with it (verified by diffing project files using sourcesafe).
The UpgradeCode never changes between versions.
My version number changes are of the form: "1.1.2" -> "1.1.3" for example (just in case that has anything to do with it).
So only 3 fields are different between builds: ProductCode, PackageCode, and ProductVersion.
When I've done all that, I build the installer.
When I install the new version (I always install for all users and always into the same directory), I have seen three different results at various times:
It will appear to in install the new version, but I really end up with the old files still there (and one instance in the add/remove programs).
I end up with 2 instances of the app in the add/remove programs, both with the same name, and both pointing to the same directory.
It will uninstall the old one first and then install the new one (what it is supposed to do).
It is very frustrating to explain to users that to be safe, they have to uninstall the old manually before installing a new release because I have to tell them "it doesn't always uninstall the old one like it is supposed to".
Any suggestions? Why isn't this working? What am I missing here?
I Found answer.
Also need to change AssemblyVersion and AssemblyFileVersion in AssemblyInfo.cs

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

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

C# Program Update

Hi I have a c# project in visual studio 2010 and Im wondering how to do the following
I have deployed this project already to a tester.
It uses a SQL database in the backend.
When I published a new version and sent him the new installer he had to remove the old version first which in turn removed his database.
What I'm looking for is a way to publish the project such that it overwrites the old stuff that has changed while leaving his database in tact.
(This would also need to but probably would circumvent the message that you can't install because its already installed in another location)
Thanks in advance for your help
The absolute simplest solution is to not use an MSI or an installer to update the program. Since this is a .NET app, it just needs to be copied to the file system. (XCOPY deployment)
The next simplest solution is to use a true database - have the database be something that is set up separate from your application.
This might also work, but I have no time to test it personally: If this is a .dbf file or another file included with the project, you might be able to change the option on that file by selecting "Copy if newer" on the Copy to Output Directory Property in the properties pane for that DB file.
Could you use ClickOnce? It is super simple.
Here is a good tutorial - http://www.youtube.com/watch?v=t4BTLdIMYEY

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