-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
When using the repo local SDK ($(DotNetTool)) to invoke dotnet-Microsoft.XmlSerializer.Generator which dynamically (via reflection) loads the test assembly Microsoft.XmlSerializer.Generator.Tests.dll we create a dependency between the repo local shared framework and the test assembly.
This surfaces in the following error locally:
.NET Xml Serialization Generation Utility, Version 6.0.0]
Assembly 'C:\git\runtime2\artifacts\bin\Microsoft.XmlSerializer.Generator.Tests\net5.0-Debug\Microsoft.XmlSerializer.Generator.Tests.dll' does not contain any types that can be serialized using XmlSerializer.
C:\git\runtime2\src\libraries\Microsoft.XmlSerializer.Generator\tests\Microsoft.XmlSerializer.Generator.Tests.csproj(45,5): warning : Fail to generate C:\git\runtime2\artifacts\bin\Microsoft.XmlSerializer.Generator.Tests\net5.0-Debug\Microsoft.XmlSerializer.Generator.Tests.XmlSerializers.cs
C:\git\runtime2\src\libraries\Microsoft.XmlSerializer.Generator\tests\Microsoft.XmlSerializer.Generator.Tests.csproj(46,5): error MSB3030: Could not copy the file "C:\git\runtime2\artifacts\bin\Microsoft.XmlSerializer.Generator.Tests\net5.0-Debug\Microsoft.XmlSerializer.Generator.Tests.XmlSerializers.cs" because it was not found.
The exact cause is that the call to Type.GetTypes fails with an ReflectionTypeLoadException saying that references with assembly version X can't be resolved.
This likely has to do with us bumping the assembly version of our shared framework assemblies to 6.0.0 while the SDK still uses 5.0.0 shared framework assemblies.
There are couple of options:
- Don't feed an assembly to sgen that compiles against the very latest. Use ie a
netcoreapp3.1test helper assembly. - Don't invoke sgen during the test assembly's compilation at all.
- Downgrade the test assembly (which is the input to sgen) to
netcoreapp3.1. This is problematic as we would also need to downgradeTestUtilitiesand add support for testing non$(NetCoreAppCurrent)configurations (unreleated but we might want do this anyway at some point, similar to .NETFramework testing). - Upgrade to a 6.0 SDK. This would fix the issue temporarily but it would re-appear with 7.0.
This needs to be sorted out now as it already started to happen on my machine and because I thought it was related to one of my PRs I already lost multiple hours on that. Others will start noticing this soon as well.