Correcting conflicting types in C # .NET caused by ILMerge

I have an interesting problem that I would like to easily fix. I have a library assembly referenced by both a client project and a test project in a Visual Studio solution. The problem is that the test project also references the client project, and we must use ILMerge to combine the library assembly with the client assembly for deployment. Since the library assembly is integrated with the client assembly, I receive an error message about the types in my library assembly that exist both in the source link assembly and in the combined assembly when the project tries to try to build.

The real problem is that ILMerge works after the build on a client project; the best solution would be to translate this into the actual deployment process. However, our current toolkit will make it difficult to implement.

Is there a way to tell .NET that a type can be in several assemblies and that OK (given that they are actually the same assembly, but just merged with another assembly in one case)?

+3
source share
3 answers

, , , , , ... , . , , , , .

+5

, , , ILMerge.

, "" ( ) .

, CSPROJ , "CopyFilesToOutputDirectory", , "" , post build ( , ).

, DLL, :

<Reference Include="MyMergedLib, Version=1.2.3.4, Culture=neutral, PublicKeyToken=3d58c5c8efc41aa9, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\MyMergedLib\$(OutputPath)MyMergedLib.dll</HintPath>
</Reference>

, VS (debug/release). , .

+2

Well, you can use the customized version of ILLink (instead of ILMerge) to fix this problem.

Or you can simply configure it to remove the duplicate assembly.

See Source Code here . Please note that ILLink is a C ++ program.

0
source

Source: https://habr.com/ru/post/1777494/


All Articles