emerbrito / ILMerge-MSBuild-Task

Adds ILMerge to Visual Studio 2013/2017 or automated builds. This Task is intended to work right out of the box however, it supports a configuration file where you can control every ILMerge property including the list of assemblies to be merged.
MIT License
54 stars 15 forks source link

include unmergedassemblies as searchdirectories #12

Closed mathiasbl closed 6 years ago

mathiasbl commented 6 years ago

When merging dll's for a CRM plugin assembly, you don't want to merge the CRM SDK dll's since this will throw errors when registrating. To fix this you should set the 'Copy Local' to false for the CRM SDK dll's but this will result in ILMerge to throw an unresolved reference error.

Adding unmerged assemblies (or references with 'Copy Local' set to false) as search directories will allow ILMerge to find the reference.

mathiasbl commented 6 years ago

@emerbrito Is this repo still active?

emerbrito commented 6 years ago

Hi there,

Pretty much. I use this project on a daily bases, just didn't have the needs to update it yet. Looks like I was having an issue with notifications though. I didn't receive any notifications regarding your commits and comment.

I will look into it today (and make sure I get notifications moving forward). By the way, thanks for contributing to this project.

emerbrito commented 6 years ago

@mathiasbl I went through your pull request and it looks good, thank you. I'm still trying to understand the use case you described. I work with Dynamics CRM on a daily basis and use this project to merge all my plugins without any issues.

I do use the suggested configuration file, which I never have to create myself since I'm using my own Visual Studio template to create the plugins (XrmUtils Dynamics 365 Project Templates). The default configuration file from the project template looks like this:

ILMergeConfig.json
{
  "General": {
    "InputAssemblies": [
      "XrmUtils.Extensions.dll",
      "XrmUtils.Plugins.Extensions.dll"
    ]
  }
}

Based on this configuration t will merge the project output (my plugin) wth the two XrmUtils.*.dll from above. Basically it will always be my output plus whatever I manually specify in "InputAssemblies", giving me more control of what to merge.

When I have additional assemblies such as a common repositories and business logic I manually add them to the above list.

Could you please elaborate on how you are doing it? Are you getting the nuget package and using it without the configuration file? If I'm not mistaken the nuget package doesn't add the file to prevent it from being overwritten.

mathiasbl commented 6 years ago

hi @emerbrito,

I was using this build task before using yours. This one would merge every assembly in the output. If you didn't want assemblies to be merged, you would have the set the 'Copy Local' to false in the project references. This needed to happen for the CrmSdk core assemblies.

When I started using your build task I was using the same steps and got unresolved references errors. Yes, I do use the setting file but I don't want to manually define or add assemblies to the InputAssemblies setting. It's only a matter of time before I forget to edit this :). Now I can add nuget packages or project references and don't need to worry about the assembly not being merged.

Hope this explains.