Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Client bug]: dotnet publish with /p:PublishTrimmed=true never finishes #1811

Closed
davull opened this issue Apr 6, 2023 · 9 comments
Closed

Comments

@davull
Copy link

davull commented Apr 6, 2023

Describe the bug

When using the Microsoft.Graph Package in an .NET MAUI Blazor project, publishing the Android or the iOS app with PublishTrimmed enabled never finishes.

With PublishTrimmed and RunAOTCompilation disabed it works. But then we can't build iOS apps:

dotnet publish -c Release -f net7.0-android /p:PublishTrimmed=false /p:RunAOTCompilation=false

To Reproduce
Steps to reproduce the behavior:

  1. Create new .NET MAUI Blazor App: dotnet new maui-blazor -n MauiBlazorTest
  2. Add latest Microsoft.Graph package: dotnet add package Microsoft.Graph --version 5.5.0
  3. Run dotnet publish: dotnet publish -c Release -f net7.0-android
  4. Output is Optimizing assemblies for size. This process might take a while.. All CPU and Memory (32gb) is used up and the command never finishes (we have let it run several hours). Same result on different machines and on Azure Pipeline CI builds.

Expected behavior
Publishing should finish and produce *.apk and *.aab bundles.

Client version
Microsoft.Graph 5.5.0

Desktop:

  • OS: Windows 11
  • Version: 11 (10.0.22621)

Additional context

dotnet --info

.NET SDK:
 Version:   7.0.202
 Commit:    6c74320bc3

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

Host:
  Version:      7.0.4
  Architecture: x64
  Commit:       0a396acafe

.NET SDKs installed:
  3.1.426 [C:\Program Files\dotnet\sdk]
  6.0.302 [C:\Program Files\dotnet\sdk]
  6.0.310 [C:\Program Files\dotnet\sdk]
  7.0.101 [C:\Program Files\dotnet\sdk]
  7.0.102 [C:\Program Files\dotnet\sdk]
  7.0.104 [C:\Program Files\dotnet\sdk]
  7.0.202 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.17 [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 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.25 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.27 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.17 [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 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

@ghost ghost added the Needs: Triage label Apr 6, 2023
@drossoft
Copy link

drossoft commented Apr 9, 2023

I have the same problem.

I created a new MAUI project, added the Microsoft.Graph 4.0.0 nuget and compiled in release. It took 12 minutes.
Then I upgraded to Microsoft.Graph version 5.5.0 and waited for 2 hours, and the compilation did not finish.

Any workaround?

@davull
Copy link
Author

davull commented Apr 9, 2023

We have removed the SDK and call the endpoints with a http client directly.

@drossoft
Copy link

Thanks, we had thought to do the same, but we have downgraded to version 4.1.0 (the one we were using in Xamarin) and we managed to compile in release, although it took 30 minutes.

@jbartlettii
Copy link

Same issue here with the dotnet publish command hanging on blazor wasm self-hosted application after adding graph v5, have tried multiple versions 5.3 to 5.5. Local and Azure Devops still fail, tried on multiple projects, removing the Graph dependency totally clears out the problem. Doing nothing but adding the graph nuget package to an existing application takes my publish command time from ~5min, to over an hour until it times itself out. Going to follow @drossoft and revert back to v4 where I have other applications whose pipelines are running fine.

@drossoft
Copy link

drossoft commented May 5, 2023

unfortunately, version 4.1 is not compatible with MAUI:

{System.TypeLoadException: Could not resolve type with token 01000023 from typeref (expected class 'System.Threading.Tasks.ValueTask1' in assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e') at Microsoft.Graph.ResponseHandler.<HandleResponse>d__21[[Microsoft.Graph.DriveItemChildrenCollectionResponse, Microsoft.Graph, Version=4.54.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext()
at Microsoft.Graph.BaseRequest.d__34`1[[Microsoft.Graph.DriveItemChildrenCollectionResponse, Microsoft.Graph, Version=4.54.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext()
at Microsoft.Graph.DriveItemChildrenCollectionRequest.GetAsync(CancellationToken cancellationToken).....

I guess I will have to switch to http client :(
Any good sample on how to do this?

@jbartlettii
Copy link

unfortunately, version 4.1 is not compatible with MAUI:

{System.TypeLoadException: Could not resolve type with token 01000023 from typeref (expected class 'System.Threading.Tasks.ValueTask`1' in assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e')

at Microsoft.Graph.ResponseHandler.d__2`1[[Microsoft.Graph.DriveItemChildrenCollectionResponse, Microsoft.Graph, Version=4.54.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext()

at Microsoft.Graph.BaseRequest.d__34`1[[Microsoft.Graph.DriveItemChildrenCollectionResponse, Microsoft.Graph, Version=4.54.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext()

at Microsoft.Graph.DriveItemChildrenCollectionRequest.GetAsync(CancellationToken cancellationToken).....

I guess I will have to switch to http client :(

Any good sample on how to do this?

https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/graph-api?view=aspnetcore-7.0&pivots=named-client-graph-api not specifically for MAUI, but hopefully this gives a good idea and can maybe help you get going.

@drossoft
Copy link

drossoft commented May 5, 2023

Thanks @jbartlettii ! I'll take a look

@NickDarvey
Copy link

We're also reproing this. This has been triaged but nobody is assigned. How does your planning work, or, what happens next @andrueastman?

@andrueastman
Copy link
Member

This should be resolved via #2182 and release https://www.nuget.org/packages/Microsoft.Graph/5.32.0

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

No branches or pull requests

5 participants