Configuring ILMerge package












0














I have GUI c# project that has several additional packages in reference. I would like to have executable without any additional dll's in build output. For this purpose I'm trying to use ILMerge package from nuget. I have just installed package with command:



Install-Package ilmerge -Version 3.0.18


But as result I got same executable that requires dll's. Should I do any configuration in my project in order to make ILMerge package build merged executable?










share|improve this question



























    0














    I have GUI c# project that has several additional packages in reference. I would like to have executable without any additional dll's in build output. For this purpose I'm trying to use ILMerge package from nuget. I have just installed package with command:



    Install-Package ilmerge -Version 3.0.18


    But as result I got same executable that requires dll's. Should I do any configuration in my project in order to make ILMerge package build merged executable?










    share|improve this question

























      0












      0








      0







      I have GUI c# project that has several additional packages in reference. I would like to have executable without any additional dll's in build output. For this purpose I'm trying to use ILMerge package from nuget. I have just installed package with command:



      Install-Package ilmerge -Version 3.0.18


      But as result I got same executable that requires dll's. Should I do any configuration in my project in order to make ILMerge package build merged executable?










      share|improve this question













      I have GUI c# project that has several additional packages in reference. I would like to have executable without any additional dll's in build output. For this purpose I'm trying to use ILMerge package from nuget. I have just installed package with command:



      Install-Package ilmerge -Version 3.0.18


      But as result I got same executable that requires dll's. Should I do any configuration in my project in order to make ILMerge package build merged executable?







      c# nuget ilmerge






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 11 at 16:58









      vico

      4,5412166139




      4,5412166139
























          1 Answer
          1






          active

          oldest

          votes


















          1














          I can to propose to you another workaround, which works without any nuget packages, and just required some code:




          1. You should add all references of your project as Embeded Resources.


          2. After this in entrypoint of your app you should do next:



            AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;

            private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
            {
            var assemblyName = args.Name.Substring(0, args.Name.IndexOf(','));
            var assembly = ...load binary from embeded resources as you wish based on assemblyName...
            return Assembly.Load(assembly);
            }



          profit: no additional packages. Easy to use and debug.



          concern: hard to maintance if you have a lot of external packages. Needs to add them manually to Embeded Resources.






          share|improve this answer

















          • 1




            github.com/Fody/Costura - Same solution but automatically adds that code in to the main entry point and handles adding the packages as embedded resources ;)
            – Scott Chamberlain
            Nov 11 at 18:04










          • @ScottChamberlain i am pretty sure, that all ilmerge tools do same, but i prefer to control all stemp, if it's not cost to much. But anyway, thanks to your link =)
            – Sergey Shulik
            Nov 11 at 18:12










          • ILMerge actually modifies the original code of the dll to make it inside the exe. The problem with this is it breaks stuff like WPF's assembly names. The resource solution you and I show does not have the renaming problem. The comment I gave is just a way to automate it. Fun Fact: The author of ILMerge once said about using this embeding resources method "... I think this is fantastic! If I had known about this, I never would have written ILMerge."
            – Scott Chamberlain
            Nov 11 at 19:28













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53251057%2fconfiguring-ilmerge-package%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          I can to propose to you another workaround, which works without any nuget packages, and just required some code:




          1. You should add all references of your project as Embeded Resources.


          2. After this in entrypoint of your app you should do next:



            AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;

            private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
            {
            var assemblyName = args.Name.Substring(0, args.Name.IndexOf(','));
            var assembly = ...load binary from embeded resources as you wish based on assemblyName...
            return Assembly.Load(assembly);
            }



          profit: no additional packages. Easy to use and debug.



          concern: hard to maintance if you have a lot of external packages. Needs to add them manually to Embeded Resources.






          share|improve this answer

















          • 1




            github.com/Fody/Costura - Same solution but automatically adds that code in to the main entry point and handles adding the packages as embedded resources ;)
            – Scott Chamberlain
            Nov 11 at 18:04










          • @ScottChamberlain i am pretty sure, that all ilmerge tools do same, but i prefer to control all stemp, if it's not cost to much. But anyway, thanks to your link =)
            – Sergey Shulik
            Nov 11 at 18:12










          • ILMerge actually modifies the original code of the dll to make it inside the exe. The problem with this is it breaks stuff like WPF's assembly names. The resource solution you and I show does not have the renaming problem. The comment I gave is just a way to automate it. Fun Fact: The author of ILMerge once said about using this embeding resources method "... I think this is fantastic! If I had known about this, I never would have written ILMerge."
            – Scott Chamberlain
            Nov 11 at 19:28


















          1














          I can to propose to you another workaround, which works without any nuget packages, and just required some code:




          1. You should add all references of your project as Embeded Resources.


          2. After this in entrypoint of your app you should do next:



            AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;

            private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
            {
            var assemblyName = args.Name.Substring(0, args.Name.IndexOf(','));
            var assembly = ...load binary from embeded resources as you wish based on assemblyName...
            return Assembly.Load(assembly);
            }



          profit: no additional packages. Easy to use and debug.



          concern: hard to maintance if you have a lot of external packages. Needs to add them manually to Embeded Resources.






          share|improve this answer

















          • 1




            github.com/Fody/Costura - Same solution but automatically adds that code in to the main entry point and handles adding the packages as embedded resources ;)
            – Scott Chamberlain
            Nov 11 at 18:04










          • @ScottChamberlain i am pretty sure, that all ilmerge tools do same, but i prefer to control all stemp, if it's not cost to much. But anyway, thanks to your link =)
            – Sergey Shulik
            Nov 11 at 18:12










          • ILMerge actually modifies the original code of the dll to make it inside the exe. The problem with this is it breaks stuff like WPF's assembly names. The resource solution you and I show does not have the renaming problem. The comment I gave is just a way to automate it. Fun Fact: The author of ILMerge once said about using this embeding resources method "... I think this is fantastic! If I had known about this, I never would have written ILMerge."
            – Scott Chamberlain
            Nov 11 at 19:28
















          1












          1








          1






          I can to propose to you another workaround, which works without any nuget packages, and just required some code:




          1. You should add all references of your project as Embeded Resources.


          2. After this in entrypoint of your app you should do next:



            AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;

            private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
            {
            var assemblyName = args.Name.Substring(0, args.Name.IndexOf(','));
            var assembly = ...load binary from embeded resources as you wish based on assemblyName...
            return Assembly.Load(assembly);
            }



          profit: no additional packages. Easy to use and debug.



          concern: hard to maintance if you have a lot of external packages. Needs to add them manually to Embeded Resources.






          share|improve this answer












          I can to propose to you another workaround, which works without any nuget packages, and just required some code:




          1. You should add all references of your project as Embeded Resources.


          2. After this in entrypoint of your app you should do next:



            AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;

            private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
            {
            var assemblyName = args.Name.Substring(0, args.Name.IndexOf(','));
            var assembly = ...load binary from embeded resources as you wish based on assemblyName...
            return Assembly.Load(assembly);
            }



          profit: no additional packages. Easy to use and debug.



          concern: hard to maintance if you have a lot of external packages. Needs to add them manually to Embeded Resources.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 11 at 17:33









          Sergey Shulik

          678824




          678824








          • 1




            github.com/Fody/Costura - Same solution but automatically adds that code in to the main entry point and handles adding the packages as embedded resources ;)
            – Scott Chamberlain
            Nov 11 at 18:04










          • @ScottChamberlain i am pretty sure, that all ilmerge tools do same, but i prefer to control all stemp, if it's not cost to much. But anyway, thanks to your link =)
            – Sergey Shulik
            Nov 11 at 18:12










          • ILMerge actually modifies the original code of the dll to make it inside the exe. The problem with this is it breaks stuff like WPF's assembly names. The resource solution you and I show does not have the renaming problem. The comment I gave is just a way to automate it. Fun Fact: The author of ILMerge once said about using this embeding resources method "... I think this is fantastic! If I had known about this, I never would have written ILMerge."
            – Scott Chamberlain
            Nov 11 at 19:28
















          • 1




            github.com/Fody/Costura - Same solution but automatically adds that code in to the main entry point and handles adding the packages as embedded resources ;)
            – Scott Chamberlain
            Nov 11 at 18:04










          • @ScottChamberlain i am pretty sure, that all ilmerge tools do same, but i prefer to control all stemp, if it's not cost to much. But anyway, thanks to your link =)
            – Sergey Shulik
            Nov 11 at 18:12










          • ILMerge actually modifies the original code of the dll to make it inside the exe. The problem with this is it breaks stuff like WPF's assembly names. The resource solution you and I show does not have the renaming problem. The comment I gave is just a way to automate it. Fun Fact: The author of ILMerge once said about using this embeding resources method "... I think this is fantastic! If I had known about this, I never would have written ILMerge."
            – Scott Chamberlain
            Nov 11 at 19:28










          1




          1




          github.com/Fody/Costura - Same solution but automatically adds that code in to the main entry point and handles adding the packages as embedded resources ;)
          – Scott Chamberlain
          Nov 11 at 18:04




          github.com/Fody/Costura - Same solution but automatically adds that code in to the main entry point and handles adding the packages as embedded resources ;)
          – Scott Chamberlain
          Nov 11 at 18:04












          @ScottChamberlain i am pretty sure, that all ilmerge tools do same, but i prefer to control all stemp, if it's not cost to much. But anyway, thanks to your link =)
          – Sergey Shulik
          Nov 11 at 18:12




          @ScottChamberlain i am pretty sure, that all ilmerge tools do same, but i prefer to control all stemp, if it's not cost to much. But anyway, thanks to your link =)
          – Sergey Shulik
          Nov 11 at 18:12












          ILMerge actually modifies the original code of the dll to make it inside the exe. The problem with this is it breaks stuff like WPF's assembly names. The resource solution you and I show does not have the renaming problem. The comment I gave is just a way to automate it. Fun Fact: The author of ILMerge once said about using this embeding resources method "... I think this is fantastic! If I had known about this, I never would have written ILMerge."
          – Scott Chamberlain
          Nov 11 at 19:28






          ILMerge actually modifies the original code of the dll to make it inside the exe. The problem with this is it breaks stuff like WPF's assembly names. The resource solution you and I show does not have the renaming problem. The comment I gave is just a way to automate it. Fun Fact: The author of ILMerge once said about using this embeding resources method "... I think this is fantastic! If I had known about this, I never would have written ILMerge."
          – Scott Chamberlain
          Nov 11 at 19:28




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53251057%2fconfiguring-ilmerge-package%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Full-time equivalent

          Bicuculline

          さくらももこ