Skip to content

Build implementation projects against ref assemblies #2737

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

Merged
merged 2 commits into from
Dec 4, 2019
Merged

Conversation

wtgodbe
Copy link
Member

@wtgodbe wtgodbe commented Dec 2, 2019

The previous PR for this (#2483) had a typo, replacing IsImplementationProject with IsImplementationAssemblyProject. This meant that Implementation projects were not being built against refs, which causing some assembly load errors upstream in AspNetCore. Local build confirms that implementation projects now reference 3.0.0.0 versions of their Extensions references.

@JunTaoLuo @dougbu PTAL

@wtgodbe wtgodbe added this to the 3.0.2 milestone Dec 2, 2019
@wtgodbe wtgodbe requested a review from a team as a code owner December 2, 2019 20:44
Copy link

@dougbu dougbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix your bugs of course 😈

@wtgodbe
Copy link
Member Author

wtgodbe commented Dec 2, 2019

About half of our tests are failing with:

System.BadImageFormatException : Could not load file or assembly 'Microsoft.Extensions.Options.ConfigurationExtensions, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (0x80131058)\n---- System.BadImageFormatException : Could not load file or assembly 'Microsoft.Extensions.Options.ConfigurationExtensions, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (0x80131058)\n-------- System.BadImageFormatException : Cannot load a reference assembly for execution.

@wtgodbe
Copy link
Member Author

wtgodbe commented Dec 3, 2019

9264306 adds some explicit references to test projects, where the tests had a transitive reference that they were attempting to resolve as a reference assembly. Referencing those things explicitly gets the tests to (correctly) resolve them as implementation assemblies. We need to fix this going forward to use the same scheme as in dotnet/aspnetcore#17311, so that we don't get hit by this when adding new test projects in the future. CC @JunTaoLuo @dougbu

@wtgodbe
Copy link
Member Author

wtgodbe commented Dec 3, 2019

Ubuntu test failures:

ShutdownTestRun

System.NullReferenceException : Object reference not set to an instance of an object.

at Microsoft.Extensions.Logging.Testing.LoggedTest.Initialize(MethodInfo methodInfo, Object[] testMethodArguments, ITestOutputHelper testOutputHelper) in //src/Logging/Logging.Testing/src/LoggedTest/LoggedTest.cs:line 21
at Microsoft.Extensions.Logging.Testing.LoggedTestInvoker.CreateTestClass() in /
/src/Logging/Logging.Testing/src/Xunit/LoggedTestInvoker.cs:line 46

Copy link

@dougbu dougbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still looks good

@dougbu
Copy link

dougbu commented Dec 3, 2019

ShutdownTestRun

Wouldn't be surprised if this test is known to be flaky. I'll click the retry button. Please double-check the issues here and in the internal repo to see if the test needs to be marked [Flaky]

@Tratcher
Copy link
Member

Tratcher commented Dec 3, 2019

System.NullReferenceException : Object reference not set to an instance of an object.

at Microsoft.Extensions.Logging.Testing.LoggedTest.Initialize(MethodInfo methodInfo, Object[] testMethodArguments, ITestOutputHelper testOutputHelper) in //src/Logging/Logging.Testing/src/LoggedTest/LoggedTest.cs:line 21
at Microsoft.Extensions.Logging.Testing.LoggedTestInvoker.CreateTestClass() in /
/src/Logging/Logging.Testing/src/Xunit/LoggedTestInvoker.cs:line 46

That stack doesn't look like a test issue, but a test infrastructure issue in LoggedTest.Initialize, unless it's loosing some inner stack?

@Tratcher
Copy link
Member

Tratcher commented Dec 3, 2019

There's an issue for this test, but with a different error.
https://github.com/aspnet/AspNetCore-Internal/issues/3311

@dougbu
Copy link

dougbu commented Dec 3, 2019

Thanks @Tratcher

Looking again, I agree this is likely an infrastructure issue. The problem is consistent and unclear, as you pointed out. @rynowak is anything about these messages familiar❔

@wtgodbe
Copy link
Member Author

wtgodbe commented Dec 3, 2019

@rynowak helped me out with this one - the following LoggerFactory was null:

https://github.com/aspnet/Extensions/blob/97c3f96fb173c219caa3fd280ede13e039bb908c/src/Logging/Logging.Testing/src/LoggedTest/LoggedTest.cs#L21

Which was hidden by:

https://github.com/aspnet/Extensions/blob/97c3f96fb173c219caa3fd280ede13e039bb908c/src/Logging/Logging.Testing/src/LoggedTest/LoggedTestBase.cs#L86-L89

By marking the LoggerFactory as nullable, it exposed the underlying error, which was more missing references. I'll throw up a PR to mark that guy nullable in master.

@wtgodbe
Copy link
Member Author

wtgodbe commented Dec 3, 2019

dotnet-install is failing on all Unix platforms everywhere right now 😢. I enabled the tests on Windows temporarily to get coverage - need to revert 991ab66 before I merge this

@wtgodbe
Copy link
Member Author

wtgodbe commented Dec 3, 2019

Locally I get:

| [4.393s] Microsoft.Extensions.Hosting.IntegrationTesting.SelfHostDeployer Warning: dotnet stderr: Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=3.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified

Referring to

https://github.com/aspnet/Extensions/blob/e17034fa265d404d48d76a3314aa856a9ab60a7c/src/Hosting/test/testassets/Microsoft.Extensions.Hosting.TestApp/Microsoft.Extensions.Hosting.TestApp.csproj#L9

Which I added in this PR. Not sure yet why it's failing to find this implementation assembly.

@wtgodbe
Copy link
Member Author

wtgodbe commented Dec 4, 2019

This is good to go now. I'm going to rebase and remove the workaround from 5c45866, which will cause CI to fail until dotnet-install.sh gets fixed, after which we should retry CI. The green CI that validates the Ubuntu failures are gone, is here: https://dev.azure.com/dnceng/public/_build/results?buildId=445741

@wtgodbe
Copy link
Member Author

wtgodbe commented Dec 4, 2019

We should fix Extensions to use the scheme from dotnet/aspnetcore#17311, at which point we can revert 40d846b

@wtgodbe wtgodbe requested a review from Tratcher December 4, 2019 00:27
@wtgodbe wtgodbe merged commit 6a34280 into release/3.0 Dec 4, 2019
@wtgodbe wtgodbe deleted the logtestref branch December 4, 2019 22:49
@ghost ghost locked as resolved and limited conversation to collaborators May 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants