Applying Dynamic Config To App-V 5 MSI Packages

CLICK HERE TO SEE THE NEW IMPROVED VERSION!

The App-V sequencer produces an MSI package by default as part of its output. This is a wrapper that runs the necessary commands to publish and remove the virtual application. I first assumed that these would usually just be used for test purposes since most places would deploy the App-V native infrastructure or use SCCM, but it turns out a few customers I am working with are using these in a live environment, particularly those using Windows Intune cloud based management software, which does not handle App-V packages natively.

A big limitation of these MSI packages however, is that they ignore the DeploymentConfig.xml files (the UserConfig.xml file is irrelevant since the MSI publishes the app globally to all users). This means that if you want to modify any package settings, or add some package scripts, then you need a separate process to import these custom configurations and re-publish the applications with Powershell commands. Most people I have encountered have opted to forget the App-V deployment and stick with a traditional MSI if such scripting is required, rather than face the hassle of managing this situation.

To solve this, I have created a generic MST transform that can be used when installing the MSI to automatically import the DeploymentConfig.xml file, and also optionally enable/disable package scripts.

To use this, you would install like so:

msiexec /i MyApp.msi /qn TRANSFORMS=ApplyDeploymentConfig.mst

There are a couple of optional properties supported too. In the example above, it will assume that the DeploymentConfig.xml matches the default naming convention. If you have a custom file name however, you can supply it via the DEPLOYMENTCONFIG property:

msiexec /i MyApp.msi /qn TRANSFORMS=ApplyDeploymentConfig.mst DEPLOYMENTCONFIG=”C:\MyAppConfig.xml”

Or:

msiexec /i MyApp.msi /qn TRANSFORMS=ApplyDeploymentConfig.mst DEPLOYMENTCONFIG=”MyAppConfig.xml”

If no path is specified for the xml file, it assumes the same directory as the MSI package.

Because you may typically supply a custom config file in order to use App-V scripting, you can also enable (or disable) package scripts with the ENABLEPACKAGESCRIPTS property:

To enable scripts:
msiexec /i MyApp.msi /qn TRANSFORMS=ApplyDeploymentConfig.mst ENABLEPACKAGESCRIPTS=1

Or to disable scripts:
msiexec /i MyApp.msi /qn TRANSFORMS=ApplyDeploymentConfig.mst ENABLEPACKAGESCRIPTS=0

If this property is not supplied then the settings will not be modified.

Click here to download the transform.

I have designed it to work with both 32-bit and 64-bit clients, but have only tested it on 64-bit. Leave comments below if you find any issues!

 

19 responses on “Applying Dynamic Config To App-V 5 MSI Packages

  1. Pingback: Deployment Models and Dynamic Configurations in App-V 5 | Kirx' Blog

  2. Tim

    Have you considered altering the MST that is in the sequencer itself? I used to do this in 4.5. The MST you find there is basically a template used in the msi creation. So you can safely add to it there and all packages have the option parameter switches that you add in. Do it once and include in the sequencing image snapshot. Whenever you need the adjusted functionality, it’s just adding switches to the cmd line. Probably should update your altered template with each App-V release.

    1. Never thought of that, nice idea.

      1. Jonas Berends

        Nice idea indeed. Just bear in mind that in the App-V 5.0 sequencer, there is just an MSI (“PackageMsiTemplate.msi”) under C:\Program Files\Microsoft Application Virtualization\Sequencer\en-US. The transform found in the 4.x versions of the sequencer (“1041.mst”) is no longer…

  3. Sylvain

    Any update so that we can simply enter the filename?

    1. I’m sure it can be done, I’ll look into it when I can.

      1. Jonas Berends

        Hi Dan,

        In Custom Action “GetDeploymentConfigXml”, replace

        If Session.Property(“DEPLOYMENTCONFIG”) =”” Then Session.Property(“DEPLOYMENTCONFIG”) = Replace(Session.Property(“OriginalDatabase”),”.msi”,”_DeploymentConfig.xml”)

        with

        If Session.Property(“DEPLOYMENTCONFIG”) =”” Then
        Session.Property(“DEPLOYMENTCONFIG”) = Replace(Session.Property(“OriginalDatabase”),”.msi”,”_DeploymentConfig.xml”)
        Else
        strXMLFile = Session.Property(“DEPLOYMENTCONFIG”)
        strLastBackSlash = InStrRev(Session.Property(“OriginalDatabase”), “\”)
        Session.Property(“DEPLOYMENTCONFIG”) = LEFT(Session.Property(“OriginalDatabase”), strLastBackSlash) & strXMLFile
        End If

        and you can simply enter the filename of your custom deployment config xml.

        Cheers,
        Jonas

        1. Thanks Jonas, making this tweak was something I meant to do at some point! When I get time I will update my MST.

        2. I’ve updated my MST with a slightly different version; yours always prepends the property with the path, mine only does it when there are no backslashes in the property. This allows you the flexibility of supplying a blank property, one with a full path, or just a file name:

          1. Jonas

            Nice one Dan! I hadn’t thought of that… 🙂

  4. Anne

    Hi,
    I configure grant permission in “Deploymentconfig.xml”. After that, I use your “MST” file to apply this file. the package publish successfully but grant permission is not effect. (I use App-V 5 and 64bit machine)
    As below is my scrip which is added into “Deploymentconfig.xml”

    cmd.exe
    /c %SYSTEMROOT%\System32\icacls.exe “[{AppVPackageRoot}]\VFS\Common AppData\SpinMe Studio Enterprise” /grant Everyone:(OI)(CI)F

    1. Sounds like nothing to do with the MST, but you can’t adjust VFS permissions like that. Refer to these posts:


  5. Neel

    I have tested the below command line however it does not work.

    msiexec /i MyApp.msi /qn TRANSFORMS=ApplyDeploymentConfig.mst DEPLOYMENTCONFIG=”C:\MyApp Config.xml”

    On the other hand, if I use PowerShell commandline to deploy MyApp Config.xml it installs perfectly.

    Add-AppvClientPackage”*.appv” -DynamicDeploymentConfiguration “_DeploymentConfig.xml” | Publish-Appvpackage -Global

    1. I haven’t tested it with xml files containing a space in the name, this could be the source of your issues – please try again without, and I will test for this myself when I get a chance.

  6. Mattski

    Can you use this for usercongif.xml files too, Dan?

    1. The MSI publishes the app globally so that it is available to all users. All the settings in the userconfig you can put in the deploymentconfig so that they apply to all users – the only reason for using a custom userconfig.xml is if you have different configurations for different user groups, something that you can’t easily make use of with the MSI based installation.

      The transform just runs a Powershell command to import config however, so it could be tweaked to apply a UserConfig via the Publish-AppvClientPackage, but you would need to know the SID of the user account you wanted to publish it to!

      By the way, I have an updated version of this MST that uses a much nicer method and also fixes a couple of other issues with the MSI, there will be an updated post coming soon.

  7. Manish

    I have tried using the provided MST, and in my application I have added some scripts to run from deployment config, which is not running using MST. Hence ultimately my purpose of creating MST fails. Please provide any inputs on this.

  8. Manish

    Hello Guys, I came to know this works for 5.0 version as in 5.0 by default when you install using MSI, it takes deployment config file, whereas this feature is removed in App-V 5.1. For 5.1, I could not find anything where deployment config can be passed.

    1. Stay tuned, I will post a new version next week (on hols right now)!

Leave a Reply