forked from peters/il-repack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
137 lines (116 loc) · 4.9 KB
/
build.gradle
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
import org.gradle.internal.os.OperatingSystem
plugins {
id 'com.ullink.msbuild' version '2.21'
id 'com.ullink.nuget' version '2.15'
id 'com.ullink.nunit' version '1.12'
id 'com.ullink.opencover' version '1.10'
id 'net.researchgate.release' version '2.3.4'
}
archivesBaseName = 'ILRepack'
defaultTasks('nugetPack')
nuget {
version = '4.4.1'
}
assemblyInfoPatcher {
version = project.version + '.0'
}
msbuild.dependsOn nugetRestore
msbuild {
solutionFile = 'ILRepack.sln'
configuration = OperatingSystem.current().unix ? 'Debug_unix' : 'Release'
projectName = 'ILRepack'
inputs.file(project.buildFile)
}
nunit {
exclude = 'LongRunning'
testAssemblies = [ msbuild.projects['ILRepack.Tests'].properties.TargetPath, msbuild.projects['ILRepack.IntegrationTests'].properties.TargetPath ]
}
nunit.dependsOn msbuild
task nunitLongRunning(type: nunit.class) {
include = 'LongRunning'
testAssemblies = [ msbuild.projects['ILRepack.IntegrationTests'].properties.TargetPath ]
}
nunitLongRunning.dependsOn msbuild
ext.repackList = ['ILRepack.exe', 'Fasterflect.dll', 'BamlParser.dll', 'Mono.Cecil.dll', 'Mono.Cecil.Mdb.dll', 'Mono.Cecil.Pdb.dll', 'Mono.Posix.dll']
// repacking of all dependencies in a single exe
task repack(dependsOn: [msbuild, nunitLongRunning]) {
inputs.files {
def workingDir = msbuild.mainProject.getProjectPropertyPath('OutputPath')
return project.ext.repackList.collect { new File(workingDir, it) }
}
ext.repacked = new File(temporaryDir, 'ILRepack.exe')
ext.repackedLib = new File(temporaryDir, 'ILRepack.dll')
outputs.files([ext.repacked, ext.repackedLib, ext.repacked.path.replace('.exe','.pdb')])
}
repack << {
def isMono = !OperatingSystem.current().windows
def outputPath = msbuild.mainProject.getProjectPropertyPath('OutputPath')
def repackExe = new File(outputPath, 'ILRepack.exe')
def executable = isMono ? ['mono', repackExe] : [repackExe]
exec {
workingDir = outputPath
commandLine = [*executable, '/log', '/wildcards', '/internalize', '/ndebug', '/out:'+ext.repacked] + project.ext.repackList
}
exec {
workingDir = outputPath
commandLine = [*executable, '/log', '/wildcards', '/internalize', '/keyfile:'+file('ILRepack/ILRepack.snk'), '/out:'+ext.repackedLib, '/target:library'] + project.ext.repackList
}
}
def commonNuspecMetadata = [
version: version,
title: 'ILRepack - Open-source alternative to ILMerge',
authors: 'Francois Valdy',
owners: 'Francois Valdy',
projectUrl: 'https://github.com/gluck/il-repack',
copyright: 'Copyright Francois Valdy 2011-2015',
requireLicenseAcceptance: false,
dependencies: []
]
// nuget package for upload to nuget
nugetSpec {
nuspec = [
metadata: commonNuspecMetadata + [
id: archivesBaseName,
description: '''ILRepack is meant at replacing ILMerge / Mono.Merge.
The former being closed-source, impossible to customize, slow, resource consuming and many more. The later being deprecated, unsupported, and based on an old version of Mono.Cecil.''',
summary: 'ILRepack is a utility that can be used to merge multiple .NET assemblies into a single assembly'
],
files: [
{ file(src: repack.ext.repacked, target: 'tools') },
{ file(src: project.file('ILRepack.props'), target: 'build') }
]
]
}
task nugetSpecLib(type: com.ullink.NuGetSpec) {
nuspec = [
metadata: commonNuspecMetadata + [
id: archivesBaseName+'.Lib',
description: '''ILRepack is meant at replacing ILMerge / Mono.Merge.
The former being closed-source, impossible to customize, slow, resource consuming and many more. The later being deprecated, unsupported, and based on an old version of Mono.Cecil.
This package provides a library, for use within tools/build projects.
If you need the tool as an executable, this is not the package you're looking for, this one is: http://www.nuget.org/packages/ILRepack/.''',
summary: 'ILRepack is a utility that can be used to merge multiple .NET assemblies into a single assembly (Packaged as library)'
],
files: [
{ file(src: repack.ext.repackedLib, target: 'lib/net40') }
]
]
}
task nugetPackLib(type: com.ullink.NuGetPack) {
dependsOn nugetSpecLib
}
nugetPack.dependsOn([repack, nugetPackLib])
nugetPackLib.dependsOn repack
// nuget package upload, requires API key to be set
nugetPush {
serverUrl = 'https://www.nuget.org/api/v2/package'
apiKey = project.properties.nugetApiKey
nupkgFile = nugetPack.packageFile
}
task nugetPushLib(type: com.ullink.NuGetPush) {
serverUrl = 'https://www.nuget.org/api/v2/package'
apiKey = project.properties.nugetApiKey
nupkgFile = nugetPackLib.packageFile
}
nugetPush.dependsOn nugetPushLib
project.tasks.afterReleaseBuild.dependsOn project.tasks.nugetPush