-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Add workaround for deprecated overload in authentication scenarios #24600
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
Conversation
@JunTaoLuo Thanks for explaining how the versioning works for these packages. I've fixed it up. These changes should do the trick but let me know if there is something else. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now but @JunTaoLuo should confirm
Hello human! Please make sure you've included the Shiproom Template in a comment or (preferably) the PR description. Also, make sure this PR is not marked as a draft and is ready-to-merge. |
@JunTaoLuo @dougbu It looks like the template tests are failing because the publish step detects us using the local artifacts as an error during publish. What's the best way to address this? |
This issue is related to sorting and it won't impact public or rolling builds because they use real versions.
➕ @javiercn for his input |
6dd6134
to
62e7a0d
Compare
src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj
Outdated
Show resolved
Hide resolved
ab0d740
to
2417788
Compare
52ab407
to
65d965e
Compare
@@ -16,6 +16,11 @@ | |||
|
|||
<!--#endif --> | |||
<!--#if (IndividualAuth || OrganizationalAuth) --> | |||
<ItemGroup Condition="'$(VersionSuffix)' != 'ci' AND '$(VersionSuffix)' != 'dev'"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if it were fine to make the default for local and PR builds be whatever Microsoft.Identity.Web brings in, doesn't this condition appear in the user's project file now❔ Might need another <!--#if ... -->
block.
But I doubt it's fine because it means local and PR builds will see the [Obsolete]
warnings. My point was to make e.g. the ${MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion}
substitution unconditional but use a property from eng/Versions.props when '$(VersionSuffix)' == 'ci' OR '$(VersionSuffix)' == 'dev'
. Should just need the eng/Versions.props properties and another block in src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj like
<GeneratedContentProperties Condition=" '$(VersionSuffix)' == 'ci' OR '$(VersionSuffix)' == 'dev' ">
$(GeneratedContentProperties);
MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion=$(MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion);
MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion=$(MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion);
<GeneratedContentProperties>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying! I just updated this branch with a fix.
9457658
to
4f8349b
Compare
fe62ea3
to
0a90427
Compare
0a90427
to
4a5b5de
Compare
@@ -247,7 +247,7 @@ private async Task MvcTemplateBuildsAndPublishes(string auth, string[] args) | |||
Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", Project, createResult)); | |||
|
|||
// Verify building in debug works | |||
var buildResult = await Project.RunDotNetBuildAsync(); | |||
var buildResult = await Project.RunDotNetBuildAsync(additionalArgs: "/p:NoWarn=NU1605"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange this still occurs. What was the exact warning❔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying this out as a workaround.
The exact error is:
version 16.7.0-preview-20330-02+1eab2845b for .NET\r\nCopyright (C) Microsoft Corporation. All rights reserved.\r\n\r\nF:\workspace\_work\1\s\.dotnet\sdk\5.0.100-preview.7.20330.3\MSBuild.dll -maxcpucount -property:Configuration=Release -target:Publish -verbosity:m /bl .\AspNet.pm24ssyvh1s.sln\r\n You are using a preview version of .NET. See: https://aka.ms/dotnet-core-
preview\r\nF:\workspace\_work\1\s\src\ProjectTemplates\BlazorTemplates.Tests\bin\Release\net5.0\TestTemplates\AspNet.pm24ssyvh1s\Server\AspNet.pm24ssyvh1s.Server.csproj : error NU1605: Detected package downgrade: Microsoft.AspNetCore.Authentication.JwtBearer from 5.0.0-preview.6.20312.15 to 5.0.0-ci. Reference the package directly from the project to select a different version.
\r\nF:\workspace\_work\1\s\src\ProjectTemplates\BlazorTemplates.Tests\bin\Release\net5.0\TestTemplates\AspNet.pm24ssyvh1s\Server\AspNet.pm24ssyvh1s.Server.csproj : error NU1605: AspNet.pm24ssyvh1s.Server -> Microsoft.Identity.Web 0.2.1-preview -> Microsoft.AspNetCore.Authentication.JwtBearer (>= 5.0.0-preview.6.20312.15)
\r\nF:\workspace\_work\1\s\src\ProjectTemplates\BlazorTemplates.Tests\bin\Release\net5.0\TestTemplates\AspNet.pm24ssyvh1s\Server\AspNet.pm24ssyvh1s.Server.csproj : error NU1605: AspNet.pm24ssyvh1s.Server -> Microsoft.AspNetCore.Authentication.JwtBearer (>= 5.0.0-ci)\r\nF:\workspace\_work\1\s\src\ProjectTemplates\BlazorTemplates.Tests\bin\Release\net5.0\TestTemplates\AspNet.pm24ssyvh1s\Server\AspNet.pm24ssyvh1s.Server.csproj : error NU1605: Detected package downgrade: Microsoft.AspNetCore.Authentication.OpenIdConnect from 5.0.0-preview.6.20312.15 to 5.0.0-ci. Reference the package directly from the project to select a different version.
\r\nF:\workspace\_work\1\s\src\ProjectTemplates\BlazorTemplates.Tests\bin\Release\net5.0\TestTemplates\AspNet.pm24ssyvh1s\Server\AspNet.pm24ssyvh1s.Server.csproj : error NU1605: AspNet.pm24ssyvh1s.Server -> Microsoft.Identity.Web 0.2.1-preview -> Microsoft.AspNetCore.Authentication.OpenIdConnect (>= 5.0.0-preview.6.20312.15)
\r\nF:\workspace\_work\1\s\src\ProjectTemplates\BlazorTemplates.Tests\bin\Release\net5.0\TestTemplates\AspNet.pm24ssyvh1s\Server\AspNet.pm24ssyvh1s.Server.csproj : error NU1605: AspNet.pm24ssyvh1s.Server ->
Microsoft.AspNetCore.Authentication.OpenIdConnect (>= 5.0.0-ci)\r\n You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview\r\n You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview\r\n AspNet.pm24ssyvh1s.Shared ->
I spoke with @pranavkm and he mentioned that the build might be failing in our public builds might be failing because they don't have access to the preview8 packages in the internal feed. When this happens, they fallback to the local verifications even though we have the VersionPrefix
check in our build.
I tried this out by submitting an internal PR but it failed with the same reason above. I'm not sure what the issue is here.
I disabled the warning as a last ditch effort since this change is a workaround that we will remove after the preview8 release and I didn't want to overinvest in it.
If you have ideas of cheap fixes for this, let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OIC the problem is the Condition
s in https://github.com/dotnet/aspnetcore/pull/24600/files#diff-a02e9b40ed5c9908719840e31ded1de3R45-R46 See suggestion there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure I had tried a similar condition at some point last night but I'll give this a go.
<PackageVersionVariableReference Include="$(RepoRoot)src\Security\Authentication\JwtBearer\src\Microsoft.AspNetCore.Authentication.JwtBearer.csproj" Condition="'$(VersionSuffix)' != 'ci' OR '$(VersionSuffix)' != 'dev'" /> | ||
<PackageVersionVariableReference Include="$(RepoRoot)src\Security\Authentication\OpenIdConnect\src\Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj" Condition="'$(VersionSuffix)' != 'ci' OR '$(VersionSuffix)' != 'dev'" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad I think. $(VersionSuffix)
is never equal to both ci
and dev
.
<PackageVersionVariableReference Include="$(RepoRoot)src\Security\Authentication\JwtBearer\src\Microsoft.AspNetCore.Authentication.JwtBearer.csproj" Condition="'$(VersionSuffix)' != 'ci' OR '$(VersionSuffix)' != 'dev'" /> | |
<PackageVersionVariableReference Include="$(RepoRoot)src\Security\Authentication\OpenIdConnect\src\Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj" Condition="'$(VersionSuffix)' != 'ci' OR '$(VersionSuffix)' != 'dev'" /> | |
<PackageVersionVariableReference Include="$(RepoRoot)src\Security\Authentication\JwtBearer\src\Microsoft.AspNetCore.Authentication.JwtBearer.csproj" Condition="'$(VersionSuffix)' != 'ci' OR '$(VersionSuffix)' != 'dev'" /> | |
<PackageVersionVariableReference Include="$(RepoRoot)src\Security\Authentication\OpenIdConnect\src\Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj" Condition=" ! ('$(VersionSuffix)' == 'ci' OR '$(VersionSuffix)' == 'dev') " /> |
@@ -247,7 +247,7 @@ private async Task MvcTemplateBuildsAndPublishes(string auth, string[] args) | |||
Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", Project, createResult)); | |||
|
|||
// Verify building in debug works | |||
var buildResult = await Project.RunDotNetBuildAsync(); | |||
var buildResult = await Project.RunDotNetBuildAsync(additionalArgs: "/p:NoWarn=NU1605"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OIC the problem is the Condition
s in https://github.com/dotnet/aspnetcore/pull/24600/files#diff-a02e9b40ed5c9908719840e31ded1de3R45-R46 See suggestion there
22ca5e5
to
1bfdcff
Compare
1bfdcff
to
3ea5b4e
Compare
I did quite a bit of tinkering to resolve the issue we were seeing in CI around the package downgrade. Ultimately, the only thing that worked was inlining the
There's probably a way to conditionally set this depending on whether or not a template was generated in a CI-environment or not. If having the Also, there is follow-up work to revert this PR and consume an updated version of the package. Work is tracked here: #24657 |
Thanks @captainsafia. |
Reimplementing the changes originally included in #24600
Reimplementing the changes originally included in #24600 Co-authored-by: Safia Abdalla <[email protected]>
Description
Addresses https://github.com/aspnet/AspNetCore-ManualTests/issues/142.
This is a temporary workaround for an issue that was found when validating project templates in preview8.
In preview8, we deprecated some authentication-related overloads (#24253). Some auth scenarios use the
Microsoft.Identity.Web
package which takes a dependency on the preview6 version of theMicrosoft.AspNetCore.Authentication.JwtBearer
andMicrosoft.AspNetCore.Authentication.OpenIdConnect
packages (ref). This caused the application to fail during initialization with aMissingMethodException
.This PR hard-codes the preview8 versions of these packages in the project template to pull in the latest version of our API. The long-term solution is for M.I.W to be updated to target >= preview8.
This change was validated on a Blazor WASM and WebAPI template.
Customer Impact
When a user creates attempts to create a template that uses some sort of AAD authentication, the application will fail to run when the user runs it using
dotnet run
or F5 on VS. The restore and build steps pass. The error occurs during startup at runtime.Workaround
To resolve this issue, customers can add the correct package references themselves.
This PR makes sure that the templates are including the correct version of the M.A.A.JwtBearer and M.A.A.OpenIdConnect packages above.
Risk
Low risk because this change has been validated in the Blazor WASM and WebAPI templates and because it's the smallest take we can change to resolve this issue.
cc: @Tratcher @HaoK @JunTaoLuo