none
Deploy User Specific config files using ClickOnce

    Question

  • How do I change config files for a specific user of an application deployed using ClickOnce (total user base is 500+).  Basically we are implementing Logging using Enterprise Library and we want to turn on logging only to the user that has issues.

    Thanks,

    Gaja


    Gaja Kannan

    Friday, May 11, 2012 2:21 PM

Answers

  • Hi Gaja,

    If the config file is included in the deployment, I would go into the user's cache and edit that file and change it.

    We publish configuration information with our deployments, and our program checks for an override file in a specific folder that will override one or more configuration entries. So we load the file from the ClickOnce deployment, then we look for the override file and if we find it, we load it, parse it, and replace just those settings. We have actually given override files to our customers and had them put them in the right folder so we can turn on additional logging and things like that.

    So this is one idea. Other than editing the user's files, you could deploy a separate build for those customers with the logging turned on. Another idea is if your application is connected to a backend with services, you could send down a field telling it whether to turn on the logging or not.

    RobinDotNet


    Click here to visit my ClickOnce blog!
    Microsoft MVP, Client App Dev

    • Marked as answer by GajaKannan Tuesday, May 15, 2012 5:26 PM
    Monday, May 14, 2012 11:54 PM

All replies

  • Hi Gaja,
    We can’t do custom action during Click once application deployment, but you can create custom Installer for a ClickOnce Application. However, I think you can perform the action when the ClickOnce application is first run. Use ApplicationDeployment.IsFirstRun Property to determine whether you need to perform any one-time initialization operations the first time your application runs.
    According to MSDN, Logging Application Block is able to detect configuration changes and reload the configuration without restarting the application. 
    I think you can detect whether has issues and set the logging level according to the result when the application is first run, then save the value to User Setting (Scope the user). The User setting will record the value for each user on this machine.
    The application should read the value and set the logging level each time the user start the application and should save the value if the user changes the logging level.
    For more details about setting, see http://msdn.microsoft.com/en-us/library/aa730869(v=vs.80).aspx
    http://msdn.microsoft.com/en-us/library/bb397750
    You can try the code below to modify sourceLevel Logging programmatically, see http://entlib.codeplex.com/discussions/284572
    If there is anything unclear, please let me know.
    Best Regards,

    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, May 14, 2012 12:40 PM
  • Hi Bob,

         We are not trying to override ClickOnce App deployment.  Currently the application is deployed using clickonce for all 500+ users.  At times, we get tickets that application is slow to some but not all users.  During that time, we want turn on tracing (using ent lib) for those users only by changing the logging framework config file.  Once the tracing is turned on we will get the actual time taken for an operation performed by user and compare it against a benchmark value and determine if it is slow and also get more information on where it is slowing...  Hope this clarifies my original question.

    Thanks,


    Gaja Kannan

    Monday, May 14, 2012 2:19 PM
  • Hi Gaja,

    If the config file is included in the deployment, I would go into the user's cache and edit that file and change it.

    We publish configuration information with our deployments, and our program checks for an override file in a specific folder that will override one or more configuration entries. So we load the file from the ClickOnce deployment, then we look for the override file and if we find it, we load it, parse it, and replace just those settings. We have actually given override files to our customers and had them put them in the right folder so we can turn on additional logging and things like that.

    So this is one idea. Other than editing the user's files, you could deploy a separate build for those customers with the logging turned on. Another idea is if your application is connected to a backend with services, you could send down a field telling it whether to turn on the logging or not.

    RobinDotNet


    Click here to visit my ClickOnce blog!
    Microsoft MVP, Client App Dev

    • Marked as answer by GajaKannan Tuesday, May 15, 2012 5:26 PM
    Monday, May 14, 2012 11:54 PM
  • Hi Gaja,
    Did you use Logging Application Block of Enterprise Library to logging?
    If so, the msdn document ( http://msdn.microsoft.com/en-us/library/ff649069 )said 
    The one exception to this is the Logging Application Block, which is able to detect configuration changes and reload the configuration without restarting the application. This works for Web Forms and Windows Forms applications, though it will still automatically trigger the application to restart for Web Forms applications. So you can update the configuration in your application according to the some condition or user choice.
    If you want to use different logging setting for different users on one machine, you can use the User Setting to save and load the information.
    In addition, according to your last description, it seems that this issue is not related to ClickOnce at all.
    Best Regards,

    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us


    Tuesday, May 15, 2012 8:21 AM
  • Thanks for detailed response Robin.  Sounds like it would work.

    If you override a file after clickonce deployment, during the next update from clickonce,

    • Skips the file
    • Overwrites the file
    • Errors out

    Thanks,


    Gaja Kannan

    Tuesday, May 15, 2012 5:26 PM
  • Hi Bob,

         Thanks for LAB.EL literature details.  The reason I put this under ClickOnce because if I override a file does ClickOnce crap out when it gets to that particular file during next update...

    Thanks,


    Gaja Kannan

    Tuesday, May 15, 2012 5:28 PM
  • When the next update is installed, it creates a new directory for the new version and puts the deployment  files there. It will not carry forward the override file. We think of this as a plus, in case the user doesn't delete the override file when we ask him to!

    RobinDotNet


    Click here to visit my ClickOnce blog!
    Microsoft MVP, Client App Dev

    Thursday, May 17, 2012 6:50 AM