Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can ClickOnce be configured to delete off old published directories?

Can ClickOnce be configured to delete off old published directories?

Or

Has anyone written some code that will delete off these publish directories (maybe keeping the last 10)?

Currently, every time a ClickOnce Publish is done a new directory is being created on the IIS Server. This NEW directory contains a copy of the whole application, which is downloaded. The old directories do not seem to be used anymore and is just taking up a lot of space.

Here is a sample of the directory names being created. As you can see the application version number is being used in the name.
EduBenesysNET_1_0_1_0
EduBenesysNET_1_0_1_1
….
EduBenesysNET_1_0_1_192
EduBenesysNET_1_0_1_193

We have had 194 (zero based) builds with each directory staying out there. With the size of one build being about 50mb, you can see how keeping the old directories out there will start to eat away at the disk space.

The way our application works is you always have to download the latest version. You do not have an option to skip the download so I am hoping that deleting off the old directories should not be a problem.

like image 628
Gerhard Weiss Avatar asked Sep 30 '10 20:09

Gerhard Weiss


People also ask

What is ClickOnce process?

ClickOnce is a deployment technology that enables you to create self-updating Windows-based applications that can be installed and run with minimal user interaction.

Where are ClickOnce applications stored?

Every ClickOnce application installed on a local computer has a data directory, stored in the user's Documents and Settings folder.

How do I manage updates for a ClickOnce application?

With a project selected in Solution Explorer, on the Project menu, click Properties. Click the Publish tab. Click the Updates button to open the Application Updates dialog box. In the Application Updates dialog box, make sure that the The application should check for updates check box is cleared.

How do you delete ClickOnce cache?

To delete the ClickOnce file cache, delete the contents of this folder based on the operating system. Deleting these files will clear the information for all installed ClickOnce applications. They'll reinstall the next time their shortcut or Uniform Resource Identifiers (URIs) are used.


2 Answers

Good question (+1) - one would think that this should be possible somehow ...

Looking a bit closer though reveals that the observed publishing behavior is not actually a feature of the ClickOnce technology, rather one of the Visual Studio Publish Wizard - see for example section ClickOnce publish folder structure in ClickOnce Publishing Process:

If you manually generate or update a ClickOnce application publication using either Mage or a custom tool, you are not constrained to this folder and file structure. For any particular ClickOnce publication, the chain of dependencies includes the following: [...] [emphasis mine]

The Walkthrough: Manually Deploying a ClickOnce Application yields the same conclusion, i.e. the folder structure in use by VS is simply a (reasonable) convention/approach.

Unfortunately the VS Publish Wizard doesn't seem to offer deleting older versions indeed, at least it is neither visible nor documented somewhere. However, given the resulting folder structure is just an artifact of the build process, you might as well add a custom build step doing just that - figuring out the details (i.e. accessing the VS automation properties to derive the last published version etc.) is outside of the scope of your question though ;)

Regarding your sub question:

I am hoping that deleting off the old directories should not be a problem.

Definitely not a problem, it just depends on how many of these you want to keep for rollback operations eventually, see e.g. Can I delete previous old versions from Publishing Location created by ClickOnce?

like image 56
Steffen Opel Avatar answered Sep 29 '22 13:09

Steffen Opel


The short answer is that this is not something that is built into Visual Studio or ClickOnce deployment, and you will have to find another way to do this, perhaps through a script that you run on your server.

You can delete all of the versions except the current one if you push updates as required updates. If you don't do that, you'll want to keep two versions in case the user reverts back a version.

like image 29
RobinDotNet Avatar answered Sep 29 '22 12:09

RobinDotNet