Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building libs.tests fails in XmlSerializer.Generator.Tests #39227

Closed
carlossanlop opened this issue Jul 13, 2020 · 9 comments · Fixed by #40216
Closed

Building libs.tests fails in XmlSerializer.Generator.Tests #39227

carlossanlop opened this issue Jul 13, 2020 · 9 comments · Fixed by #40216
Labels
area-Serialization test-bug Problem in test source code (most likely)
Milestone

Comments

@carlossanlop
Copy link
Member

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.

Let me know if you need more info.

@ghost
Copy link

ghost commented Jul 13, 2020

Tagging subscribers to this area: @safern, @ViktorHofer
Notify danmosemsft if you want to be subscribed.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Jul 13, 2020
@safern safern added this to the 5.0.0 milestone Jul 13, 2020
@safern safern removed the untriaged New issue has not been triaged by the area owner label Jul 13, 2020
@safern
Copy link
Member

safern commented 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
Copy link
Member

ericstj commented Jul 14, 2020

Odd. I'd expect serializable types to come from here

<Compile Include="$(TestSourceFolder)..\..\System.Runtime.Serialization.Xml\tests\SerializationTypes.cs" />

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
Copy link
Member

ericstj commented 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
Copy link
Member

Agreed with using runtime detection over compile time exclusion. Probably via an XUnitExtensions attribute? cc @safern

@carlossanlop
Copy link
Member Author

was this in your regular machine or the Surface Pro X?

@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
Copy link
Member

safern commented Jul 15, 2020

Then I think that confirms @ericstj statement.

@carlossanlop
Copy link
Member Author

@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

@ericstj
Copy link
Member

ericstj commented 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.

  1. Carlos had the verison of dotnet required by the repo installed machine-wide, so build didn't acquire a local copy.
  2. Carlos had a 2.x shared framework installed machine-wide.
  3. The tool preferred the 2.0.0 machine-wide framework, which couldn't analyze the net5.0 test assembly.

Ultimately the bug here is that this tool is doing runtime-reflection on build assets:

assembly = Assembly.LoadFile(path);

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

to

  "rollForward": "LatestMajor"

cc @HongGit @StephenBonikowsky @StephenMolloy

@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Serialization test-bug Problem in test source code (most likely)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants