-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
Description
Beginning with the Microsoft.XmlSerializer.Generator 7.* or greater (#2335; #73550), the generated *.XmlSerialization.all are added to the nuget package in the lib\*\ folder. Thereby, those become part of the compilation process down the line.
This will cause an CS0436 on another project also using Microsoft.XmlSerializer.Generator.
Reproduction Steps
If one creates two libraries both using the Microsoft.XmlSerializer.Generator and lib.B depends on lib.A via NuGet (package reference), than lib.B will have an CS0436.
Expected behavior
No warning. (Obviously 😉)
Add the generated *.XmlSerialization.dll not to the lib folder, but rather to the build folder including a .targets file which will ensure that the *.XmlSerialization.all is copied to the output directory (for example).
Actual behavior
Warning (active) CS0436 The type 'XmlSerializationReader1' in [...]\Lib.B\obj\Debug\net8.0\Lib.B.XmlSerializers.cs' conflicts with the imported type 'XmlSerializationReader1' in 'Lib.A, Version=[...] Culture=neutral, PublicKeyToken=null'.
Using the type defined in '[...]\Lib.B\obj\Debug\net8.0\Lib.B.XmlSerializers.cs'.
Regression?
Microsoft.XmlSerializer.Generator 6.0.0 work fine, because it did not add the generated *.XmlSerialization.dll to the nuget package.
Known Workarounds
Use the Microsoft.XmlSerializer.Generator 6.0.0.
Configuration
net6.0 / net8.0; VS 2022
Other information
No response