dotnet / dotnet/sdk

Microsoft.Windows.SDK.NET.Ref package not referenced when targeting .NET 5.0 in .NET 9.0 RC.2 SDK

Open
#44,705 9 comments 0 reactions 1 assignee Claimed by @manodasanW View on GitHub
Area-NetSDK untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Description
A simple project targeting e.g. `net5.0-windows10.0.17763.0` will fail to resolve UWP types like `Windows.Devices.Power.Battery` because `Microsoft.Windows.SDK.NET.Ref` references are not passed to C# compiler.

```
error CS0246: The type or namespace name 'Windows' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'Battery' could not be found (are you missing a using directive or an assembly reference?)
```

This was working in RC.1.

Changing the target framework version to `net6.0-windows10.0.17763.0` resolves this problem.

.NET 5.0 is not supported, but is this intentional?

### To Reproduce
1. Create any .NET project targeting `net5.0-windows10.0.17763.0` or any other version of Win SDK as long as the target framework is `net5.0`.
2. Reference any UWP type like `Windows.Devices.Power.Battery`.
3. `dotnet build` with .NET 9.0 RC2 (I tried with the 6th November nightly build and the behavior was the same).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.