You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Building libs.tests fails in XmlSerializer.Generator.Tests #39227
I have a clean enlistment synced to the latest runtime commit in master.
I ran .\build.cmd clr+libs -rc release without problem.
When I build .\build.cmd libs.tests -rc release, I get this error:
Assembly 'D:\runtime\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.
D:\runtime\src\libraries\Microsoft.XmlSerializer.Generator\tests\Microsoft.XmlSerializer.Generator.Tests.csproj(47,5): error : Fail to generate D:\runtime\artifacts\bin\Microsoft.XmlSerializer.Generator.Tests\net5.0-Debug\Microsoft.XmlSerializer.Generator.Tests.XmlSerializers.cs
D:\runtime\src\libraries\Microsoft.XmlSerializer.Generator\tests\Microsoft.XmlSerializer.Generator.Tests.csproj(48,5): error MSB3030: Could not copy the file "D:\runtime\artifacts\bin\Microsoft.XmlSerializer.Generator.Tests\net5.0-Debug\Microsoft.XmlSerializer.Generator.Tests.XmlSerializers.cs" because it was not found.
One thing that comes to mind would be that this could happen if you were messing with TargetArchitecture. For instance if you set it to arm64 and built the project (meant to skip) then set it to something else like amd64. It's possible compiler wouldn't rebuild due to incremental, but would try to run the generator.
Frankly think we shouldn't be conditioning the test this way as it could cause these incremental build issues since the project doesn't represent these as configurations. Instead we should have the condition as attribute on the test.
@safern@ericstj I built my x64 PC and I also saw the failure there:
Build FAILED.
D:\runtime\src\libraries\Microsoft.XmlSerializer.Generator\tests\Microsoft.XmlSerializer.Generator.Tests.csproj(47,5): error : Fail to generate D:\runtime\artifacts\bin\Microsoft.XmlSerializer.Generator.Tests\net5.0-Release\Microsoft.XmlSerializer.Generator.Tests.XmlSerializers.cs
D:\runtime\src\libraries\Microsoft.XmlSerializer.Generator\tests\Microsoft.XmlSerializer.Generator.Tests.csproj(48,5): error MSB3030: Could not copy the file "D:\runtime\artifacts\bin\Microsoft.XmlSerializer.Generator.Tests\net5.0-Release\Microsoft.XmlSerializer.Generator.Tests.XmlSerializers.cs" because it was not found.
0 Warning(s)
2 Error(s)
Time Elapsed 00:10:11.61
Build failed.
Some builds failed:
Configuration: release, Architecture: x64
This is the command I used: .\build.cmd clr+libs+libs.tests -c release -arch x64
This is an age-old problem where a build tool conflates build-framework with target-framework. Instead of doing runtime-reflection, this tool should be changed to read metadata. That should be much easier now with MetadataLoadContext. I suspect that's the root cause of #1390.
The reason this regressed was because we stopped using the test-framework to execute the tool. The reason it's only happening for Carlos is the set of things I called out above. Perhaps a workaround would be to change
Activity
safern commentedon Jul 13, 2020
cc: @ViktorHofer @ericstj -- maybe a fallout from: 8790ade
What is weird is that CI is not failing and CI is doing
build.cmd libs.tests. @carlossanlop was this in your regular machine or the Surface Pro X?ericstj commentedon Jul 14, 2020
Odd. I'd expect serializable types to come from here
runtime/src/libraries/Microsoft.XmlSerializer.Generator/tests/Microsoft.XmlSerializer.Generator.Tests.csproj
Line 18 in 8892364
One thing that comes to mind would be that this could happen if you were messing with TargetArchitecture. For instance if you set it to arm64 and built the project (meant to skip) then set it to something else like amd64. It's possible compiler wouldn't rebuild due to incremental, but would try to run the generator.
ericstj commentedon Jul 14, 2020
Frankly think we shouldn't be conditioning the test this way as it could cause these incremental build issues since the project doesn't represent these as configurations. Instead we should have the condition as attribute on the test.
ViktorHofer commentedon Jul 14, 2020
Agreed with using runtime detection over compile time exclusion. Probably via an XUnitExtensions attribute? cc @safern
carlossanlop commentedon Jul 15, 2020
@safern so far I've seen it in my ARM64 surface, but if I see it in my x64 PC I'll let you know.
safern commentedon Jul 15, 2020
Then I think that confirms @ericstj statement.
carlossanlop commentedon Jul 15, 2020
@safern @ericstj I built my x64 PC and I also saw the failure there:
This is the command I used:
.\build.cmd clr+libs+libs.tests -c release -arch x64ericstj commentedon Jul 15, 2020
I looked at Carlos's machine. The assembly had the types present. The problem is that the tool was running on an old shared framework.
Ultimately the bug here is that this tool is doing runtime-reflection on build assets:
runtime/src/libraries/Microsoft.XmlSerializer.Generator/src/Sgen.cs
Line 444 in 69b0d16
This is an age-old problem where a build tool conflates build-framework with target-framework. Instead of doing runtime-reflection, this tool should be changed to read metadata. That should be much easier now with MetadataLoadContext. I suspect that's the root cause of #1390.
The reason this regressed was because we stopped using the test-framework to execute the tool. The reason it's only happening for Carlos is the set of things I called out above. Perhaps a workaround would be to change
runtime/src/libraries/Microsoft.XmlSerializer.Generator/pkg/build/dotnet-Microsoft.XmlSerializer.Generator.runtimeconfig.json
Line 8 in 69b0d16
cc @HongGit @StephenBonikowsky @StephenMolloy