App-V 5 Configuration Editor User Guide

ACEWe’ve been working hard getting the App-V 5 Configuration Editor (ACE) ready for official release; take a look at the ACE page for a bit more information about why it was developed.

The purpose of this short blog to guide you through the ACE interface. There is an assumption here you have an understanding of the App-V 5 Dynamic Configuration files and how they are used, if not you might want to take a look at this Technet article.

USER INTERFACE

Main Toolbar:

You will notice there are three main buttons in the tool bar as shown below:

Main Toolbar

image Opens an App-V XML file, i.e. a UserConfig.xml or DeploymentConfig.xml file. Once the file has been opened the contents will be parsed and displayed under the various tabs within the GUI.

image Saves the current App-V XML file, including any changes that have been made. You can give it a new name and Save As a different file, keeping your original one as is if necessary.

image Previews the changes that will be made to the App-V XML file before saving. This gives you the ability to check out the structure of the generated XML. It’s probably a good idea to point out here that you don’t need to preview the changes prior to performing a save.

Package Details:

This sections displays the Package Display Name, Package ID and Type of XML file opened, i.e. DeploymentConfig or UserConfig. Here is an example DeploymentConfig.xml opened below:

Package Details

MAIN CONFIGURATION TABS

Once an App-V 5 configuration XML file has been opened you can then begin to make changes as required using the tabs set out below.

User Configuration

Under the User Configuration tab you can change and view various options and configurations:

User Configuration

Options

Various global options change be changed here if you so desire, e.g. altering the COM integration mode.

Shortcuts

This tab allows you to View, Add, Edit or Delete any Shortcuts within the package.

If you want to delete an existing shortcut, simply select the row that contains the shortcut and press delete. Should you wish to add a new shortcut, I’d suggest you copy and paste an existing row and then edit the fields accordingly; we’ve added a context menu to make that task easy, should you not fancy using Ctrl+C and Ctrl+V  Smile.

Shortcuts

Scripts (User Context)

This is really where ACE starts to make life simple Smile. You can easily define which scripts you’d like to add and to which script actions, e.g. PublishPackage, UnpublishPackage, StartVirtualEnvironment, TerminateVirtualEnvironment, StartProcess and ExitProcess. There is no need to worry about getting the syntax in the XML file right. There are some excellent blogs out there talking about using scripts in App-V 5.0, so I suggest you take a look here at one from Tim Mangan and Microsoft’s own Steve Thompson if you need some further background information.

NOTE: You might have noticed that not all the script actions are available under this tab, that’s simply because those excluded aren’t permitted to run under the User Configuration section of the XML file.

I think most of the options are self explanatory but, it’s good to point out that leaving the Timeout value at 0 means no timeout period will be set, i.e. it will wait indefinitely for it to finish so use with caution.

Scripts (User Context)

Machine Configuration

Under the Machine Configuration tab you can alter global options, configure scripts and control the termination of processes.

NOTE: this tab will only be available when you open a DeploymentConfig.xml file. This is because machine configuration items cannot be set in the UserConfig.xml file.

Machine Configuration

Options

Here you’ll find any options that can be changed if you so desire.

Terminate Child Processes

You can define the path to an executable, that when closed, will terminate any child process running within the virtual environment.

Terminate Child Processes

Scripts (System Context)

Very much like the Scripts tab under User Configuration you can define which scripts you’d like to add to which machine script actions, e.g. AddPackage, RemovePackage, PublishPackage and UnpublishPackage.

NOTE: You might have noticed that not all the script actions are available under this tab, that’s simply because those excluded aren’t permitted to run under the Machine Configuration section of the XML file.

Scripts (System Context)

XML

You can view both the source (original) XML and/or preview the generated XML under this tab.

Source XML

Source XML

This is simply where you can view your source App-V XML file as it was when you opened it.

Generated XML

