pcservtn
Posts: 5
Joined: Thu Apr 25, 2019 3:57 pm

How to use AI to replicate this Wixproj Target TaskAction

I'm working on replacing a Wix Msi project with an Advanced Installer project.

I've run into a Target in the .wixproj file that looks like this:

<Target Name="CreateSolutionInstallerConfigFile">
<Copy SourceFiles="Configuration\Setup\SPSolutions.SharePoint.SolutionInstaller.exe.config.template" DestinationFiles="Configuration\Setup\SPSolutions.SharePoint.SolutionInstaller.exe.config" />
<MSBuild.ExtensionPack.Xml.XmlFile TaskAction="UpdateAttribute" File="Configuration\Setup\SPSolutions.SharePoint.SolutionInstaller.exe.config" XPath="/configuration/spSolutions.solutionInstaller/deploymentPlans/deploymentPlan[@name='ExCM']/solutions/solution[@id='{5d85f35b-15e7-4625-8eff-b5c64f3abe4d}']" Key="version" Value="$(ProductVersion)" />
<ItemGroup>
<Content Include="Configuration\Setup\SPSolutions.SharePoint.SolutionInstaller.exe.config" />
</ItemGroup>
</Target>

What this is doing, I believe, is making a copy of an XML file and saving it under a new name and then using MSBuild.ExtensionPack to edit an element in the copied file. Then, the copied and edited file gets deployed by the installer, rather than the original file, which is intended to serve as a template for this task.

What feature(s) in AI would I use to accomplish this same thing?

Thanks,
Jeff
Catalin
Posts: 6584
Joined: Wed Jun 13, 2018 7:49 am

Re: How to use AI to replicate this Wixproj Target TaskAction

Hello Jeff,

In what regards the copy operation of the XML file, you can have a look on the following articles:

1. File Operations in the Files And Folders Page

2. File Copy/Move Dialog

In what regards the edit operation for the XML file, you can have a look on the following articleS:

3. How to import and edit an XML file

4. Edit XML File Dialog

However, if I am not mistaken, you want the edit operation for the XML file to happen during install time (please correct me if I'm wrong). In this case, the above points (3 and 4) may not apply. However, this can still be achieved through a custom action. For instance, you can use a "Run Inline PowerShell Script" or any other script type custom action (here you can see a full list of our predefined custom actions).

If you want, you can forward me, either here or by e-mail at support at advancedinstaller dot com the content of your XML file and what you want to be replaced in it and I may be able to help you creating and configuring the custom action.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
pcservtn
Posts: 5
Joined: Thu Apr 25, 2019 3:57 pm

Re: How to use AI to replicate this Wixproj Target TaskAction

Thanks, Catailn. I will email you a zip with my XML file and an explanation of what I need to update in it during the deployment process. Then, you can give me your feedback on the best feature for me to use to update it.

Jeff
Catalin
Posts: 6584
Joined: Wed Jun 13, 2018 7:49 am

Re: How to use AI to replicate this Wixproj Target TaskAction

Hello Jeff,

First of all, please accept my apologies for the delayed reply, but we were quite busy lately. Also, we do not work over the weekend here.

Thanks for the sent file. Here is a little PowerShell script that will modify the desired value:

Code: Select all

[XML] $appConfigFile = Get-Content -Path "C:\Users\Catalin\Desktop\SPSolutions.SharePoint.SolutionInstaller.exe.config"

$solution = $appConfigFile.SelectNodes('//solution')

# iterate through all nodes returned by SelectNodes() method and modify "version"

foreach ($node in $solution){
$node.SetAttribute("version", "4.1.0.0")
}

# saves the XML file (please be aware that the name is changed from "SolutionInstaller..." to "SolutionInstaller1".

[XML]$appConfigFile.Save("C:\Users\Catalin\Desktop\SPSolutions.SharePoint.SolutionInstaller1.exe.config")
This can be added as a "Run PowerShell inline script" custom action with sequence. In order to add a custom action with sequence, all you have to do is to press the "Add custom action with sequence" button which is placed to the right side of the custom action's name.

The custom action will be scheduled, by default, in "Install Execution Stage", between "Add resources" and "Finish Execution" action group. This is fine, since the files (including your XML file) are copied on the target machine during the "Add resources" action group. By placing the custom action after, we will have access to the XML file.

The Execution Time of this custom action should be set to "When the system is being modified (deferred)".

You would probably want to execute this custom action only during the installation process, so you can uncheck the "Uninstall" and "Maintenance" checboxes from under the "Execution Stage Condition" section.

Once again, I apologize for the delayed reply and hopefully this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
pcservtn
Posts: 5
Joined: Thu Apr 25, 2019 3:57 pm

Re: How to use AI to replicate this Wixproj Target TaskAction

Thanks, Catalin, I'll give this a try.

I think I am going to add this to the beginning of the Powershell script to get the correct version number of a DLL that is put on the file system during "Add Resources":

$assembly = "C:\{my path to dll}\SPSolutions.SharePoint.ExCM.dll"
$version = (Get-Command $assembly).FileVersionInfo.FileVersion

Then, I can use $version to put the correct version number in XML attribute.

Thanks for your help!

Jeff
Catalin
Posts: 6584
Joined: Wed Jun 13, 2018 7:49 am

Re: How to use AI to replicate this Wixproj Target TaskAction

You are always welcome, Jeff.

I'm glad I could help.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”