Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ultimately the easiest thing to do is to exclude log4net completely from the ilmerge process and maintain it as a dependent assembly.</p> <p>So after much torture here's the "not-so-obvious" solution..</p> <p>The excludes were not required after all, the real answer is to use the <code>/lib:[path]</code> switch in ilmerge. </p> <p>I updated the <code>AfterBuild</code> target to remove the excludes from the <code>/internalize</code> switch. Next I added the <code>/lib</code> switch to pass in the location of the log4net dll as a dependent reference. It looks like this:</p> <pre><code>&lt;Target Name="AfterBuild"&gt; &lt;CreateItem Include="@(ReferenceCopyLocalPaths)" Condition="'%(Extension)'=='.dll'"&gt; &lt;Output ItemName="AssembliesToMerge" TaskParameter="Include" /&gt; &lt;/CreateItem&gt; &lt;Message Text="MERGING: @(AssembliesToMerge-&gt;'%(Filename)')" Importance="High" /&gt; &lt;Exec Command="&amp;quot;$(ProgramFiles)\Microsoft\Ilmerge\Ilmerge.exe&amp;quot; /lib:..\packages\log4net.2.0.0\lib\net35-full\ /targetplatform:v2 /log /internalize /keyfile:$(AssemblyOriginatorKeyFile) /out:@(MainAssembly) &amp;quot;@(IntermediateAssembly)&amp;quot; @(AssembliesToMerge-&gt;'&amp;quot;%(FullPath)&amp;quot;', ' ')" /&gt; &lt;Delete Files="@(ReferenceCopyLocalPaths-&gt;'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" /&gt; &lt;/Target&gt; </code></pre> <p>In addition, I've added another target to restrict the list of assemblies included in the merge by adding a unique <code>&lt;ILMerge /&gt;</code> element to the references located in my .csproj file</p> <pre><code>&lt;Target Name="AfterResolveReferences"&gt; &lt;Message Text="Filtering out ILMerge assemblies from ReferenceCopyLocalPaths..." Importance="High" /&gt; &lt;ItemGroup&gt; &lt;ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.ILMerge)'=='false'" /&gt; &lt;/ItemGroup&gt; &lt;/Target&gt; </code></pre> <p>Thus the reference elements were listed like so to accommodate:</p> <pre><code>... &lt;Reference Include="Ionic.Zip"&gt; &lt;HintPath&gt;..\packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll&lt;/HintPath&gt; &lt;ILMerge&gt;True&lt;/ILMerge&gt; &lt;/Reference&gt; &lt;Reference Include="log4net"&gt; &lt;HintPath&gt;..\packages\log4net.2.0.0\lib\net35-full\log4net.dll&lt;/HintPath&gt; &lt;ILMerge&gt;False&lt;/ILMerge&gt; ... </code></pre> <p>There's probably a better (programmatic) alternative for explicitly adding ILMerge=False values to the <code>/lib</code> switch but, in my case it is sufficient due to there being only one excluded item. Otherwise you may need to add additional paths manually.</p> <p>Credit for the 'AfterResolveReferences' technique I've listed goes to <a href="http://www.hanselman.com/blog/MixingLanguagesInASingleAssemblyInVisualStudioSeamlesslyWithILMergeAndMSBuild.aspx" rel="noreferrer">http://www.hanselman.com/blog/MixingLanguagesInASingleAssemblyInVisualStudioSeamlesslyWithILMergeAndMSBuild.aspx</a></p> <p>Hopefully this helps someone! </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload