Skip to content

NET1136 errors in net6.0 project after updating to 6.0.300. #25363

@cgranade

Description

@cgranade

Describe the bug

When building the C# project at https://github.com/microsoft/qsharp-compiler/blob/main/src/QsCompiler/Tests.LanguageServer/Tests.LanguageServer.csproj against .NET SDK 6.0.202 or 6.0.203, no errors are observed. After updating to .NET SDK 6.0.300 or 7.0.100.preview.3, however, NET1136 is observed during builds:

C:\Program Files\dotnet\sdk\7.0.100-preview.3.22179.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.Defa
ultItems.Shared.targets(250,5): error NETSDK1136: The target platform must be set to Windows (usually by in 
cluding '-windows' in the TargetFramework property) when using Windows Forms or WPF, or referencing project
s or packages that do so. [C:\Users\cgran\source\repos\microsoft\qsharp-compiler\src\QsCompiler\Tests.Langu 
ageServer\Tests.LanguageServer.csproj]

For example, see CI build output at https://dev.azure.com/ms-quantum-public/Microsoft%20Quantum%20(public)/_build/results?buildId=41360&view=logs&j=89d70cac-d499-5445-3972-d2953f76273e&t=101b9824-70a7-5aa4-254a-0d15cbffbfcd.

To Reproduce

Modify global.json to the following:

{
    "sdk": {
        "version": "6.0.300",
        "rollForward": "disable"
    }
}

Further technical details

➜  dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.203
 Commit:    a20feadf6d

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.203\

Host (useful for support):
  Version: 7.0.0-preview.3.22175.4
  Commit:  162f83657c

.NET SDKs installed:
  3.1.201 [C:\Program Files\dotnet\sdk]
  3.1.300 [C:\Program Files\dotnet\sdk]
  3.1.418 [C:\Program Files\dotnet\sdk]
  5.0.100 [C:\Program Files\dotnet\sdk]
  5.0.400 [C:\Program Files\dotnet\sdk]
  5.0.407 [C:\Program Files\dotnet\sdk]
  6.0.104 [C:\Program Files\dotnet\sdk]
  6.0.201 [C:\Program Files\dotnet\sdk]
  6.0.202 [C:\Program Files\dotnet\sdk]
  6.0.203 [C:\Program Files\dotnet\sdk]
  6.0.300 [C:\Program Files\dotnet\sdk]
  7.0.100-preview.3.22179.4 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0-preview.3.22178.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.24 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0-preview.3.22175.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]      
  Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.24 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.0-preview.3.22177.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

Activity

added a commit that references this issue on May 11, 2022
ghost added
untriagedRequest triage from a team member
on May 11, 2022
ghost

ghost commented on May 11, 2022

@ghost

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.

baronfel

baronfel commented on May 11, 2022

@baronfel
Member

I cloned and built the repo, and it turns out that there are two dependencies that you have that are bringing in transitive framework references to Windows frameworks:

  • Microsoft.VisualStudio.ImageCatalog/17.0.31723.112 is bringing in Microsoft.WindowsDesktop.App.WPF
  • Microsoft.VisualStudio.Utilities/17.0.31723.112 is bringing in Microsoft.WindowsDesktop.App

I found these by looking at a binlog and cross-referencing with the generated project.assets.json file for the Tests.LanguageServer project. There are a few ways forward that I can see:

  • work with the authors of these packages to see if the Windows framework references are truly necessary
  • replace these packages with ones that provide similar functionality but don't have these required framework references
  • set the DisableTransitiveFrameworkReferences to true, either through the -p command of dotnet build and related commands, or via your project files directly

I do not recommend the third option as a long-term solution, as this will prevent you from restoring any future framework references your dependencies bring in. Right now you have no other dependencies that include framework references, but that could change at any time.

baronfel

baronfel commented on May 11, 2022

@baronfel
Member

Interesting note that may need some follow-up - these transitive framework references are as follows:

  • Microsoft.VisualStudio.Utilties:
    <frameworkReferences>
      <group targetFramework="net6.0" />
      <group targetFramework="net6.0-windows10.0.18362">
        <frameworkReference name="Microsoft.WindowsDesktop.App" />
      </group>
      <group targetFramework=".NETFramework4.7.2" />
      <group targetFramework=".NETStandard2.0" />
    </frameworkReferences>
  • Microsoft.VisualStudio.ImageCatalog
    <frameworkReferences>
      <group targetFramework="net6.0-windows10.0.18362">
        <frameworkReference name="Microsoft.WindowsDesktop.App.WPF" />
      </group>
      <group targetFramework=".NETFramework4.7.2" />
      <group targetFramework=".NETStandard2.0" />
    </frameworkReferences>

But the windows-specific frameworkReferences were written to the project.assets.json file under the net6.0 target node when I would have expected a net6.0-windows10.0.18362 node, or something (I've attached one here as an example). @nkolev92 is this expected? Is there something off with assets file generation here?

project.assets.json.zip

cgranade

cgranade commented on May 11, 2022

@cgranade
Author

@baronfel: Much obliged for the help! I'll follow up with the package authors, then, as you suggest. Out of curiosity, do you know why these transitive references only started causing a problem as of SDK 6.0.300? Thank you so much!

baronfel

baronfel commented on May 11, 2022

@baronfel
Member

I'm unsure - the brief look I've taken shows PRs from a year or two ago, so I would expect it to have been a persistent problem.

nkolev92

nkolev92 commented on May 12, 2022

@nkolev92
Contributor

@baronfel

Maybe you were looking at the wrong verion of the ImageCatalog package.

I see

    <frameworkReferences>
      <group targetFramework=".NETCoreApp3.1">
        <frameworkReference name="Microsoft.WindowsDesktop.App.WPF" />
      </group>
      <group targetFramework=".NETFramework4.7.2" />
      <group targetFramework=".NETStandard2.0" />
    </frameworkReferences>

Which would explain the assets file.

baronfel

baronfel commented on May 12, 2022

@baronfel
Member

Ah, of course! You're exactly right.

baronfel

baronfel commented on May 12, 2022

@baronfel
Member

@cgranade the up-shot of @nkolev92's point is that if you update to the most recent version of these libraries (both seem to be 17.2.x versions in the most recent form) then this should go away.

cgranade

cgranade commented on May 12, 2022

@cgranade
Author

Much obliged, @baronfel and @nkolev92! Will go on and work with my team to get that updated on our side, then. Thank you again! ♥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @cgranade@baronfel@nkolev92

        Issue actions

          NET1136 errors in net6.0 project after updating to 6.0.300. · Issue #25363 · dotnet/sdk