forked from phatboyg/Magnum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathilmerge.build
184 lines (162 loc) · 11.3 KB
/
ilmerge.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?xml version="1.0" encoding="utf-8" ?>
<project name="ILMergeBuilder" default="go">
<!-- Project UppercuT - http://projectuppercut.org -->
<property name="build.config.settings" value="__NONE__" overwrite="false" />
<include buildfile="${build.config.settings}" if="${file::exists(build.config.settings)}" />
<property name="path.separator" value="${string::trim(path::combine(' ', ' '))}" />
<property name="file.current.no_extension" value="ilmerge" />
<property name="dirs.current" value="${directory::get-parent-directory(project::get-buildfile-path())}" />
<property name="path.to.toplevel" value=".." />
<property name="folder.build_scripts" value="build" overwrite="false" />
<property name="folder.build_scripts_custom" value="build.custom" overwrite="false" />
<property name="dirs.build_scripts_custom" value="${dirs.current}${path.separator}${path.to.toplevel}${path.separator}${folder.build_scripts_custom}" />
<property name="folder.code_drop" value="code_drop" overwrite="false" />
<property name="dirs.drop" value="${dirs.current}${path.separator}${path.to.toplevel}${path.separator}${folder.code_drop}" overwrite="false" />
<property name="folder.app.drop" value="${project.name}" overwrite="false" />
<property name="dirs.lib" value="${dirs.current}${path.separator}${path.to.toplevel}${path.separator}lib" overwrite="false" />
<property name="dirs.ilmerge.folder" value="${dirs.lib}${path.separator}ILMerge" />
<property name="app.ilmerge" value="${dirs.ilmerge.folder}${path.separator}ILMerge.exe" overwrite="false" />
<property name="dirs.merge.log" value="${dirs.drop}${path.separator}build_artifacts${path.separator}ilmerge" />
<property name="log.merge" value="ilmerge.log" />
<property name="file.uppercut.assembly" value="uppercut.tasks.dll" />
<property name="path.uppercut.assembly" value="${dirs.current}${path.separator}${file.uppercut.assembly}" />
<property name="dirs.merge.from" value="${dirs.drop}${path.separator}${folder.app.drop}" overwrite="false" />
<property name="dirs.merge.to" value="${dirs.drop}${path.separator}merge" overwrite="false" />
<property name="file.internalize.ignore" value="ilmerge.internalize.ignore.txt" />
<property name="path.file.internalize.ignore" value="${dirs.build_scripts_custom}${path.separator}${file.internalize.ignore}" />
<property name="file.merge.name" value="__REPLACE__" overwrite="false" />
<!-- exe winexe dll -->
<property name="merge.target.type" value="__REPLACE__" overwrite="false" />
<property name="args.ilmerge" value="/internalize /target:${merge.target.type} /out:${dirs.merge.to}${path.separator}${file.merge.name} /log:${dirs.merge.log}${path.separator}${log.merge} /ndebug /xmldocs /allowDup ${file.merge.name} " />
<property name="args.ilmerge" value="/internalize:${path.file.internalize.ignore} /target:${merge.target.type} /out:${dirs.merge.to}${path.separator}${file.merge.name} /log:${dirs.merge.log}${path.separator}${log.merge} /ndebug /xmldocs /allowDup ${file.merge.name} " if="${file::exists(path.file.internalize.ignore)}"/>
<property name="allow.powershell.unrestricted" value="false" overwrite="false" />
<property name="file.custom.step.before" value="${dirs.build_scripts_custom}${path.separator}${file.current.no_extension}.pre.build" />
<property name="file.custom.step.after" value="${dirs.build_scripts_custom}${path.separator}${file.current.no_extension}.post.build" />
<property name="file.custom.step.replace" value="${dirs.build_scripts_custom}${path.separator}${file.current.no_extension}.replace.build" />
<property name="is.replaced" value="false" />
<property name="fail.build.on.error" value="true" />
<target name="go" depends="load_uppercut_assemblies, allow_powershell_unrestricted, run_tasks" />
<target name="run_tasks">
<echo message="Running ${project::get-name()} tasks." />
<call target="prepare" if="${target::exists('prepare')}" />
<call target="custom_tasks_before" if="${target::exists('custom_tasks_before')}" />
<call target="custom_tasks_replace" if="${target::exists('custom_tasks_replace')}" />
<call target="run_normal_tasks" if="${not is.replaced}" />
<call target="custom_tasks_after" if="${target::exists('custom_tasks_after')}" />
</target>
<target name="run_normal_tasks"
depends="set_environment_variables, error_check, get_regular_dlls, run_ilmerge, copy_configs, remove_unneeded_assemblies, copy_from_merge, delete_merge_folder"
description="Running ILMerge with UppercuT default.build." />
<target name="custom_tasks_before">
<echo message="Running custom tasks if ${file.custom.step.before} exists." />
<nant buildfile="${file.custom.step.before}" inheritall="true" if="${file::exists(file.custom.step.before)}" failonerror="${fail.build.on.error}" />
<exec program="powershell.exe" if="${file::exists(file.custom.step.before + '.ps1')}" failonerror="${fail.build.on.error}">
<arg value="${path::get-full-path(file.custom.step.before + '.ps1')}" />
</exec>
<exec program="ruby.exe" if="${file::exists(file.custom.step.before + '.rb')}" failonerror="${fail.build.on.error}">
<arg value="${path::get-full-path(file.custom.step.before + '.rb')}" />
</exec>
</target>
<target name="custom_tasks_replace">
<echo message="Running custom tasks instead of normal tasks if ${file.custom.step.replace} exists." />
<property name="is.replaced" value="true" if="${file::exists(file.custom.step.replace)}" />
<nant buildfile="${file.custom.step.replace}" inheritall="true" if="${file::exists(file.custom.step.replace)}" failonerror="${fail.build.on.error}" />
<property name="is.replaced" value="true" if="${file::exists(file.custom.step.replace + '.ps1')}" />
<exec program="powershell.exe" if="${file::exists(file.custom.step.replace + '.ps1')}" failonerror="${fail.build.on.error}" >
<arg value="${path::get-full-path(file.custom.step.replace + '.ps1')}" />
</exec>
<property name="is.replaced" value="true" if="${file::exists(file.custom.step.replace + '.rb')}" />
<exec program="ruby.exe" if="${file::exists(file.custom.step.replace + '.rb')}" failonerror="${fail.build.on.error}" >
<arg value="${path::get-full-path(file.custom.step.replace + '.rb')}" />
</exec>
</target>
<target name="set_environment_variables">
<property name="dirs.merge.from" value="${environment::get-variable('uc.dirs.merge.from')}" if="${environment::variable-exists('uc.dirs.merge.from')}" />
<property name="dirs.merge.to" value="${environment::get-variable('uc.dirs.merge.to')}" if="${environment::variable-exists('uc.dirs.merge.to')}" />
<property name="file.merge.name" value="${environment::get-variable('uc.file.merge.name')}" if="${environment::variable-exists('uc.file.merge.name')}" />
<property name="merge.target.type" value="${environment::get-variable('uc.merge.target.type')}" if="${environment::variable-exists('uc.merge.target.type')}" />
<property name="args.ilmerge" value="/internalize /target:${merge.target.type} /out:${dirs.merge.to}${path.separator}${file.merge.name} /log:${dirs.merge.log}${path.separator}${log.merge} /ndebug /xmldocs /allowDup ${file.merge.name} " />
<property name="args.ilmerge" value="/internalize:${path.file.internalize.ignore} /target:${merge.target.type} /out:${dirs.merge.to}${path.separator}${file.merge.name} /log:${dirs.merge.log}${path.separator}${log.merge} /ndebug /xmldocs /allowDup ${file.merge.name} " if="${file::exists(path.file.internalize.ignore)}"/>
</target>
<target name="error_check">
<fail message="You must pass in the file.merge.name and the merge.target.type through the command line calling this build. Please do that and retry the build. You can also set up an ilmerge.pre.build and set these environment variables: uc.dirs.merge.from, uc.dirs.merge.to, uc.file.merge.name, and uc.merge.target.type"
if="${file.merge.name=='__REPLACE__' or merge.target.type=='__REPLACE__'}" />
</target>
<target name="prepare">
<mkdir dir="${dirs.merge.log}" />
<mkdir dir="${dirs.merge.to}" />
</target>
<target name="get_regular_dlls">
<echo message="Getting output dlls based on name in directory ${path::get-full-path(dirs.merge.from)}." />
<property name="dll.names" value="" />
<foreach item="File" property="dll.filename">
<in>
<items>
<exclude name="${dirs.merge.from}${path.separator}${file.merge.name}" />
<include name="${dirs.merge.from}${path.separator}*.dll" />
<include name="${dirs.merge.from}${path.separator}*.exe" />
</items>
</in>
<do>
<property name="dll.names" value="${dll.names + ' ' + path::get-file-name(dll.filename)}" />
</do>
</foreach>
<property name="dlls.regular" value="${dll.names}" />
<property name="args.ilmerge" value="${args.ilmerge} ${dlls.regular}" />
</target>
<target name="run_ilmerge">
<echo message="Merging the the contents of ${dirs.merge.from} into a single executable - ${dirs.merge.to}${path.separator}${file.merge.name}. This will fail if all dependencies are not resolved."/>
<echo message="Running this: ${app.ilmerge} ${args.ilmerge}"/>
<exec program="${app.ilmerge}"
workingdir="${dirs.merge.from}"
commandline="${args.ilmerge}" />
</target>
<target name="copy_configs">
<copy todir="${dirs.merge.to}">
<fileset basedir="${dirs.merge.from}">
<include name="**/*.config" />
</fileset>
</copy>
</target>
<target name="remove_unneeded_assemblies">
<echo message="Removing unneeded assemblies before moving the merged assembly back into ${dirs.merge.from}."/>
<delete>
<fileset basedir="${dirs.merge.from}" >
<include name="*.*" />
</fileset>
</delete>
</target>
<target name="copy_from_merge">
<copy todir="${dirs.merge.from}">
<fileset basedir="${dirs.merge.to}">
<include name="**/*.*" />
</fileset>
</copy>
</target>
<target name="delete_merge_folder">
<delete dir="${dirs.merge.to}" failonerror="false" />
</target>
<target name="custom_tasks_after">
<echo message="Running custom tasks if ${file.custom.step.after} exists." />
<nant buildfile="${file.custom.step.after}" inheritall="true" if="${file::exists(file.custom.step.after)}" failonerror="${fail.build.on.error}" />
<exec program="powershell.exe" if="${file::exists(file.custom.step.after + '.ps1')}" failonerror="${fail.build.on.error}" >
<arg value="${path::get-full-path(file.custom.step.after + '.ps1')}" />
</exec>
<exec program="ruby.exe" if="${file::exists(file.custom.step.after + '.rb')}" failonerror="${fail.build.on.error}" >
<arg value="${path::get-full-path(file.custom.step.after + '.rb')}" />
</exec>
</target>
<target name="load_uppercut_assemblies">
<loadtasks assembly="${path.uppercut.assembly}" if="${file::exists(path.uppercut.assembly)}" />
</target>
<target name="allow_powershell_unrestricted">
<!-- powershell 1.0 -->
<exec program="powershell.exe" if="${allow.powershell.unrestricted}" failonerror="false">
<arg value="set-executionpolicy unrestricted" />
</exec>
<!-- powershell 2.0 -->
<exec program="powershell.exe" if="${allow.powershell.unrestricted}" failonerror="false">
<arg value="set-executionpolicy unrestricted -force -scope CurrentUser" />
</exec>
</target>
</project>