问题描述
[
<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在一个dll下打包了更多的dll,但是在其他程序中使用这个dll时,隐藏的dll仍然可见,从而导致版本冲突。
问题: 您好,我在使用 ILMerge 时遇到以下问题:
我[在此处输入图像描述][2]有两个程序。使用程序 1,ILMerge 成功运行,它实际上将所有 dll 打包在我的(一个)Service.dll 下。 AutoMapper.dll、NewtonsoftJson.dll 也打包在Service.dll 下。这就是我的发布文件夹在 ILMerge 执行后的样子(参见图片 >)。一切似乎都很好。我将程序 1 打包为 NuGet,并希望将其包含在程序 2 中。在 NuGet 管理器中,一切看起来也很好。 Service.dll 没有其他依赖项。我的意思是,它在 NuGet-Install 窗口中为我的 Nuget(带有 service.dll)显示“无依赖项”->(参见图片>)。 但是在“构建解决方案”之后,我收到一条错误消息,例如AutoMapper 存在于两者中(在程序 2 中,我想添加 Serice.dll 甚至 Service.dll)。 NewtosoftJson 也会导致“发现不同版本的 Newtonsoft.json 之间存在冲突”等问题。
问题: 为什么隐藏在 Service.dll 下的依赖项对程序 2 可见?我怎么解决这个问题?我想在程序 1 和程序 2 中使用相同的 dll,例如 Automapper.dll。
Befor/AfterILMerge.exe & Add Reference Service.dll as Nuget
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)