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

Update SDK #48908

Merged
merged 8 commits into from
Jun 24, 2023
Merged

Update SDK #48908

merged 8 commits into from
Jun 24, 2023

Conversation

RussKie
Copy link
Member

@RussKie RussKie commented Jun 20, 2023

No description provided.

@RussKie RussKie requested review from a team and wtgodbe as code owners June 20, 2023 02:22
@ghost ghost added the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Jun 20, 2023
@RussKie
Copy link
Member Author

RussKie commented Jun 20, 2023

/home/vsts/work/1/s/src/Middleware/Spa/SpaProxy/src/SpaHostingStartup.cs(37,13): error IL2091: 'TOptions' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in 'Microsoft.Extensions.DependencyInjection.OptionsConfigurationServiceCollectionExtensions.Configure<TOptions>(IServiceCollection, IConfiguration)'. The generic parameter 'T' of 'ConfigureOptions<T>(IServiceCollection, IConfigurationSection)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [/home/vsts/work/1/s/src/Middleware/Spa/SpaProxy/src/Microsoft.AspNetCore.SpaProxy.csproj]
##[error]src/Middleware/Spa/SpaProxy/src/SpaHostingStartup.cs(37,13): error IL2091: (NETCORE_ENGINEERING_TELEMETRY=Build) 'TOptions' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in 'Microsoft.Extensions.DependencyInjection.OptionsConfigurationServiceCollectionExtensions.Configure<TOptions>(IServiceCollection, IConfiguration)'. The generic parameter 'T' of 'ConfigureOptions<T>(IServiceCollection, IConfigurationSection)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.

@sbomer can you help with this?

@halter73
Copy link
Member

.dotnet/sdk/8.0.100-preview.6.23319.37/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(267,5):
error NETSDK1206: (NETCORE_ENGINEERING_TELEMETRY=Build)
Found version-specific or distribution-specific runtime identifier(s): alpine-arm, alpine-arm64, alpine-x64, browser-wasm, maccatalyst-arm64, maccatalyst-x64.
Affected libraries: SQLitePCLRaw.lib.e_sqlite3.
In .NET 8.0 and higher, assets for version-specific and distribution-specific runtime identifiers will not be found by default. See https://aka.ms/dotnet/rid-usage for details.

I filed an issue on SQLitePCLRaw at ericsink/SQLitePCL.raw#543, but in the meantime, I think we're going to need to set the System.Runtime.Loader.UseRidGraph compatibility switch to true to take this SDK update in a reasonable amount of time. @elinor-fung

@@ -31,7 +31,7 @@ public void Configure(IWebHostBuilder builder)
});

[UnconditionalSuppressMessageAttribute("Trimming", "IL2026", Justification = "Configuration object's public properties are preserved.")]
static void ConfigureOptions<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>(IServiceCollection services, IConfigurationSection section)
static void ConfigureOptions<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T>(IServiceCollection services, IConfigurationSection section)
Copy link
Member

Choose a reason for hiding this comment

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

The upstream annotation (in Configure<TOptions>) now specifies DynamicallyAccessedMemberTypes.All, so we have to broaden the annotation here to match.

Copy link
Member

@halter73 halter73 Jun 22, 2023

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Good question

Copy link
Member

Choose a reason for hiding this comment

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

@sbomer @agocke @vitek-karas - any thoughts on what could have fixed this between 8.0.100-preview.6.23305.3 and 8.0.100-preview.7.23321.23? We must have had a bug here in the analyzer?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe the configuration binder source generator? I seem to see something like the Configure call below to be handled by the source generated at least in some cases. So it's possible that it's effectively started to call a different overload than before? Just guessing.

Copy link
Member

Choose a reason for hiding this comment

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

/home/vsts/work/1/s/src/Middleware/Spa/SpaProxy/src/SpaHostingStartup.cs(37,13): error IL2091: 'TOptions' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in 'Microsoft.Extensions.DependencyInjection.OptionsConfigurationServiceCollectionExtensions.Configure<TOptions>(IServiceCollection, IConfiguration)'. The generic parameter 'T' of 'ConfigureOptions<T>(IServiceCollection, IConfigurationSection)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [/home/vsts/work/1/s/src/Middleware/Spa/SpaProxy/src/Microsoft.AspNetCore.SpaProxy.csproj]
##[error]src/Middleware/Spa/SpaProxy/src/SpaHostingStartup.cs(37,13): error IL2091: (NETCORE_ENGINEERING_TELEMETRY=Build) 'TOptions' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in 'Microsoft.Extensions.DependencyInjection.OptionsConfigurationServiceCollectionExtensions.Configure<TOptions>(IServiceCollection, IConfiguration)'. The generic parameter 'T' of 'ConfigureOptions<T>(IServiceCollection, IConfigurationSection)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.

The IL2091 error specifically references the call to Microsoft.Extensions.DependencyInjection.OptionsConfigurationServiceCollectionExtensions.Configure<TOptions>(IServiceCollection, IConfiguration), so I don't think the call is getting intercepted by the source generator.

@SteveSandersonMS SteveSandersonMS enabled auto-merge (squash) June 22, 2023 09:37
@SteveSandersonMS
Copy link
Member

I filed an issue on SQLitePCLRaw at ericsink/SQLitePCL.raw#543, but in the meantime, I think we're going to need to set the System.Runtime.Loader.UseRidGraph compatibility switch to true to take this SDK update in a reasonable amount of time.

@halter73 Thanks for tracking that down. I've added 47f5966 as suggested.

@SteveSandersonMS
Copy link
Member