Once you click the Preview button image this pane will display any changes that will be made to the App-V XML file, giving you the ability to check out the structure of the XML before saving if you wish. NOTE: You don’t have to preview the changes prior to performing a save.

The example below (highlighted in yellow) shows the changes made by ACE in the generated XML format. NOTE: ACE will not highlight the changes in the XML, we’ve done it here for clarity purposes only.

Generated XML

With any luck this brief guide has given you a good overview of how to use ACE and hopefully you’ll agree its pretty intuitive to use and should make editing the App-V 5 Dynamic Configuration files a lot, lot easier (well we think so anyway!)? 🙂

DISCLAIMER: THE APP-V CONFIGURATION EDITOR IS FREE TO USE AT YOUR OWN RISK, WE CANNOT BE HELD RESPONSIBLE FOR ANY DAMAGE IT MIGHT CAUSE.

App-V 5 Configuration Editor User Guide

ACEWe’ve been working hard getting the App-V 5 Configuration Editor (ACE) ready for a BETA release; take a look at the ACE page for a bit more information about why it was developed.

With any new application it’s great to have some user guides, right (RTFM)?!? Rest assured that will come when it’s officially released, in the mean time we wanted to create this short blog to guide you through the ACE interface. There is also an assumption here you have an understanding of the App-V 5 Dynamic Configuration files and how they are used, if not you might want to take a look at this technet article.

USER INTERFACE

Main Toolbar:

You will notice there are three main buttons in the tool bar as shown below:

SNAGHTML105760e

image Opens an App-V XML file, i.e. a UserConfig.xml or DeploymentConfig.xml file. Once the file has been opened the contents will be parsed and displayed under the various tabs within the GUI.

image Saves the current App-V XML file, including any changes that have been made. You can give it a new name and Save As a different file, keeping your original one as is if necessary.

image Previews the changes that will be made to the App-V XML file before saving. This gives you the ability to check out the structure of the generated XML. It’s probably a good idea to point out here that you don’t need to preview the changes prior to performing a save.

Package Details:

This sections displays the Package Display Name, Package ID and Type of XML file opened, i.e. DeploymentConfig or UserConfig. Here is an example DeploymentConfig.xml opened below:

SNAGHTML10a6c4e

MAIN CONFIGURATION TABS

Once an App-V 5 configuration XML file has been opened you can then begin to make changes as required using the tabs set out below.

User Configuration

Under the User Configuration tab you can change and view various options and configurations:

SNAGHTML1151fa5

Options

Various global options change be changed here if you so desire, e.g. altering the COM integration mode.

Shortcuts

This tab allows you to view all the defined Shortcuts within the package.

NOTE: at this time its Read Only but is great for getting an overview of all the Shortcuts available.

SNAGHTML123eb5d

Scripts (User Context)

This is really where ACE starts to make life simple Smile. You can easily define which scripts you’d like to add and to which actions, e.g. PublishPackage, UnpublishPackage, StartVirtualEnvironment, TerminateVirtualEnvironment, StartProcess and ExitProcess. There is no need to worry about getting the syntax in the XML file right. There are are some excellent blogs out there talking about using scripts in App-V 5.0, so I suggest you take a look here at one from Tim Murgent and Microsoft’s own Steve Thompson if you need some further background information.

NOTE: You might have noticed that not all the script actions are available under this tab, that’s simply because those excluded aren’t permitted to run under the User Configuration section of the XML file.

I think most of the options are self explanatory but, it’s good to point out that leaving the Timeout value at 0 means no timeout period will be set, i.e. it will wait indefinitely for it to finish so use with caution.

SNAGHTML137e66e

Machine Configuration

Under the Machine Configuration tab you can alter global options, configure scripts and control the termination of processes.

NOTE: this tab will only be available when you open a DeploymentConfig.xml file. This is because machine configuration items cannot be set in the UserConfig.xml file.

SNAGHTML144b2d1

Options

Here you’ll find any options that can be changed if you so desire.

