Open TiltonJH opened 2 months ago
Example *.targets file for the nuget build
dir as mentioned above:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)*.XmlSerializers.dll"
Link="%(Filename)%(Extension)"
Visible="false">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Description
Beginning with the
Microsoft.XmlSerializer.Generator 7.*
or greater (#2335; #73550), the generated*.XmlSerialization.all
are added to the nuget package in thelib\*\
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
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