Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.25k stars 4.58k forks source link

[BUG] "-windows" TargetFramework requires "Microsoft.WindowsDesktop.App" and can't be deployed to Azure #41390

Closed robertmuehsig closed 7 months ago

robertmuehsig commented 7 months ago

Library name and version

Azure.Identity 1.10.4

Describe the bug

When you create a "Windows" specific Web Application like that:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net6.0-windows</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Azure.Identity" Version="1.10.4" />
  </ItemGroup>

</Project>

Then the resulting project will require the WindowsDesktop runtime:

{
  "runtimeOptions": {
    "tfm": "net6.0",
    "frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "6.0.0"
      },
      {
        "name": "Microsoft.WindowsDesktop.App",
        "version": "6.0.0"
      },
      {
        "name": "Microsoft.AspNetCore.App",
        "version": "6.0.0"
      }
    ],
    "configProperties": {
      "System.GC.Server": true,
      "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
      "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
    }
  }
}

Reason is the dependency Microsoft.Identity.Client, which will add WebView2 and other stuff to the dependency tree: image

The problem: a) It was quite suprising that the target runtime dependency has changed. b) This WindowsDesktop Runtime is not available on Azure (e.g. App Service).

Expected behavior

It seems wrong that the TargetFramework "net6.0-windows" is treated like "the application will be run on a desktop environment". I always thought that "net6.0-windows" is for applications that uses Windows Specific APIs, which might be a Web Application. With the current behavior we had to use "net6.0" (which is in the end a good thing, but feels a bit drastic just because one NuGet package has a weird feature backed in).

Actual behavior

The desktop runtime is required.

Reproduction Steps

Result:

You must install or update .NET to run this application.

App: C:\inetpub\wwwroot\primedocs\Service\PrimeDocs.Service.Host.dll
Architecture: x64
Framework: 'Microsoft.WindowsDesktop.App', version '6.0.0' (x64)
.NET location: C:\Program Files\dotnet\

No frameworks were found.

Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed

Environment

Azure App Service

jsquire commented 7 months ago

This issue has been transferred to the repository where the Microsoft.Identity.Client library is maintained as #4525.