Terminate Child Processes

You can define the path to an executable, that when closed, will terminate any child process running within the virtual environment.

SNAGHTML14d302a

Scripts (System Context)

Very much like the Scripts tab under User Configuration you can define which scripts you’d like to add to which actions, e.g. AddPackage, RemovePackage, PublishPackage and UnpublishPackage.

NOTE: You might have noticed that not all the script actions are available under this tab, that’s simply because those excluded aren’t permitted to run under the Machine Configuration section of the XML file.

SNAGHTML1522226

XML

You can view both the source (original) XML and/or preview the generated XML under this tab.

SNAGHTML18ecc7a

Source XML

This is simply where you can view your source App-V XML file as it was when you opened it.

Generated XML

Once you click the Preview button image this pane will display any changes that will be made to the App-V XML file, giving you the ability to check out the structure of the XML before saving if you wish.

NOTE: You don’t have to preview the changes prior to performing a save.

The example below (highlighted in yellow) shows the changes made by ACE in the generated XML format.

SNAGHTML19082ed

Hopefully this brief guide has given you a good overview of how to use ACE. Hopefully you’ll agree its pretty intuitive to use and should make editing the App-V 5 Dynamic Configuration files a lot, lot easier (well we think so anyway!) 🙂

DISCLAIMER: THE APP-V CONFIGURATION EDITOR IS FREE TO USE AT YOUR OWN RISK, WE CANNOT BE HELD RESPONSIBLE FOR ANY DAMAGE IT MIGHT CAUSE.

Updating and Writing XML Files with PowerShell

Manipulating XML files with PowerShell is something that we’re having to accomplish more and more internally. Microsoft App-V 5.0 and RES Workspace Manager utilise XML files extensively. Whilst we can manually tweak them, there’s nothing like automating things for consistency and speed!

I have seen a lot of “rip and replace” and “find and replace” script examples, but ensuring that the correct elements/nodes are added in the correct place can be troublesome. The only real option is to utilise the built-in .Net Framework XML objects. Hopefully this post will lay the basis for some more App-V 5.0 focused blogs in the future Open-mouthed smile.

There are lots of forum posts out there that detail snippets of information, but a lot of it is trial and error. As a starting point you might want to read up here first. Reading XML files is one thing, but as the previous article mentions, inserting (multiple) elements can be quite convoluted. Note: I’m using the XmlDocument .Net object here but it is possible to utilise other .Net classes, e.g. XPath and/or XDocument.

Here is the example we’ll use in this post. Apologies; the XML formatting is stripped by the plugin:

<!-- employees.xml -->
<employees>
  <employee id="101">
    <name>Frankie Johnny</name>
    <age>36</age>
  </employee>
  <employee id="102">
    <name>Elvis Presley</name>
    <age>79</age>
  </employee>
  <employee id="301">
    <name>Ella Fitzgerald</name>
    <age>102</age>
  </employee>
</employees>

Creating XML Elements

If we wish to add a new employee record to the above document, we need to create a new XML element (or node). Firstly we need to load the XML document:

$fileName = “employees.xml”;
$xmlDoc = [System.Xml.XmlDocument](Get-Content $fileName);

Now we can create our new element/node, append it to the parent reference and save it:

$newXmlEmployeeElement = $xmlDoc.CreateElement("employee");
$newXmlEmployee = $xmlDoc.employees.AppendChild($newXmlEmployeeElement);
$xmlDoc.Save($fileName);

To shorten this we can just use this (see here for more information on the CreateElement method):

$newXmlEmployee = $xmlDoc.employees.AppendChild($xmlDoc.CreateElement("employee"));
$xmlDoc.Save($fileName);

If we examine the resulting XML file we’ll find the following (note the new empty element):

