[
<Target Name="AfterBuild" Condition="'$(Configuration)' == 'Release' ">
<CreateItem Include="@(ReferencePath)" Condition="'%(CopyLocal)'=='true'">
<Output ItemName="IlmergeAssemblies" TaskParameter="Include" />
</CreateItem>
<PropertyGroup>
<ReferenceAssemblies>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2</ReferenceAssemblies>
<ILMergePath>..\packages\ILMerge.3.0.41\tools\net452</ILMergePath>
<NugetPackagesPath>..\packages</NugetPackagesPath>
</PropertyGroup>
<ItemGroup>
<dependency Include="$(nugetPackagesPath)\Newtonsoft.Json.12.0.3\lib\net45" />
<dependency Include="$(nugetPackagesPath)\AutoMapper.10.1.1\lib\net461" />
<dependency Include="$(nugetPackagesPath)\RestSharp.106.11.7\lib\net452" />
</ItemGroup>
<PropertyGroup>
<ReferenceAssemblies>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2</ReferenceAssemblies>
</PropertyGroup>
<Exec Command=""$(ILMergePath)\ILMerge.exe" @(dependency->'/lib:"%(FullPath)"', ' ') /out:@(MainAssembly) /targetplatform:v4,"$(ReferenceAssemblies)" "@(IntermediateAssembly)" @(IlmergeAssemblies->'"%(FullPath)"', ' ')" />
<Delete Files="@(ReferencePath->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />
</Target>`]
1`Thema: ILMerge packages more dlls under one, but when using this one dll in other programs the hidden dlls are still visible, which leads to version conflicts.
Problem: Hello I have the following problem with ILMerge:
I[enter image description here][2] have two programs. With program 1, ILMerge runs successfully and it actually packages all dlls under my (one) Service.dll. AutoMapper.dll, NewtonsoftJson.dll are also packaged under Service.dll. This is how my release folder looks after the ILMerge execution(see on the picture << Before ILmerge.exe & After ILMerge.exe >>). Everything seems fine. I package program 1 as NuGet and would like to include this in program 2. Everything looks fine in NuGet Manager, too. There are no other dependencies to be seen with Service.dll.I mean, it shows "no dependencies" in the NuGet-Install window for my Nuget(with service.dll)->(see the picture << Add Reference Service.dll >>) . But after the "Build Solution" I get an error message that e.g. AutoMapper exists in both (in program 2 where I want to add men Serice.dll and even with Service.dll). NewtosoftJson also causes problems like "found conflicts between different versions of Newtonsoft.json".
Question: Why are the dependencies hidden under Service.dll visible for program 2? How can I solve this problem? I want to use the same dlls such as Automapper.dll in both program 1 and program 2.