Closed ajaskiewiczpl closed 3 years ago
I did not see a use case for this. When would you have two assemblies having e.g. System.Web.Http
already embedded?
No feedback, closed as stale
I'd like to suggest reopening this issue.
Introduced with C# 7.2, readonly structs are causing System.Runtime.CompilerServices.IsReadOnlyAttribute
and Microsoft.CodeAnalysis.EmbeddedAttribute
types to be embedded in the resulting assembly. And they cause this issue if multiple assemblies are containing these.
Note: In my tests, netstandard2.1
and beyond are not affected by this issue.
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
public readonly struct Test
{
}
}
ILSpy of Assembly:
Thanks.
@otuncelli that should be already working.
Anything with the [Embedded]
attribute is replaced with the existing target type.
I'm using this heavily for assemblies with nullable reference types.
Can you provide a sample where this is not working?
I'm currently working with PdfPig Library. It contains these readonly structs in its different assemblies.
Edit: It seems to happen only when I use NamespacePrefix
The error message I get when I try debugging:
ILSpy of resulting assembly:
My Configuration:
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ILMerge NamespacePrefix="PdfFileTypePlugin">
<IncludeAssemblies>PDFiumSharp|UglyToad.PdfPig.Core|UglyToad.PdfPig|UglyToad.PdfPig.DocumentLayoutAnalysis|UglyToad.PdfPig.Fonts|UglyToad.PdfPig.Package|UglyToad.PdfPig.Tokenization|UglyToad.PdfPig.Tokens</IncludeAssemblies>
<FullImport>true</FullImport>
</ILMerge>
</Weavers>
@otuncelli can you try V 1.18?
Solved! Thank you very much.
It seems to happen only when I use NamespacePrefix
That was the key information
ILMerge supports the
/allowDup
command line argument to allow duplicated types. However when I try to use ILMerge.Fody, in runtime I get the errorSystem.BadImageFormatException Duplicate type with name 'System.Web.Http.Error' in assembly [...]
. Is there a reason why it's not supported?