title: How can I temporarily inactivate MSBuild.ILMerge.Task?
body: <p>I am using the NuGet package <code>MSBuild.ILMerge.Task</code>in order to combine .NET external dlls to a single executable file. It works like a charm.</p>
  
  <p>Now, when I try to edit while Debugging, Visual Studio says:</p>
  
  <blockquote>
    <p>Changes are not allowed if the assembly has not been loaded</p>
  </blockquote>
  
  <p>I guess it's the downside of having all the dependencies into a single .exe (I don't know about that, it's just a guess).</p>
  
  <p>But anyway, it would make sense to have <code>MSBuild.ILMerge.Task</code> on Build, but inactive on Debug. Does anybody know how to achieve this?</p>
  
  <p>Notice that when <code>MSBuild.ILMerge.Task</code> is installed through NuGet, when you hit "rebuild" it automatically creates the single .exe (letting the .config file outside, of course, plus a .pdb). You don't need to configure anything, and this why I am not able to guess the inner workings of the process and how to inactivate it.</p>
  
  <hr>
  
  <p>For more information, I am writing a blog post about ILMerge. I am trying to document all how-to's, problems and caveats:</p>
  
  <p><a href="http://localcode.wikidot.com/merge-all-binary-files-dll-s-etc-into-a-single-exe" rel="noreferrer">http://localcode.wikidot.com/merge-all-binary-files-dll-s-etc-into-a-single-exe</a></p>
  
  <hr>
  
  <p><strong>Edit1:</strong> I've noticed that the NuGet package automatically sets a <code>.props</code> file with the following info:</p>
  
  <pre><code>&lt;Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
  </code></pre>
  
  <p>I've started looking for <code>DefaultTargets="Build"</code> and a way to disable on debug, and I've found <a href="https://stackoverflow.com/a/28814062/831138">this post</a> that seems to explain how.</p>
  
  <hr>
  
  <p><strong>Edit2:</strong></p>
  
  <p>If remove this lines from my .csproj, then it skips the ILMerge compilation correctly:</p>
  
  <pre><code>&lt;Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"&gt;
  &lt;PropertyGroup&gt;
    &lt;ErrorText&gt;This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.&lt;/ErrorText&gt;
  &lt;/PropertyGroup&gt;
  &lt;Error Condition="!Exists('..\packages\MSBuild.ILMerge.Task.1.0.5\build\MSBuild.ILMerge.Task.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSBuild.ILMerge.Task.1.0.5\build\MSBuild.ILMerge.Task.props'))" /&gt;
  &lt;Error Condition="!Exists('..\packages\MSBuild.ILMerge.Task.1.0.5\build\MSBuild.ILMerge.Task.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSBuild.ILMerge.Task.1.0.5\build\MSBuild.ILMerge.Task.targets'))" /&gt;
  &lt;/Target&gt;
  &lt;Import Project="..\packages\MSBuild.ILMerge.Task.1.0.5\build\MSBuild.ILMerge.Task.targets" Condition="Exists('..\packages\MSBuild.ILMerge.Task.1.0.5\build\MSBuild.ILMerge.Task.targets')" /&gt;  
  </code></pre>
  
  <p>It's something, but it looks a bit handcrafted and impractical for the moment...</p>