Unfortunately this is still stuck on the new RID resolution warning because it also shows up in our template tests, and we don't have such an easy way to override the build config for those. I did try one possible workaround but it didn't work. Some other approach will be needed for setting System.Runtime.Loader.UseRidGraph on the projects generated during template tests.

<!-- Temporarily ignore RID-related warnings. -->
<ItemGroup>
<RuntimeHostConfigurationOption Include="System.Runtime.Loader.UseRidGraph" Value="true" />
</ItemGroup>
Copy link
Member

Choose a reason for hiding this comment

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

This will actually show up in people's real apps when they create them, won't it? Is that OK?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it will. I gave this a try largely to see if this is the only remaining issue with this SDK update or if we might have to onion peel on another item.

As to whether or not it is OK, it appears that the right thing to do is resolve the underlying issue is resolve ericsink/SQLitePCL.raw#543.

Given that we've branched for preview7 already, I was assuming that it was OK to take this in as we have some runaway to land a fix in preview7.

@bricelam Thoughts on feasibility of getting a fix for the underlying issue?

Copy link
Member

Choose a reason for hiding this comment

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

It looks like we'll also need to fix templates in the spa-templates repo. :/

I'm fine to pursue this assuming we think we can land a permanent fix for preview7 or there isn't a way to address this that is more hidden from the user.

@SteveSandersonMS SteveSandersonMS merged commit 85f7685 into main Jun 24, 2023
@SteveSandersonMS SteveSandersonMS deleted the update_sdk branch June 24, 2023 01:54
@ghost ghost added this to the 8.0-preview7 milestone Jun 24, 2023
<!-- Ignore warning about RID resolution rules changing in .NET 8 Preview 6 -->
<!-- Needed until https://github.com/ericsink/SQLitePCL.raw/issues/543 is fixed -->
<!-- See https://github.com/dotnet/aspnetcore/pull/48908#issuecomment-1601894643 -->
<ItemGroup>
Copy link
Member

Choose a reason for hiding this comment

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

How does this work for templates?

Copy link
Member

Choose a reason for hiding this comment

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

I thought it might work for the templates because of these lines:

<GenerateFileFromTemplate
TemplateFile="$(MSBuildThisFileDirectory)..\TestInfrastructure\Directory.Build.props.in"
Properties="RepoRoot=$(RepoRoot);ArtifactsBinDir=$(ArtifactsBinDir)"
OutputPath="$(TestTemplateCreationFolder)Directory.Build.props" />

<Import Project="${ArtifactsBinDir}GenerateFiles\Directory.Build.props" />

But I was just trying thing, and I'm a bit surprised it worked too. @wtgodbe Is there a better way to do this? I saw that @mitchdenny updated this a couple months ago as part of #48014. Do we still need to hardcode SuppressGenerateILCompilerExplicitPackageReferenceWarning?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, this is the right way to do it, at least for in-repo stuff. Template tests will get the workaround, but template projects may run into issues in real world scenarios (since the workaround won't be injected into them). I don't know enough about this specific issue to know if it's something that would actually manifest.

@eerhardt do we still need the SuppressGenerateILCompilerExplicitPackageReferenceWarning workaround?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, this is the right way to do it, at least for in-repo stuff. Template tests will get the workaround, but template projects may run into issues in real world scenarios (since the workaround won't be injected into them). I don't know enough about this specific issue to know if it's something that would actually manifest.

Ah, that makes sense. Hopefully, this is resolved for preview7 and we don't have to issue a known issues warning. 🤞🏽

Copy link
Member

Choose a reason for hiding this comment

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

@eerhardt do we still need the SuppressGenerateILCompilerExplicitPackageReferenceWarning workaround?

I believe so. I don't know of any changes here that would cause us to no longer need the workaround. We are running our tests against a specific version of the runtime, and not the runtime that comes with the SDK. See dotnet/runtime#84372.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, that makes sense. Hopefully, this is resolved for preview7 and we don't have to issue a known issues warning. 🤞🏽

I doubt this will be fixed by preview7. Even if ericsink/SQLitePCL.raw#543 is resolved by then and uploaded to nuget, EF still needs to update its dependencies. Anyone using Microsoft.Data.Sqlite will likely see warnings until rc1 at the earliest unless they manually upgrade, so we should probably get ahead of the issues. @dotnet/efteam

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it would be reasonable to add a mechanism to tell the SDK that it should not warn on some particular package or particular versions of packages - for example, the consumer has checked that they are not affected by the non-portable RID in that package, as would be the case here. @dsplaisted @vitek-karas @agocke - thoughts?

It would go kind of counter to making a hard push for packages to fix their RID usage, but it would provide an option between suppressing the warning entirely and switching to the old behaviour - neither of which we really want people to do.

Copy link
Member

Choose a reason for hiding this comment

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

Is there a way to suppress the warning by its warning code - I don't know if NoWarn works on SDK warnings. If that works, then I'd probably not add any new support and ask the affected people to suppress the warning code instead.

Basically we want packages to fix this problem, and there are not that many packages which are affected by this and consequently not that many teams/customers will see the warning either. I'd like to avoid adding production code into the SDK unless there's a strong reason for it - and this doesn't feel that strong - assuming the warning can be suppressed already.

Copy link
Member

Choose a reason for hiding this comment

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

<NoWarn>NETSDK1206</NoWarn> works.

Copy link
Member

Choose a reason for hiding this comment

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

Basically we want packages to fix this problem, and there are not that many packages which are affected by this and consequently not that many teams/customers will see the warning either.

That's fair. The main concern is that the affected package is brought in as a dependency under certain template configurations to there is a chance that users might run into the issue with this particular package at a higher rate than other packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants