microsoft-authentication-library-for-dotnet icon indicating copy to clipboard operation
microsoft-authentication-library-for-dotnet copied to clipboard

[Bug] Microsoft.Identity.Client.NativeInterop.targets doesn't respect `GenerateAssemblyInfo=false`

Open RussKie opened this issue 1 year ago • 9 comments

The embedding must be conditional, otherwise it breaks the build image

Repro steps:

test.csproj
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
    <OutputType>Library</OutputType>
    <LangVersion>latest</LangVersion>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Identity.Client.NativeInterop" Version="0.16.2" />
  </ItemGroup>
</Project>
Class1.cs
namespace test;
public class Class1 { }

Try to compile the above - it fails because the targets unconditionally embeds non-existing non-generated assembly info:

PS D:\Development\throwaway\Microsoft.Identity.Client.NativeInterop> dotnet build
  Determining projects to restore...
  All projects are up-to-date for restore.
C:\Program Files\dotnet\sdk\8.0.400-preview.0.24312.1\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(311,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [D:\Development\throwaway\Microsoft.Identity.Client.NativeInterop\test.csproj]
CSC : error CS2001: Source file 'D:\Development\throwaway\Microsoft.Identity.Client.NativeInterop\obj\Debug\net472\test.AssemblyInfo.cs' could not be found. [D:\Development\throwaway\Microsoft.Identity.Client.NativeInterop\test.csproj]

Build FAILED.

CSC : error CS2001: Source file 'D:\Development\throwaway\Microsoft.Identity.Client.NativeInterop\obj\Debug\net472\test.AssemblyInfo.cs' could not be found. [D:\Development\throwaway\Microsoft.Identity.Client.NativeInterop\test.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.89

RussKie avatar Jul 10 '24 03:07 RussKie

Hi @RussKie , thanks for opening this! Would <EmbeddedFiles Condition="'$(GenerateAssemblyInfo)' == 'true'" Include="$(GeneratedAssemblyInfoFile)"/> resolve this issue? Thanks.

xinyuxu1026 avatar Jul 30 '24 22:07 xinyuxu1026

Yes, that should fix the issue.

RussKie avatar Jul 30 '24 22:07 RussKie

Thanks! @RussKie , I checked in the change, it should be in next release.

xinyuxu1026 avatar Aug 01 '24 23:08 xinyuxu1026

Great, thank you.

RussKie avatar Aug 02 '24 00:08 RussKie

Hi @RussKie , thanks for opening this! Would <EmbeddedFiles Condition="'$(GenerateAssemblyInfo)' == 'true'" Include="$(GeneratedAssemblyInfoFile)"/> resolve this issue? Thanks.

If it will be fixed in the next release, please set the "milestone" to the next version of MSAL.NET (a milestone should already exist). It'll help partners keep track of fixes.

bgavrilMS avatar Aug 13 '24 08:08 bgavrilMS

My question is why is it adding the generated assembly info file to embedded files in the first place? Do we know? It's good to have this fix, but what is it trying to do in the first place?

KirillOsenkov avatar Aug 13 '24 17:08 KirillOsenkov

Hi @RussKie , the new version of Microsoft.Identity.Client.NativeInterop is released https://www.nuget.org/packages/Microsoft.Identity.Client.NativeInterop/0.17.0, please update to Version="0.17.0"

xinyuxu1026 avatar Sep 21 '24 00:09 xinyuxu1026

@xinyuxu1026 do you know the answer to my question above? thanks!

KirillOsenkov avatar Sep 21 '24 02:09 KirillOsenkov

Hi @KirillOsenkov , I don't know about that.

@gladjohn might know more context.

xinyuxu1026 avatar Sep 23 '24 16:09 xinyuxu1026

Hi @xinyuxu1026, I followed up with @gladjohn and we both agree that the EmbeddedFiles line should just be deleted.

Instead of adding the condition, could you please just delete the whole line? Thanks!

KirillOsenkov avatar Oct 25 '24 04:10 KirillOsenkov

Hi @xinyuxu1026, any progress on deleting the line?

inthemedium avatar Dec 11 '24 23:12 inthemedium

Hi @inthemedium , sorry I missed the comment previously, I will work on this removal this week.

xinyuxu1026 avatar Dec 16 '24 18:12 xinyuxu1026

Hi, this is fixed in Microsoft.Identity.Client.NativeInterop 0.18.0. Please update to that version and see if this works, thanks.

xinyuxu1026 avatar Jan 31 '25 21:01 xinyuxu1026

I think we can close this, thanks.

KirillOsenkov avatar Feb 01 '25 00:02 KirillOsenkov