I want to use ILMerge to merge a number of .dlls as part of the build definition/script. How do I do that with TFS 2015?
There are a number of ways to do this. Here's one way that I found to be simple and clean. I'm only going to cover the part about adding the ILMerge process to an existing build definition that is already successfully building and publishing your build artifacts. I'm also going to gloss over how ILMerge works and where to get it.
Open your build definition for editing;
Add a 'Command Line' build step
Click 'Add' button next to 'Command Line' and close the dialog.
Note: Only click it once. Gets added but dialog stays open.
In the 'Tool' input, specify: $(Build.ArtifactStagingDirectory)\ILMerge.exe
Note: You may need to customize this path depending on where you are getting ILMerge from. See 'Referencing ILMerge' section down below.
/lib:"C:\Windows\Microsoft.NET\Framework\v4.0.30319" /out:"\\SomeServer\BuildDrops\Builds\$(Build.DefinitionName)\$(Build.BuildNumber)\$(Build.DefinitionName).dll" /log:"\\SomeServer\BuildDrops\Builds\$(Build.DefinitionName)\$(Build.BuildNumber)\MergeLog.txt" $(Build.ArtifactStagingDirectory)\ABC.Services.dll $(Build.ArtifactStagingDirectory)\ABC.Auth.dll $(Build.ArtifactStagingDirectory)\ABC.Lib.dll $(Build.ArtifactStagingDirectory)\ABC.Content.dll $(Build.ArtifactStagingDirectory)\ABC.Test.dll /targetplatform:v4`
Referencing ILMerge - Note: There are a number of ways you can do this so I'll just note a few.
1. Copy ILMerge.exe down from the network at build time. (Recommended)
2. Copy ILMerge to the build client machine and create an environment variable on the build clients for it.
3. You might be able to figure out a way to reference ILMerge directly from a network share.
4. Add a copy of ILMerge to one of your projects.
It really doesn't matter where you put it in the solution because ILMerge.exe runs post-build.
If you place ILMerge.exe anywhere besides the root of one of your projects, you may need to update the Tool path in the 'Command Line' build step AND you would need to update any path in the arguments to reflect the working directory of ILMerge.exe. You'll likely be looking at needing some '..\..\' in your paths. I didn't test that.*
Argument Notes:
/lib:"C:\Windows\Microsoft.NET\Framework\v4.0.30319"
/out:"\SomeServer\BuildDrops\Builds\$(Build.DefinitionName)\$(Build.BuildNumber)\$(Build.DefinitionName).dll"
log:"\SomeServer\BuildDrops\Builds\$(Build.DefinitionName)\$(Build.BuildNumber)\MergeLog.txt"
$(Build.ArtifactStagingDirectory)\ABC.Auth.dll
/targetplatform:v4
Additional Resources: https://www.visualstudio.com/en-us/docs/build/steps/utility/command-line