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

OrchardCore doesn't work on net6.0 #34208

Closed
eerhardt opened this issue Jul 8, 2021 · 11 comments · Fixed by #34257
Closed

OrchardCore doesn't work on net6.0 #34208

eerhardt opened this issue Jul 8, 2021 · 11 comments · Fixed by #34257
Assignees
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates bug This issue describes a behavior which is not expected - a bug.
Milestone

Comments

@eerhardt
Copy link
Member

eerhardt commented Jul 8, 2021

Describe the bug

When trying to use OrchardCore on a net6.0 app, the default page 404s.

To Reproduce

  1. Build and run the following app using the latest 6.0.0-preview7 build:
<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="OrchardCore.Application.Cms.Targets" Version="1.0.0-rc2-13450" />
  </ItemGroup>
</Project>
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webbuilder =>
{
    webbuilder.Configure(app =>
    {
        app.UseRouting();

        app.UseStaticFiles();

        app.UseOrchardCore();

    });
})
.ConfigureServices(services => { services.AddOrchardCms(); })
.Build()
.Run();
  1. Navigate to https://localhost:5001/

image

Exceptions (if any)

(Note: there is a background NullReferenceException occurring in DependencyInjection code. That is tracked by dotnet/runtime#55255. I've fixed it locally and ensured that this issue still occurs even when the NRE is fixed.)

Further technical details

  • ASP.NET Core version: 6.0.0-preview.7.21355.4
  • Include the output of dotnet --info
❯ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.100-preview.7.21357.29
 Commit:    229bc924ef

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19043
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\dotnet\sdk\6.0.100-preview.7.21357.29\

Host (useful for support):
  Version: 6.0.0-preview.7.21356.2
  Commit:  566b53a66b

.NET SDKs installed:
  6.0.100-preview.7.21357.29 [C:\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.0-preview.7.21355.4 [C:\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.0-preview.7.21356.2 [C:\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.0-preview.7.21352.1 [C:\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version: n/a

cc @davidfowl

@adityamandaleeka
Copy link
Member

I was able to repro this. Dropping some logged info here in case it's helpful later...

trce: Microsoft.AspNetCore.Server.Kestrel.Http2[37]
      Connection id "0HMA2FMPU9JHK" received HEADERS frame for stream ID 25 with length 22 and flags END_STREAM, END_HEADERS, PRIORITY.
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2 GET https://localhost:5001/ - -
trce: Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware[2]
      All hosts are allowed.
dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1000]
      No candidates found for the request path '/'
dbug: Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware[2]
      Request did not match any endpoints
dbug: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[4]
      The request path / does not match a supported file type
info: OrchardCore.Modules.ModularTenantRouterMiddleware[0]
      Begin Routing Request
dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1000]
      No candidates found for the request path '/'
dbug: Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware[2]
      Request did not match any endpoints
dbug: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[4]
      The request path / does not match a supported file type
trce: Microsoft.AspNetCore.Server.Kestrel.Http2[49]
      Connection id "0HMA2FMPU9JHK" sending HEADERS frame for stream ID 25 with length 38 and flags END_STREAM, END_HEADERS.
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/2 GET https://localhost:5001/ - - - 404 0 - 0.4202ms

@davidfowl
Copy link
Member

davidfowl commented Jul 9, 2021

@pranavkm @javiercn I haven't dug in here enough yet but it might be an MVC or routing problem.

@davidfowl davidfowl added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates and removed area-runtime labels Jul 9, 2021
@javiercn
Copy link
Member

javiercn commented Jul 9, 2021

@davidfowl there are two things that I can think about being problematic here:

  • Application parts
  • The call to UseEndpoints, which I don't get to see anywhere

I was expecting to see an app.UseEndpoints(endpoints => endpoints.MapControllers())

Not sure if app.UseOrchardCore(); is doing it internally, but if so, it should not. We provide explicit guidance to customers not to subsume UseRouting and UseEndpoints within their own extension methods.

@davidfowl
Copy link
Member

Yea, but it used to work in .NET 5, this is a compat break in .NET 6. We need to figure out why it broke

@davidfowl
Copy link
Member

davidfowl commented Jul 9, 2021

UseOrchardCore is doing it internally. Along with alot of other crazy things 😄

@javiercn
Copy link
Member

javiercn commented Jul 9, 2021

@davidfowl my money is on application parts not working well with top-level statements or some of the new minimal hosting APIs, that's what I would check first.

Does it work outside of orchard?

@davidfowl
Copy link
Member

Top level statements? Yes.

@mkArtakMSFT mkArtakMSFT added this to the Next sprint planning milestone Jul 9, 2021
@ghost
Copy link

ghost commented Jul 9, 2021

Thanks for contacting us.

We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@mkArtakMSFT mkArtakMSFT added the bug This issue describes a behavior which is not expected - a bug. label Jul 9, 2021
@davidfowl
Copy link
Member

OK this is a bit more insidious than I thought, and it might not be an MVC or routing issue (yet). There are no IActionDescriptorProviders registered...

@davidfowl
Copy link
Member

davidfowl commented Jul 10, 2021

Found the issue. It's this change 2af293d. This works:

using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.Extensions.DependencyInjection.Extensions;

Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webbuilder =>
{
    webbuilder.Configure(app =>
    {
        app.UseOrchardCore();
    });
})
.ConfigureServices(services =>
{
    services.RemoveAll<IActionDescriptorCollectionProvider>();
    services.RemoveAll<IApiDescriptionGroupCollectionProvider>();
    services.AddOrchardCms();
})
.Build()
.Run();

It seems orchard relies on certain services not being added by the shell application. In this case the IActionDescriptorCollectionProvider was added by the call to AddEndpointsApiExplorer() which results in orchard finding 0 action descriptors. This seems like a bug in orchard IMO but it is a regression so we need to decide what to do here.

@Junjun-zhao
Copy link
Member

Verified and it has been fixed on SDK dotnet-sdk-6.0.100-preview.7.21363.2.Thanks.

@ghost ghost locked as resolved and limited conversation to collaborators Aug 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates bug This issue describes a behavior which is not expected - a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants