I am using the NuGet package MSBuild.ILMerge.Task
in order to combine .NET external dlls to a single executable file. It works like a charm.
Now, when I try to edit while Debugging, Visual Studio says:
Changes are not allowed if the assembly has not been loaded
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).
But anyway, it would make sense to have MSBuild.ILMerge.Task
on Build, but inactive on Debug. Does anybody know how to achieve this?
Notice that when MSBuild.ILMerge.Task
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.
For more information, I am writing a blog post about ILMerge. I am trying to document all how-to's, problems and caveats:
http://localcode.wikidot.com/merge-all-binary-files-dll-s-etc-into-a-single-exe
Edit1: I've noticed that the NuGet package automatically sets a .props
file with the following info:
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
I've started looking for DefaultTargets="Build"
and a way to disable on debug, and I've found this post that seems to explain how.
Edit2:
If remove this lines from my .csproj, then it skips the ILMerge compilation correctly:
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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}.</ErrorText>
</PropertyGroup>
<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'))" />
<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'))" />
</Target>
<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')" />
It's something, but it looks a bit handcrafted and impractical for the moment...