microsoft / react-native-windows

A framework for building native Windows apps with React.
https://microsoft.github.io/react-native-windows/
Other
16.36k stars 1.14k forks source link

C# projects sometimes hang at .NetNative step during release builds #14055

Closed jonthysell closed 2 weeks ago

jonthysell commented 3 weeks ago

Problem Description

We're seeing a lot of PR / CI builds where the new project CLI tests fail for a old architecture C# X64 and/or ARM64 release build. The hang appears to happen during the .NET native step:

BuildNativePackage:
         Creating ilc response file "obj\x64\Release\ilc.testcli.rsp" with the following content: /in:"D:\a\_work\1\testcli\windows\testcli\obj\x64\Release\ilc\in" /out:"D:\a\_work\1\testcli\windows\testcli\bin\x64\Release\ilc" /intermediatespath:"D:\a\_work\1\testcli\windows\testcli\obj\x64\Release\ilc\intermediate" /v:normal /keepintermediates:true /buildtype:ret /exename:"testcli.exe" /rcpath:"C:\Program Files %28x86%29\Windows Kits\10\bin\10.0.22621.0\x64\rc.exe" /targetplatformsdklibpath:"C:\Program Files %28x86%29\Windows Kits\10\lib\10.0.22621.0\um" /WindowsSdkApiXml:"C:\Program Files %28x86%29\Windows Kits\10\bin\10.0.22621.0\x64\PInvoke\SupportedAPIs.xml" /targetplatformsdkmetadatapath:"D:\a\_work\1\testcli\windows\testcli\obj\x64\Release\ilc\in\WinMetadata" /RdXmlPath:"D:\a\_work\_temp\.nuget\packages\microsoft.net.native.compiler\2.2.7-rel-27913-00\tools\LibraryXML" /CscPath:"D:\a\_work\_temp\.nuget\packages\microsoft.net.native.compiler\2.2.7-rel-27913-00\tools\csc\csc.exe" /suppressPDBWarnings:true /AllowNoManagedCode /frameworkDependency:"Name = Microsoft.UI.Xaml.2.8, MinVersion = 8.2207.14002.0, Publisher = 'CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US'" /frameworkDependency:"Name = Microsoft.NET.Native.Framework.2.2, MinVersion = 2.2.27912.0, Publisher = 'CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US'" /frameworkDependency:"Name = Microsoft.NET.Native.Runtime.2.2, MinVersion = 2.2.27328.0, Publisher = 'CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US'"  /UseSharedAssemblies /InSharedAssemblyPath:"D:\a\_work\_temp\.nuget\packages\runtime.win10-x64.microsoft.net.native.sharedlibrary\2.2.7-rel-27913-00\build\..\tools\SharedLibrary" /TargetPlatform:x64
         D:\a\_work\_temp\.nuget\packages\runtime.win10-x64.microsoft.net.native.compiler\2.2.7-rel-27913-00\build\..\tools\\x64\ilc\ilc.exe @"obj\x64\Release\ilc.testcli.rsp" "/logger:CsvLogger;4736;5868" 
         Launching 'D:\a\_work\_temp\.nuget\packages\runtime.win10-x64.microsoft.net.native.compiler\2.2.7-rel-27913-00\tools\x64\ilc\ilc.exe --gatekeeper @"D:\a\_work\1\testcli\windows\testcli\obj\x64\Release\ilc\intermediate\gkargs.rsp"'
##[error]The Operation will be canceled. The next steps may not contain expected logs.

Debug builds don't have this problem for X86 and X64 because they don't use .Net Native. ARM64 on the other hand, requires .NetNative for all builds and is the most likely to hit this.

Steps To Reproduce

  1. Build a new project with the old/uwp-cs-app template
  2. Build with run-windows --release

Expected Results

No response

CLI version

15.0.0-alpha.2

Environment

info Fetching system and libraries information... System: OS: Windows 11 10.0.26100 CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz Memory: 5.20 GB / 15.84 GB Binaries: Node: version: 18.18.0 path: C:\Program Files\nodejs\node.EXE Yarn: version: 1.22.22 path: C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: version: 9.8.1 path: C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: Not Found Windows SDK: AllowDevelopmentWithoutDevLicense: Enabled AllowAllTrustedApps: Enabled Versions:

Community Modules

No response

Target Platform Version

10.0.19041

Target Device(s)

Desktop

Visual Studio Version

Visual Studio 2022

Build Configuration

Release

Snack, code example, screenshot, or link to a repository

No response

jonthysell commented 2 weeks ago

I have confirmed that this hang can happen independent of the bundler hang addressed by https://github.com/microsoft/react-native-windows/pull/14063

See logs for an example of e2etest app hanging at .netnative way after bundler has completed successfully: https://dev.azure.com/ms/react-native-windows/_build/results?buildId=617132&view=logs&jobId=3559bc2f-1310-581e-5707-c6e64205ea8f&j=3559bc2f-1310-581e-5707-c6e64205ea8f&t=05b05db0-10ae-5c08-3d6e-0503fe2a7458