AzureAD / microsoft-authentication-library-for-dotnet

Microsoft Authentication Library (MSAL) for .NET
https://aka.ms/msal-net
MIT License
1.36k stars 330 forks source link

[Bug] Unable to build in release configuration since version 4.52 for .Net 4.8 #4722

Closed lexus1991fi closed 5 days ago

lexus1991fi commented 2 months ago

Library version used

4.52.0

.NET version

net4.8

Scenario

PublicClient - desktop app

Is this a new or an existing app?

The app is in production, and I have upgraded to a new version of MSAL

Issue description and reproduction steps

Hello. I tried to update my project nugets to recent version and ran into a problem

Here is csproj file of my empty (!) project.

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

  <PropertyGroup>
    <TargetFramework>net48</TargetFramework>
    <UseWpf>true</UseWpf>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Identity.Client.Desktop" Version="4.52.0" />
  </ItemGroup>

</Project>

and this is Directory.Build.props file

<Project>
  <PropertyGroup>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
  </PropertyGroup>

  <PropertyGroup>
    <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
    <Configurations>Release;Debug</Configurations>
    <PlatformTarget>AnyCPU</PlatformTarget>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <CodeAnalysisRuleSet>Microsoft.ExtendedDesignGuidelines.ruleset</CodeAnalysisRuleSet>
    <Optimize>false</Optimize>
    <DebugType>full</DebugType>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)' == 'Release'">
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <Optimize>true</Optimize>
    <DebugType>none</DebugType>
    <WarningLevel>2</WarningLevel>
  </PropertyGroup>
</Project>

and my compiler error output

Build started at 16:18...
1>------ Build started: Project: AnyLib, Configuration: Release Any CPU ------
1>CSC : error CS2045: /embed switch is only supported when emitting a PDB.
1>Done building project "AnyLib.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 16:18 and took 00,473 seconds ==========

If I change version from 4.52.0 to 4.51.0 or older build goes without any issues

Relevant code snippets

No response

Expected behavior

No response

Identity provider

Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)

Regression

4.51.0

Solution and workarounds

Works also in case of turned on debug pdb generation (non-release configuration)

localden commented 1 month ago

@lexus1991fi any reason you are using an outdated version of MSAL.NET? Have you tried this with 4.61.0 (latest Microsoft.Identity.Client)?

bgavrilMS commented 1 month ago

I wonder if it is related to https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues?q=is%3Aissue+GeneratedAssemblyInfoFile+is%3Aopen

The "native interop" package injects some settings in the build pipeline because net48 doesn't play nice with native dependencies. See the props and targets file in https://nuget.info/packages/Microsoft.Identity.Client.NativeInterop/0.16.0

lexus1991fi commented 5 days ago

@lexus1991fi any reason you are using an outdated version of MSAL.NET? Have you tried this with 4.61.0 (latest Microsoft.Identity.Client)?

Recent version also had issue when I reported. Just updated to 4.61 and it works fine. So bug is likely fixed now (at least for my exact case)