Clickonce “copy if newer” always download the file

2019-09-05 08:19发布

问题:

My clickonce App has an .ini file(config from a 3 party dll) that must be included on app root directory. I added the file as link and mark as "content" and "copy if newer". The problem is that every time that I deploy an update, clickonce download the file again overwriting all changes.

Why clickonce is not respecting "copy if newer" ?

回答1:

Why clickonce is not respecting "copy if newer" ?

Because that's used by the compiler when copying to the bin (or where ever the binaries are compiled to). This setting has nothing to do with clickonce.

I would recommend renaming your INI to "base.ini", or some equivalent. When your application starts, copy it to a new file with the new name if, and only if, it doesn't exist already. Something like this:

if (!File.Exists("yourinifile.ini"))
{
    File.Copy("base.ini", "yourinifile.ini");
}

EDIT:

You may be able to mark your file as a data file in your ClickOnce manifest. To do this,

  1. Open the properties of your project
  2. Select the "Publish" tab
  3. Click the "Application Files..." button
  4. Find your INI file in the list of files, and change the Publish Status to "Data File".