<!-- employees.xml -->
<employees>
  <employee id="101">
    <name>Frankie Johnny</name>
    <age>36</age>
  </employee>
  <employee id="102">
    <name>Elvis Presley</name>
    <age>79</age>
  </employee>
  <employee id="301">
    <name>Ella Fitzgerald</name>
    <age>102</age>
  </employee>
  <employee />
</employees>

 Adding XML Attributes

To add the ID attribute tag in the XML document, we need to create a new XmlDocument Attribute and then attach it to our newly created element. We can create an XmlDocument attribute on our element with the following code:

$newXmlEmployee = $xmlDoc.employees.AppendChild($xmlDoc.CreateElement("employee"));
$newXmlEmployee.SetAttribute(“id”,”111”);
$xmlDoc.Save($fileName);

Now our resulting XML file looks like this:

<!-- employees.xml -->
<employees>
  <employee id="101">
    <name>Frankie Johnny</name>
    <age>36</age>
  </employee>
  <employee id="102">
    <name>Elvis Presley</name>
    <age>79</age>
  </employee>
  <employee id="301">
    <name>Ella Fitzgerald</name>
    <age>102</age>
  </employee>
  <employee id="111">
</employees>[/code]

Adding Nested XML Elements

Knowing how to add elements we can simply create our sub elements and attach them to our newly created parent reference:

$newXmlNameElement = $newXmlEmployee.AppendChild($xmlDoc.CreateElement("name"));
$newXmlAgeElement = $newXmlEmployee.AppendChild($xmlDoc.CreateElement("age"));

The resulting XML file now looks like:

<!-- employees.xml -->
<employees>
  <employee id="101">
    <name>Frankie Johnny</name>
    <age>36</age>
  </employee>
  <employee id="102">
    <name>Elvis Presley</name>
    <age>79</age>
  </employee>
  <employee id="301">
    <name>Ella Fitzgerald</name>
    <age>102</age>
  </employee>
  <employee id="111">
    <name />
    <age />
  </employee>
</employees>

Adding XML Text Nodes

Unbeknownst to me, when you have text within an element tag, i.e. <name>Iain Brighton</name>, this is known as a text node (at least in XDocument speak). This is probably the bit that took longest to work out.

To add the text node we can use the following code:

$newXmlNameElement = $newXmlEmployee.AppendChild($xmlDoc.CreateElement("name"));
$newXmlNameTextNode = $newXmlNameElement.AppendChild($xmlDoc.CreateTextNode("Iain Brighton"));

$newXmlAgeElement = $newXmlEmployee.AppendChild($xmlDoc.CreateElement("age"));
$newXmlAgeTextNode = $newXmlAgeElement.AppendChild($xmlDoc.CreateTextNode("37"));

Et voilà!

<!-- employees.xml -->
<employees>
  <employee id="101">
    <name>Frankie Johnny</name>
    <age>36</age>
  </employee>
  <employee id="102">
    <name>Elvis Presley</name>
    <age>79</age>
  </employee>
  <employee id="301">
    <name>Ella Fitzgerald</name>
    <age>102</age>
  </employee>
  <employee id="111">
    <name>Iain Brighton</name>
    <age>37</age>
  </employee>
</employees>

 Full PowerShell Code Snippet

Here is the full code listing:

$fileName = “employees.xml”;
$xmlDoc = [System.Xml.XmlDocument](Get-Content $fileName);

$newXmlEmployee = $xmlDoc.employees.AppendChild($xmlDoc.CreateElement("employee"));
$newXmlEmployee.SetAttribute("id","111");

$newXmlNameElement = $newXmlEmployee.AppendChild($xmlDoc.CreateElement("name"));
$newXmlNameTextNode = $newXmlNameElement.AppendChild($xmlDoc.CreateTextNode("Iain Brighton"));

$newXmlAgeElement = $newXmlEmployee.AppendChild($xmlDoc.CreateElement("age"));
$newXmlAgeTextNode = $newXmlAgeElement.AppendChild($xmlDoc.CreateTextNode("37"));

$xmlDoc.Save($fileName);