Wix installer keep user settings config on upgrade - wpf

I have a WPF application that uses user settings to store the users preferences and I use the Wix installer to install the application. When the application gets installed, the default config file is placed under the install location, for example C:\Program Files[CompanyName][ApplicationName]. When a user makes changes to their preferences in the application, these preferences are saved out to the users AppData folder, an example of this path might be
C:\Users[Username]\AppData\Local[ApplicationName][ApplicationName].exe_Url_pduhkwydh2kyq5nkqnr5jbnuaznm\1.1.0.0\user.config
Now, if I am upgrading the application to version 1.2.0.0, the application now defaults back to the default config file and when the user makes changes to their preferences again, a new folder is created this time being 1.2.0.0\user.config.
How can I preserve the user.config when upgrading the application? I don't know the location of the user.config file during install or where the new user.config will be created. Is there a better way of storing user settings?

This is an application issue, not an installer issue. The application should perform a settings upgrade by calling Upgrade.
To determine if an upgrade is required, create a user setting saying it is and then change it after the upgrade.
if (Properties.Settings.Default.IsFirstRun)
{
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.IsFirstRun = false;
Properties.Settings.Default.Save();
}

Related

How can i change the Installation Folder Url and Update location of a c# click once application in user machine

we have a WPF application where we use click once for deployment and installation location is network path, Now we are planning to move it to IIS(http://example.com)
we don't want to inform the existing users to uninstall the application. Is there any possible way to change the installation location and Update location of click once in user machine through code.
How to check the Update location and installed location of click once in user machine, Is it possible to check?
You cannot just change the update URL of the already deployed ClickOnce application due to the security functionality that is built-in into ClickOnce. It checks the update location for the installed application against the URL for the update, and if they don't match, it won't install the new version.
But you can deploy an interim version (an update) to the old location that tells it to look for updates at the new URL. There is a video available here that describes how to this in detail which should be helpful: https://robindotnet.wordpress.com/2010/01/17/how-to-move-a-clickonce-deployment/.

How to deploy a WPF application?

I have developed a WPF application and deployed it using Click Once Deployment. I installed it on another pc it works fine but the problem is that the application's root folder is being created in a temporary folder in app data/local. I want to give user the flexibility of installing the software wherever he/she wants. How do I do this?
You simply can't change the installation folder using ClickOnce. If you want to do this you need to choose a different installer technology.
ClickOnce application require no administrative privileges and are always installed per user in the user application cache.

How to get setup.exe folder path for ClickOnce

I have a click once Application which is deployed in folder say, "c:\temp\MyApp". In this folder I have a config file "MyAppDynamic.config" which I want my click once app to read when it starts.
When I click on c:\temp\MyApp\setup.exe, ClickOnce App is deployed in %APPDATA%.. folder and hence I am not able to get the folder location from where clickonce is launched.
Is there a way to get the launch location in clickonce app?
Am I doing something wrong?
Thanks,
RDV
Little more info:
My clickonce app's main purpose is to install a bunch of pre-reqs on client box. These pre-reqs can be located anywhere on network (their location changes depending upon whether the particular component is in development or production). I did not want to update the clickonce installer just because some dynamic location changed and thats why I do not want to hardcode the installation paths in ClickOnce app.
Hence, I am using an external file "MyAppDynamic.config" where I update the installation paths of all components and I place this file in the published folder where setup.exe resides.
The problem is I want to read this file when ClickOnce application starts, but any System/Environment variable wont give me this published location because by this time, ClickOnce is already deployed on Client Box and all Location/CodeBase paths point to %APPDATA%..
Question:
Is it possible for a deployed clickonce application to get its installation directory path (I verified IsolatedStorage does not provide this information)?
Is above not not possible, are there any ideas how to achieve this? Again I do not even want to hardcode location of MyAppDynmaic.config file. But if nothing else work, this is going to be my best bet :-(
Thanks,
RDV
There is no way to get or set location of installation. Installation folder is under Isolated Storage for security purpose. You can read your config file. Check this answer;
How can I get the application's path in a .NET console application?

ClickOnce and app.config not deploying

I have a new WinForms application that I'm trying to deploy with the ClickOnce method. However, the app.config file that is needed for the application is not included with the installation.
The application is installed properly from the server, and launches the exe, but as soon as I try to login by hitting my WCF Server, I get.
"Could not find the file 'C:\Documents and Settings\Adminstrator\Local Settings\Apps\2.0\7KAA3h20\app.config"
I can manually copy the file from my development machine to this folder and the application works fine.
Any ideas?
The application settings are included in the ClickOnce application as yourappname.exe.config. Are you accessing the app.config through a different mechanism that the global app settings?
Config file is included by default. Are you removing it for some reason?
You can choose files to be deployed on properties page (application files) if you are using Visual Studio.
If file is not in the list, you can add it to project and set build action to "Content" and it will show up in this list.

Clickonce deployment with wpf

I've created a wpf application and its installer with Clickonce. But running installer on another computer causes exe file creation in Start-Programs-Microsoft. What should I do to make installer create a folder in Program files?
By the way, I also want a program to create a desktop shortcut, I put make the "Make desktop shortcut" checkbox enabled when customizing publishing options, but nothing happens.
Clickonce doesn't allow to specify a folder in Program Files, the solution was to create a Setup Project within the solution.
The Publisher name settings under Publish Options -> Description of the project properties in Visual Studio determines the folder under Program Files.
I usually follow below steps. Hope it may helps
Steps
1. Right click on the client project -> properties -> Publish tab
Publish folder location, installation URL(eg: http://LocalHost/Application/client/)
Click updates give same installation URL
Click options > give name and description for the application
Click Publish
Copy the files from Publish folder location and paste it in corresponding installation URL
Browse the install.htm
Click install
Some times before publishing you may need to create a new certificate (project properties -> signing tab > create test certificate (password not mandatory))

Resources