How to get setup.exe folder path for ClickOnce - wpf

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?

Related

UWP App WPF .Net Core has no access right to dependencies

We're making a new application using WPF .Net Core. To use the auto update function we decided to pack it with the MSIX Packaging Tool as a UWP App in VS2019. I was able to host the appinstaller File on an IIS and to Install the App over a link to that file over the web. Auto updating is also working fine.
Now to the problem:
When I run the installed App it's icon is not showing in the task bar but it is shown in the Task-Manager using a lot of cpu. In the Process Monitor it shows that the App tries to access its dependencies (like PresentationFramework.dll) but is not successful as the result is always "File locked with only readers". The DLL itself is present in the WindowsApps/xxx/ Path. Also I can not start the EXE manually as my user do not have the rights. What am I missing here?
Edit: Also I realized now that my app is only starting as a background process in the task manager and not as an app. When I go to the app directory under WindowsApps/xxx/MyApp I can not start the EXE directly because of no rights as mentioned before. But when I copy the whole folder I can start the EXE, the GUI appears and the app is an app again in the task manager.
We found an answer. As the GUI is a WPF .Net Core Project and we make the setup with a Windows Application Packaging Project to generate a UWP App from it the technology used seems to be the so called Desktop Bridge.
In the process monitor it seems that it tries to access the files under the correct path but somehow it does it not in the right way as long as the application path is not set correctly in the WPF Projects App.xaml.cs.
To fix this use the solution from Andrew Leader

How do I refresh resources folder of web application?

I'm developing a web application in which I want to insert users and be able to display files that they upload via a search option. I can get all of the logic that I need sorted and the files uploaded into the correct directory. However, if I insert a new user into the db, the web app cannot find their file in the directory until I restart the server.
How can I make it so that the resources directory of my web app automatically gets refreshed by the server? I'm developing in Java/JSP and using Tomcat as my server.
Thanks!!
I'm guessing you're putting the files into the src/main/resources folder, then it's being packaged into the artifact and then you access them as the classpath resources. Then the next portion of the resources is going to be available after the next packaging.
Instead you should access the Files via usual File System and Absolute or Relative paths.

Wix installer keep user settings config on upgrade

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();
}

Azure Clickonce publishing

we are working on a WPF application which we want to publish as a click once smart client application.
We are able to publish the application on local machine using Visual Studio 2012 and configured it in IIS.
Now we want to upload the published smart client installer to windows Azure Virtual Machine with Windows Server 2012 and IIS 8. We cannot upload the locally published components as the URL configuration in the manifest and deployment file is that of local server. We tried to edit the entries using text editor but once we do the editing the files become unused and it shows xml parsing error when we try to install from the location.
we tried to publish the application direct to the Virtual Machine but it shows an error as Front Page Extension is needed in IIS. We tried to find Front Page extension but couldn't find an version for IIS 8 in Windows Server 2012.
Can any one help us to publish the application in Azure Virtual Machine.
The problem you are having has nothing to do with Azure per se.
In the first case (of editing the XML files), you can do that but it's best to use MageUI to do the edit, because you can then re-sign the manifests. If you just edit the files, it messes up the security on them, and they will not work (as you have found). If you want to edit them with a text editor, you can do that, but then you must re-sign them (using mage); you can create a script to change the installation URL.
Or you can use MageUI. You need to do it in this order:
Open the application manifest in the versioned folder and then save it, re-signing it with your signing certificate.
Open the deployment manifest (yourapp.application) in the top deployment folder. Change the Start Folder to be the right Installation URL. Go to the "Application Reference" tab and re-select the application manifest in the versioned folder. (I know, it hasn't changed, but trust me, you have to do this.) Save this manifest and sign it with your signing certificate.
Copy the deployment manifest from the top folder to the versioned folder. It's always good to keep a copy, so you can go backwards a version if you need to.
NOW you can copy the files to your VM and they will work fine.
In the second case, the Front Page Extensions are required if you are using HTTP to publish the application, yet they are no longer available past about Windows Server 2008(?). So don't use HTTP. Use FTP. Set the publish file location using FTP, like ftp://myserver.mycompany.com/myfolder and set the Installation URL to the HTTP equivalent of it. Then publish it. It will put the files on your VM (assuming FTP is enabled on both sides), and the HTTP link should work.
By the way, you can also host your deployment in Azure blob storage. It is dirt cheap, and you can use something like Cerebrata Cloud Storage Studio or even write your own code to publish it (which I did). This article explains how to put the files out there, what the MIME types need to be, etc. If you do this, then it will work even if you need to replace your VM or redeploy it or the VM becomes unavailable for some reason.
here is a reference to Avkash Chauhan's blog post explaining in detail How to deploy ClickOnce Application using Windows Azure Storage in very simple steps?
http://blogs.msdn.com/b/avkashchauhan/archive/2011/05/09/how-to-deploy-clickonce-application-using-windows-azure-storage-in-very-simple-steps.aspx
He also gives an code example of a windows form (using Wpf) that he shows how to deploy on azure using one click deployment.
hope this helps

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.

Resources