dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.72k stars 1.07k forks source link

Form designer keep loading when targeting to .NET 7.0 #24389

Closed Lydia-Shi closed 2 years ago

Lydia-Shi commented 2 years ago

Description

When creating a Winforms .Net core application and targeting to .NET 7.0, Form designer keep loading and an error dialog pops out, WSOD page is shown after few minutes.

Reproduction Steps

  1. Create a Winforms .NET Core application
  2. Observe Form designer that opens automatically

Expected behavior

Forms designer can displayed successfully.

Actual behavior

Form designer keeps loading. WSOD page is shown after few minutes. image image

Regression?

Yes, it's a regression issue and cannot repro in 7.0.100-preview.3.22153.22.

Known Workarounds

No response

Configuration

.Net 7.0.100-preview.3.22159.27

Other information

This issue also occurs in WPF project. image

dotnet-issue-labeler[bot] commented 2 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

teo-tsirpanis commented 2 years ago

This issue should be moved either to dotnet/winforms or to the Visual Studio Developer Community.

BTW I have encountered a similar error but when targeting .NET 6.

dreddy-work commented 2 years ago

@Lydia-Shi, can you check event log and see which framework preview version it was expecting here. Did you create this application new on the machine where you are running it?

RussKie commented 2 years ago

@Lydia-Shi can you please provide a link to the SDK installer that causes the issue? And VS version too please.

Lydia-Shi commented 2 years ago

@Lydia-Shi, can you check event log and see which framework preview version it was expecting here. Did you create this application new on the machine where you are running it?

@dreddy-work I just create a simple project, not a running one. Please see below GIF: NotOpen

Event log:

Description: A .NET Core application failed.
Application: DesignToolsServer.exe
Path: \\?\C:\Users\v-qiashi\AppData\Local\Temp\WinFormsCache\cy2c0v4g.mit\DesignToolsServer.exe
Message: It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '7.0.0-preview.3.22158.1' (x64) was not found.
  - The following frameworks were found:
      2.1.30 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      3.1.22 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      3.1.23 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      5.0.14 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      5.0.15 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      6.0.2 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      6.0.3 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      7.0.0-preview.3.22151.6 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:
  - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=7.0.0-preview.3.22158.1&arch=x64&rid=win10-x64

image image

@Lydia-Shi can you please provide a link to the SDK installer that causes the issue? And VS version too please.

@RussKie We always download 7.0 from latest main branch(https://github.com/dotnet/installer), like below: image

VS Version: 17.2.0 Preview 3.0 [32310.290.main]

dreddy-work commented 2 years ago

@Lydia-Shi , creating .Net 6.0 apps work fine?

Lydia-Shi commented 2 years ago

@dreddy-work Yes, Form designer works fine when targeting to .NET 6.0.

dreddy-work commented 2 years ago

Runtime config json is missing framework versions in it.

{
  "runtimeOptions": {
    "tfm": "net7.0",

    "additionalProbingPaths": [
      "C:\\Users\\dreddy\\.dotnet\\store\\|arch|\\|tfm|",
      "C:\\Users\\dreddy\\.nuget\\packages"
    ],
    "configProperties": {
      "Microsoft.NETCore.DotNetHostPolicy.SetAppPaths": true
    }
  }
}
RussKie commented 2 years ago

Is this an SDK issue?

dreddy-work commented 2 years ago

Seems so. ProjectName>.designer.runtimeconfig.json is generated without targetframework info in it. @dsplaisted , who would be right person to look into this? @Shyam-Gupta as FYI.

We use

 await  configuredProject.Services.OutputGroups.GetOutputGroupAsync("DesignerRuntimeImplementationProjectOutputGroup", cancellationToken);
dsplaisted commented 2 years ago

What does the (non-designer) runtimeconfig.json look like?

Can you share a binlog including the _GenerateDesignerRuntimeConfigFile target?

dreddy-work commented 2 years ago

Copied binlog here: "\clickonceqa\ClickOnce\temp\dreddy\msbuild.binlog"

Content of the runtimeconfig.json are

{
  "runtimeOptions": {
    "tfm": "net7.0",
    "frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "7.0.0-preview.3.22151.6"
      },
      {
        "name": "Microsoft.WindowsDesktop.App",
        "version": "7.0.0-preview.3.22159.1"
      }
    ]
  }
}

and content of deps.json are

{
  "runtimeTarget": {
    "name": ".NETCoreApp,Version=v7.0",
    "signature": ""
  },
  "compilationOptions": {},
  "targets": {
    ".NETCoreApp,Version=v7.0": {
      "TestApp/1.0.0": {
        "runtime": {
          "TestApp.dll": {}
        }
      }
    }
  },
  "libraries": {
    "TestApp/1.0.0": {
      "type": "project",
      "serviceable": false,
      "sha512": ""
    }
  }
}
dreddy-work commented 2 years ago

Here is the copy from repro machine where build is failing and (non-designer) runtimeconfig.json is not yet generated. need to change extension to zip to upload here. msbuild.zip .

dreddy-work commented 2 years ago

This is currently blocking both WinForms and WPF.

dreddy-work commented 2 years ago

expected runtimeconfig.json should have following content

{
  "runtimeOptions": {
    "tfm": "net7.0",

    "frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "7.0.0-preview.3.22151.6"
      },
      {
        "name": "Microsoft.WindowsDesktop.App",
        "version": "7.0.0-preview.3.22128.8"
      }
    ],

    "additionalProbingPaths": [
      "C:\\Users\\dreddy\\.dotnet\\store\\|arch|\\|tfm|",
      "C:\\Users\\dreddy\\.nuget\\packages",
      "C:\\temp\\fallback"
    ],
    "configProperties": {
      "Microsoft.NETCore.DotNetHostPolicy.SetAppPaths": true
    }
  }
}
marcpopMSFT commented 2 years ago

The current installer build is incoherent as runtime is blocked: https://github.com/dotnet/installer/pull/13376

RussKie commented 2 years ago

/cc: @kirsan31 @Olina-Zhang

Olina-Zhang commented 2 years ago

Verified this issue in the latest .Net 7.0 SDK build 7.0.100-preview.4.22173.7 from main branch: https://github.com/dotnet/installer, it is fixed: form designer can be loaded successfully, build and run app successfully. image