I have a blocker in MSI installer package creation, please find the below details and let me know if any solutions,
I have written PowerShell script to automate the Hyper-V virtual machine provision ( AWS i3.metal instance type ) and the script is working fine.
I wants that PowerShell script as MSI installer package
Working in visual studio 2017 community version to make MSI installer package
For that I used WIX installer commands and created wxs file to make MSI
Successfully created MSI installer using WIX but while installing that MSI, it’s not invoking PowerShell script
But I could see that application installed ( listed in control panel & installation folder is created in C:\programFiles)
Used wix SetProperty, CustomAction & InstallExecuteSequence cmd but no luck with invoking Powershell script
This is for a new Windows server
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="19fe6e20-a840-4829-8883-bde0bfa51d4c" Name="testing" Language="1033" Version="1.0.0.0" Manufacturer="muni" UpgradeCode="93008c8b-adb9-4498-8be2-4a83162b3a35">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="test" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="ProductComponent">
<File Source="C:\Users\Administrator\source\repos\testMSI\test\Invoke-Test.ps1" Id="InvokeTestPS1" />
</Component>
</ComponentGroup>
</Fragment>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="testing" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Component Guid="*">
<File Id="InvokeTestPS1" Source="Invoke-Test.ps1" />
</Component>
</DirectoryRef>
<Property Id="POWERSHELLEXE">
<RegistrySearch Id="POWERSHELLEXE"
Type="raw"
Root="HKLM"
Key="SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell"
Name="Path" />
</Property>
<Condition Message="This application requires Windows PowerShell.">
<![CDATA[Installed OR POWERSHELLEXE]]>
</Condition>
<SetProperty Id="InvokeTestPS1"
Before="InstallFinalize"
Sequence="execute"
Value =""[POWERSHELLEXE]" -Version 2.0 -NoProfile -NonInteractive -InputFormat None -ExecutionPolicy Bypass -Command "& '[#InvokeTestPS1]' ; exit $$($Error.Count)"" />
<CustomAction Id="InvokeTestPS1"
BinaryKey="WixCA"
DllEntry="WixSilentExec"
Execute="immediate"
Return="check"
Impersonate="yes" />
<InstallExecuteSequence>
<Custom Action="InvokeTestPS1" After="InstallFinalize">
<![CDATA[NOT Installed]]>
</Custom>
</InstallExecuteSequence>
</Fragment>
<Fragment>
<Feature Id="Application" Title="Minefold" Level="1">
<ComponentRef Id="ProductComponent" />
</Feature>
</Fragment>
</Wix>
MSI installer should invoke Powershell script - Means once i created MSI then i need to install that MSI and MSI need to invoke the powershell script
Related
I am wanting to create a nuget that adds a dll reference into the type libary of visual studio and .net. Now normally you would use reserve32 nameof.dll is there a way to achieve this with nuget package explorer
I would normally run this command from an administrative comcmand prompt
regsvr32 nameof.dll
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MyPackage</id>
<version>1.0.0</version>
<title></title>
<authors>User</authors>
<owners>User</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>My package description.</description>
</metadata>
<files>
<file src="build\_._" target="build\_._" />
<file src="content\Sage50ApplicationObject.chm" target="content\Sage50ApplicationObject.chm" />
<file src="content\SageDataObjects2017.chm" target="content\SageDataObjects2017.chm" />
<file src="content\SageDataObjectsv24.chm" target="content\SageDataObjectsv24.chm" />
<file src="content\SageDataObjectsv25.chm" target="content\SageDataObjectsv25.chm" />
<file src="lib\SdoEng170.tlb" target="lib\SdoEng170.tlb" />
<file src="lib\SdoEng200.tlb" target="lib\SdoEng200.tlb" />
<file src="lib\SdoEng220.tlb" target="lib\SdoEng220.tlb" />
<file src="lib\SdoEng230.tlb" target="lib\SdoEng230.tlb" />
<file src="lib\SdoEng240.tlb" target="lib\SdoEng240.tlb" />
<file src="lib\SdoEng250.tlb" target="lib\SdoEng250.tlb" />
<file src="lib\sg50SdoEngine170.dll" target="lib\sg50SdoEngine170.dll" />
<file src="lib\sg50SdoEngine200.dll" target="lib\sg50SdoEngine200.dll" />
<file src="lib\sg50SdoEngine220.dll" target="lib\sg50SdoEngine220.dll" />
<file src="lib\sg50SdoEngine230.dll" target="lib\sg50SdoEngine230.dll" />
<file src="lib\sg50SdoEngine240.dll" target="lib\sg50SdoEngine240.dll" />
<file src="lib\sg50SdoEngine250.dll" target="lib\sg50SdoEngine250.dll" />
</files>
</package>
I then should be able to see it in the references section of the com in visual studio as per below its to help me speed up not always having to register these each project.
As per below screen shot
Edit 2
I found this code which should allow it to process the command through powershell.
param($installPath, $toolsPath, $package, $project)
regsvr32 Join-Path $toolsPath '\mycom.dll' /s
$project.Object.References | Where-Object { $_.Name -eq "MYCOMLib" } | ForEach-Object { $_.EmbedInteropTypes = $false }
But where do i place this code and how can I adjust it to take into account all my dlls. As they all require regsvr32.dll to be called.
see Can NuGet distribute a COM dll?
I could never find where this is clearly documented on the MS site, but here's what I did:
Create a folder and add the nuspec file to it.
Then create a subfolder: tools.
Put your dlls in the tools folder.
Name your Powershell script file 'install.ps1' and put it in the tools folder.
The nuget package will run the ps1 script during its install process. Put the dlls in a 'lib' folder (sibling to 'tools') if you want to add them as references to the project you're importing the nuget package into.
see also https://learn.microsoft.com/en-us/nuget/create-packages/creating-a-package#create-the-nuspec-file
I am new in wix and creating a window service. I have created my service and successfully added in window service but when I run it stopped due to error.
<?xml version="1.0" encoding="UTF-8"?>
<?define Name = "New Window Service" ?>
<?define Manufacturer = "GAT" ?>
<?define UpgradeCode = "{0d4fb541-bb66-4df8-bdab-893564e191fc}" ?>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"
>
<Product Id="*" Name="$(var.Name)" Manufacturer="$(var.Manufacturer)" Version="1.0.0.0" UpgradeCode="$(var.UpgradeCode)" Language="1033">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<Media Id="1" Cabinet="GAT.GATAC.ServiceLayer.WindowsServiceHost.cab" EmbedCab="yes" />
<MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="ROOTDIRECTORY" Name="$(var.Manufacturer)">
<Directory Id="INSTALLFOLDER" Name="$(var.Name)" />
</Directory>
</Directory>
</Directory>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="$(var.GAT.GATAC.ServiceLayer.WindowsServiceHost.TargetFileName)">
<CreateFolder />
<File Id="$(var.GAT.GATAC.ServiceLayer.WindowsServiceHost.TargetFileName)" Source="D:\Projects\GATAC\GAT.GATAC.ServiceLayer.WindowsServiceHost\bin\Release\GAT.GATAC.ServiceLayer.WindowsServiceHost.exe" KeyPath="yes" Vital="yes" />
<File Id="GAT.GATAC.ServiceLayer.WindowsServiceHost.exe.config"
Name="MyProduct.exe.config"
Source="D:\Projects\GATAC\GAT.GATAC.ServiceLayer.WindowsServiceHost\bin\Release\GAT.GATAC.ServiceLayer.WindowsServiceHost.exe.config"
Vital="yes"
KeyPath="no"
DiskId="1" />
<RemoveFile Id="ALLFILES" Name="*.*" On="both" />
<util:XmlFile Id="ModifyServiceLocation" Action="setValue" ElementPath="/configuration/connectionStrings/add[\[]#name='DefaultConnection'[\]]/#connectionString" File="D:\Projects\GATAC\GAT.GATAC.ServiceLayer.WindowsServiceHost\bin\Release\GAT.GATAC.ServiceLayer.WindowsServiceHost.exe.config" Value="Data Source=[DB_SERVER];Initial Catalog=[DB_DATABASE];User Id=[DB_USER];Pwd=[DB_PASSWORD]"/>
<ServiceInstall Id="ServiceInstaller"
Type="ownProcess"
Name="GAT.GATAC.ServiceLayer.WindowsServiceHost"
DisplayName="$(var.Name)"
Description="A Test Service that logs dummy text on an interval to a text file."
Start="auto"
ErrorControl="normal"
/>
<ServiceControl Id="ServiceInstaller"
Stop="both"
Remove="both"
Name="GAT.GATAC.ServiceLayer.WindowsServiceHost"
Wait="yes" />
</Component>
</DirectoryRef>
<Feature Id="MainApplication" Title="Main Application" Level="1">
<ComponentRef Id="$(var.GAT.GATAC.ServiceLayer.WindowsServiceHost.TargetFileName)" />
</Feature>
</Product>
</Wix>
when I saw in installation folder of service there is only exe file so how to copy all dependencies of window service in this folder my code is following.When I copy files manually in installation folder it works.Do I need to harvest
Yes, you need to include ALL files in your wxs as components you want to install.
If you have a few dependencies, you can just add them as File components yourself. If there are a lot of files consider using heat to generate the wxs file for you and you can copy the file elements into your wxs code. If the file dependencies may change frequently, consider using heat to always generate the wxs and include it as a linked file in your main installer project.
Ideally all your dependencies are being included in the GAT.GATAC.ServiceLayer.WindowsServiceHost project's bin folder so you can just use $(var.GAT.GATAC.ServiceLayer.WindowsServiceHost.TargetDir)DependencyFileName as the Source for the file.
Is there tutorial for creating a WiX installer, that can check if MCR is already installed and if not can install it?
I'm working with Visual Studio 2012.
Here's my solution for MCR 2012a and .NET 4.5 please comment if there is a better way to do it:
this is for documentation
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
xmlns:netfx='http://schemas.microsoft.com/wix/NetFxExtension'>
<Bundle Name="MYAPP"
Version="0.6"
Manufacturer="MY Corporation"
UpgradeCode="f380ae43-5df1-4cfe-9297-526e3e638e57">
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />
<Chain>
<!-- TODO: Define the list of chained packages. -->
<PackageGroupRef
Id="Netfx45FullPackage"/>
</Chain>
</Bundle>
<Fragment>
<util:RegistrySearch
Id="MatlabPath"
Variable="UniqueId"
Root="HKLM"
Key="SOFTWARE\Matworks\MATLAB\4.17\"
Result="exists"/>
<PackageGroup Id="Netfx45FullPackage">
<ExePackage
Id="Netfx45Xxx"
Cache="no"
Compressed="no"
PerMachine="yes"
Permanent="yes"
Vital="no"
InstallCommand="/q"
SourceFile="..\SetupProject\dotnetfx45_full_x86_x64.exe"
DetectCondition="(Netfx4FullVersion="4.5.50709") AND (NOT VersionNT64 OR (Netfx4x64FullVersion="4.5.50709"))"
InstallCondition="(VersionNT >= v6.0 OR VersionNT64 >= v6.0) AND (NOT (Netfx4FullVersion="4.5.50709" OR Netfx4x64FullVersion="4.5.50709"))"/>
<ExePackage
Id="MatlabMCR2012a64"
Cache="no"
Compressed="no"
PerMachine="yes"
Permanent="yes"
Vital="no"
InstallCommand="/q"
SourceFile="..\SetupProject\MCR_R2012a_win64_installer.exe"
InstallCondition="(NOT MatlabPath)"/>
<MsiPackage
Id="MYAPP"
Cache="no"
Compressed="no"
Vital="yes"
SourceFile="..\SetupProject\bin\Release\MYAPPSetup.msi"/>
</PackageGroup>
</Fragment>
</Wix>
I'm creating the package for my assembly but I dont' want to include the docs/*.xml files in my nuget package. I have tried the -Exclude switch of the pack command and the exclude property for the files section in the nuspec file to explictly excluding these files. None of these worked. So every time I generate my nuget package and then test it by installing it in the target project it always adds a docs folder with all the xml files. How can I avoid that the xml files are included into the nuget package? Any help would be highly appreciated.
To exclude all .xml files you should use the **\*.xml wildcard. I am guessing that you are using *.xml which will not work.
To exclude all .xml files you could use a nuget command line similar to the following:
nuget.exe pack MyPackage.nuspec -Exclude **\*.xml
If you only need to exclude .xml files in the docs directory then you can use a nuget command line similar to the following:
nuget.exe package MyPackage.nuspec -Exclude **\docs\*.xml
The wildcards seem to work relative to the folder that your .nuspec file is in.So if you have an .xml file in a docs subfolder relative to the .nuspec file then a wildcard if docs*.xml should work too.
Thank you Matt, I'm already doing what you mentioned but seems to me that Nuget does some other things by convention. Even if I use the exclude just like you said the docs folder is included. I resolved the issue by generating the nuspec file with the -a switch (I was using my .csproj file). I also had to copy the .dll file to a folder outside of my solution's folder. This way everything worked fine and as expected.
Anyway your answer is accurate but in my scenario it wasn't working. Not sure if this is by design.
Here's my final msbuild file which I'm currently using to generate the package. Hopefully Nuget soon will add more switches to the spec command so we won't have to modify so much the nuspec file afterwards.
<Project DefaultTargets="NugetPackage" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<OutputPathCore>NugetPkgs\$(Configuration)\My.Assembly</OutputPathCore>
<NuGetExePath>assets\nuget.exe</NuGetExePath>
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<Import Project="$(MSBuildExtensionsPath)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks"/>
<Target Name="NugetPackage" DependsOnTargets="PackageClean;BuildNugetPackageMyAssembly">
<Target Name="PackageClean">
<RemoveDir Directories ="NugetPkgs\$(Configuration)" ContinueOnError ="true"/>
<Target Name="BuildNugetPackageMyAssembly">
<MakeDir Directories="$(OutputPathCore)" />
<MakeDir Directories="$(OutputPathCore)\Package" />
<MakeDir Directories="$(OutputPathCore)\lib\net40" />
<MakeDir Directories="$(OutputPathCore)\lib\net20" />
<MakeDir Directories="$(OutputPathCore)\lib\net20-cf" />
<Copy
DestinationFolder="$(OutputPathCore)\lib\net40"
SourceFiles="Source\My.Assembly\bin\$(Configuration)\My.Assembly.dll" />
<Copy
DestinationFolder="$(OutputPathCore)\lib\net20"
SourceFiles="VS2008\Source\My.Assembly\bin\$(Configuration)\My.Assembly.dll" />
<Copy
DestinationFolder="$(OutputPathCore)\lib\net20-cf"
SourceFiles="VS2008\Source\My.Assembly.CF\bin\$(Configuration)\My.Assembly.CF.dll" />
<Copy DestinationFolder="$(OutputPathCore)\content" SourceFiles="CHANGES" />
<Copy SourceFiles="Release Notes.txt" DestinationFiles="$(OutputPathCore)\Readme.txt" />
<Exec Command=""$(NuGetExePath)" spec -a "$(OutputPathCore)\lib\net40\My.Assembly.dll"" />
<XmlUpdate Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" XmlFileName="My.Assembly.nuspec" XPath="//package/metadata/licenseUrl" Value="http://someurl" />
<XmlUpdate Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" XmlFileName="My.Assembly.nuspec" XPath="//package/metadata/projectUrl" Value="http://someurl" />
<XmlUpdate Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" XmlFileName="My.Assembly.nuspec" XPath="//package/metadata/iconUrl" Value="http://somenice.png" />
<XmlUpdate Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" XmlFileName="My.Assembly.nuspec" XPath="//package/metadata/tags" Value="My.Assembly" />
<XmlUpdate Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" XmlFileName="My.Assembly.nuspec" XPath="//package/metadata/releaseNotes" Value="Review readme.txt for details." />
<ItemGroup>
<file Include="Source\My.Assembly\bin\$(Configuration)\My.Assembly.dll"/>
<file Include="VS2008\Source\My.Assembly\bin\$(Configuration)\My.Assembly.dll"/>
<file Include="$(OutputPathCore)\Readme.txt"/>
</ItemGroup>
<MSBuild.ExtensionPack.Xml.XmlFile TaskAction="RemoveElement" File="My.Assembly.nuspec" Element="dependencies" XPath="//package/metadata/dependencies" />
<MSBuild.ExtensionPack.Xml.XmlFile TaskAction="AddElement" File="My.Assembly.nuspec" Key="" Value="" Element="files" XPath="//package" InsertAfterXPath="//package" />
<MSBuild.ExtensionPack.Xml.XmlFile TaskAction="AddElement" File="My.Assembly.nuspec" Key="src" Value="%(file.Identity)" Element="file" XPath="//package/files" />
<MSBuild.ExtensionPack.Xml.XmlFile TaskAction="AddAttribute" File="My.Assembly.nuspec" XPath="//package/files/*[1]" Key="target" Value="lib\net40" />
<MSBuild.ExtensionPack.Xml.XmlFile TaskAction="AddAttribute" File="My.Assembly.nuspec" XPath="//package/files/*[2]" Key="target" Value="lib\net20" />
<MSBuild.ExtensionPack.Xml.XmlFile TaskAction="AddAttribute" File="My.Assembly.nuspec" XPath="//package/files/*[3]" Key="target" Value=""/>
<Exec Command=""$(NuGetExePath)" pack My.Assembly.nuspec -OutputDirectory "$(OutputPathCore)\Package" -NoPackageAnalysis" />
<Delete Files ="My.Assembly.nuspec" />
Another thing I can think of is
Create a nuspec file and edit it. this needs to be done only once (could be checked in as well). Any reasons you are editing the nuspec file while doing build?
use files element in nuspec file to copy files to destination folders
<files>
<file src="bin\Debug\*.dll" target="lib" />
<file src="bin\Debug\*.pdb" target="lib" />
<file src="tools\*\.*" exclude="*\.log" />
</files>
3. pack command can remain to be done at build time.
more details for files can be found here http://docs.nuget.org/docs/reference/nuspec-reference
I got ant script running fine inside Eclipse
Here is a piece of it :
<p2.composite.repository failOnExists="true">
<repository location="file:/${basedir}/compRepo" name="Repository description goes here" />
<add>
<repository location="http://url/Eclipse/repo/Galileo-3.5.1/" />
<repository location="http://another-url/Java/repo/4.0/" />
<repository location="${diag.location}" />
</add>
</p2.composite.repository>
But I would like Hudson CI server to be able to run it, but, no matter all the jars I put in ANT_HOME/lib I can't get this task to run in a simple command line ant...
I got stuck with this error :
C:\workspaces\workspace\project\junit.script\createCompRepo.xml:10: Problem: failed to create task or type p2.composite.repository
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
Where are defined the p2 ant tasks ? Is there a way to run them outside Eclipse ?
Thank you very much for you help !
Anthony
By reading this thread and the P2 Publisher documentation, it should be in org.eclipse.equinox.launcher_*.jar
Example of a P2 task (not an ant task here) just for the -jar argument:
java -jar <targetProductFolder>/plugins/org.eclipse.equinox.launcher_*.jar
-application org.eclipse.equinox.p2.publisher.UpdateSitePublisher
-metadataRepository file:/<some location>/repository
-artifactRepository file:/<some location>/repository
-source /<location with a site.xml>
-configs gtk.linux.x86
-compress
-publishArtifacts
The P2 Ant tasks are described here, and in the Eclipse help.
The OP Anthony43 adds in the comments:
I just want to run an an ant target with p2 taskdefs, outside of eclipse.
I found out that I should use antRunner, using such a command line :
./eclipse -vm /opt/sun-java2-6.0/bin/java -nosplash \
-data ${java.io.tmpdir}/workspace -consolelog \
-application org.eclipse.ant.core.antRunner \
-f /path/to/scripts/partialMirrorFromRepo.xml
But Andrew Niefer (Eclipse committer on PDE/Build, p2, & Equinox Framework) adds:
The p2 tasks need to be run inside an osgi environment and won't work in a normal ant run.
That is why you need to use the org.eclipse.ant.core.antRunner application.
Starting with "java -jar launcher.jar" is just an alternate method to invoking the eclipse executable.
martin jakubik mentions:
I would have liked to see a command that I could cut&paste and that put everything together.
What I used was:
java -jar <eclipse-install-directory>\eclipse\plugins\org.eclipse.equinox.launcher_*.jar -application org.eclipse.ant.core.antRunner.
Note that I could not figure out what <targetProductFolder> was, so I used <eclipse-install...> instead.
I created a small Ant macro for that exact purpose
<path id="equinox.launcher.path">
<fileset dir="${eclipse.home}/plugins">
<include name="org.eclipse.equinox.launcher_*.jar" />
</fileset>
</path>
<macrodef name="antRunner">
<!-- Ant script location -->
<attribute name="antFile" />
<!-- the arguments for the script that is executed -->
<attribute name="args" default=""/>
<sequential>
<java
classname="org.eclipse.equinox.launcher.Main"
fork="true"
failonerror="true">
<arg line="-application org.eclipse.ant.core.antRunner" />
<arg line="-f #{antFile}" />
<arg line="#{args}"/>
<classpath refid="equinox.launcher.path" />
</java>
</sequential>
</macrodef>
All the p2 tasks NEED the eclipse runtime (as explicitly stated in the eclipse help mentioned above), so you definitely need to use eclipse.
The only way to get round of it would be to analyze the eclipse code, extract what is needed and create your own build system with it.
Just to complete the example of Jarek Przygódzki here is my solution, using his ant-file. I'm not well versed in using ant, so there might be potential for optimisation.
This aproach is used headless on a server without GUI, nevertheless I had to install eclipse. Installation with apt-get wasn't working, so it's better to install manual (download and untar).
First antfile assembles names, versions, etc...
Second antfile is called from first antfile and creates composite repositories.
First antfile:
<project name="project">
<!-- ....do some other stuff...-->
<target name="p2.composite.add">
<!--Call macro for child repo-->
<antRunner
name="${site.composite.name}"
location="${composite.repository.directory}"
child="${child.repository}"
/>
<!--Call macro for main repo-->
<antRunner
name="${main.site.composite.name}"
location="${main.composite.repository.directory}"
child="${majorMinorVersion}"
/>
</target>
<!--Eclipse installation path-->
<path id="equinox.launcher.path">
<fileset dir="/usr/share/eclipse/plugins">
<include name="org.eclipse.equinox.launcher_1.3.201.v20161025-1711.jar" />
</fileset>
</path>
<macrodef name="antRunner">
<attribute name="name"/>
<attribute name="location"/>
<attribute name="child"/>
<sequential>
<java
classname="org.eclipse.equinox.launcher.Main"
fork="true"
failonerror="true">
<arg line="-application org.eclipse.ant.core.antRunner" />
<arg line="-f addCompositeInternal.ant run" />
<arg line="-Dcomposite.name=#{name}"/>
<arg line="-Dcomposite.location=#{location}"/>
<arg line="-Dcomposite.child=#{child}"/>
<classpath refid="equinox.launcher.path" />
</java>
</sequential>
</macrodef>
</project>
Second Antfile, named addCompositeInternal.ant
<project name="composite">
<target name="run">
<add.composite.repository.internal
composite.repository.location="${composite.location}"
composite.repository.name="${composite.name}"
composite.repository.child="${composite.child}"
/>
</target>
<!-- = = = = = = = = = = = = = = = = =
macrodef: add.composite.repository.internal
= = = = = = = = = = = = = = = = = -->
<macrodef name="add.composite.repository.internal">
<attribute name="composite.repository.location" />
<attribute name="composite.repository.name" />
<attribute name="composite.repository.child" />
<sequential>
<echo message=" " />
<echo message="Composite repository : #{composite.repository.location}" />
<echo message="Composite name : #{composite.repository.name}" />
<echo message="Adding child repository : #{composite.repository.child}" />
<p2.composite.repository>
<repository compressed="false" location="#{composite.repository.location}" name="#{composite.repository.name}" />
<add>
<repository location="#{composite.repository.child}" />
</add>
</p2.composite.repository>
<echo file="#{composite.repository.location}/p2.index">version=1
metadata.repository.factory.order=compositeContent.xml,\!
artifact.repository.factory.order=compositeArtifacts.xml,\!
</echo>
</sequential>
</macrodef>
</project>