-
Notifications
You must be signed in to change notification settings - Fork 15
Config File
In the root of your Visual Studio project create a JSON file and name it:
ILMergeConfig.json
Copy and paste bellow content into the JSON file and tweak the properties as needed. This represents the default configuration used by ILMerge.MSBuild.Task.
{
"General": {
"OutputFile": null,
"TargetPlatform": null,
"KeyFile": null,
"AlternativeILMergePath": null,
"InputAssemblies": []
},
"Advanced": {
"AllowDuplicateType": null,
"AllowMultipleAssemblyLevelAttributes": false,
"AllowWildCards": false,
"AllowZeroPeKind": false,
"AttributeFile": null,
"Closed": false,
"CopyAttributes": false,
"DebugInfo": true,
"DelaySign": false,
"DeleteCopiesOverwriteTarget": false,
"ExcludeFile": "",
"FileAlignment": 512,
"Internalize": false,
"Log": false,
"LogFile": null,
"PublicKeyTokens": true,
"SearchDirectories": [],
"TargetKind": null,
"UnionMerge": false,
"Version": null,
"XmlDocumentation": false
}
}
Since this is a JSON file make sure you escape characters according to JSON specification specially when entering paths where "\" should be replaced with "\\". For example:
Original Path | Escaped Path |
---|---|
C:\MyFolder\MyLib.dll | C:\\MyFolder\\MyLib.dll |
You can have a look at the JSON specification or use string escape tools such as JavaScript String Escape @ freeformatter.com
The following variables are supported in the configuration file:
Variable | Sample Value |
---|---|
$(ProjectDir) | D:\Development\MyPluginSolution\MyPluginProject\ |
$(ProjectFileName) | MyPluginProject.csproj |
$(ProjectPath) | D:\Development\MyPluginSolution\MyPluginProject\MyPluginProject.csproj |
$(SolutionDir) | D:\Development\MyPluginSolution\ |
$(SolutionPath) | D:\Development\MyPluginSolution\MyPluginSolution.sln |
$(TargetDir) | D:\Development\MyPluginSolution\MyPluginProject\bin\Debug\ |
$(TargetPath) | D:\Development\MyPluginSolution\MyPluginProject\bin\Debug\MyPluginProject.dll |
$(TargetFileName) | MyPluginProject.dll |
In this example a variable is used to specify assemblies in the target directory (usually Release or Debug):
{
"General": {
"InputAssemblies": [
"$(SolutionDir)libs\\Dependency1.dll",
"$(SolutionDir)libs\\Dependency2.dll"
]
}
}
The following properties can be used to change ILMerge.MSBuild.Task behavior:
Property | description |
---|---|
AlternativeILMergePath | A custom location for ILMerge.exe. |
DeleteCopiesOverwriteTarget | When set to true , all input assemblies (merged into the target assembly) will be deleted from the target directory. |
OutputFile | A custom location for the merged assembly. Default is: |
InputAssemblies | An array of assemblies to be merged into the project output. When specified, only these files will be merged (this will disable the default behavior which looks at the Copy Local property). There is no need to enter the project output. |
when using InputAssemblies
, there is no need to specify path if assemblies are expected to be in the output folder (copy local=true):
{
"General": {
"InputAssemblies": [
"Dependency1.dll",
"Dependency2.dll"
]
}
}
All other properties are ILMerge.exe properties.
For documentation, download and Install ILMerge from Microsoft's website. Open the installation folder (usually C:\Program Files (x86)\Microsoft\ILMerge) and look for the document file. Each property is very well documented by Microsoft.