microsoft / react-native-windows

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

APPX Generation very slow #3096

Closed nelsona closed 4 years ago

nelsona commented 5 years ago

Environment

  1. react-native -v: v0.59.10
  2. npm ls rnpm-plugin-windows: 0.2.11
  3. npm ls react-native-windows: 0.59.0-rc3
  4. node -v: 10.15.0
  5. npm -v: 6.4.1

Then, specify:

Steps to Reproduce

(Write your steps here:)

  1. Attempt to generate the APPX bundle from either within VS or using msbuild on command line

Expected Behavior

The APPX bundle would be created in a timely fashion.

Actual Behavior

APPX bundle is taking in excess of an hour to be built.

Reproducible Demo

Repo available here: https://github.com/nelsona/windows-rn59-testapp

Running the following msbuild:

msbuild testApp.sln -t:restore /t:Clean;Build /t:testApp /p:OutputPath=./build;Configuration=ReleaseBundle;AppxBundle=Always;AppxBundlePlatforms="x64|ARM|x86";AppxPackageDir="build\\AppxPackages\\";UapAppxPackageBuildMode=StoreUpload

command shows the build getting stuck during the Processing application code section. Checking in task manager shows the .NET Native Compiler Toolchain process is running and doesn't seem to finish.

sashaxxd commented 5 years ago

I have the same thing - I don’t understand what to do ... debug works fine, release freezes for several hours

did not find a solution?

licanhua commented 5 years ago

I reproduced the problem with VS2019, from what I see, problem is in RunILTransforms. At that time, ilc is busy with GC. I already collected some logs and would ask help from VS team. Will let you know if there is update.

licanhua commented 5 years ago

You are hitting known VS bug. Here is the workaround provides by VS team: To get latest tools you need to update to 6.2.9 of Microsoft.NETCore.UniversalWindowsPlatform and have an OsMinVersion of 16299 or greater.

sashaxxd commented 5 years ago

You are hitting known VS bug. Here is the workaround provides by VS team: To get latest tools you need to update to 6.2.9 of Microsoft.NETCore.UniversalWindowsPlatform and have an OsMinVersion of 16299 or greater.

Microsoft.NETCore.UniversalWindowsPlatform updated to 6.2.9 OsMinVersion - this is the build version of windows 10? If so, I have the assembly of windows 10 - 18362.356

Visual Studio 2017 - updated today

Debug and DebugBundle x86 - the application runs well

ReleaseBundle x86 - release freezes for several hours

downloaded Visual Studio 2019 - DebugBundle x86 gives an error message - failed to open certificate test_TemporaryKey.pfx

ReleaseBundle x86 gives an error message - failed to open certificate test_TemporaryKey.pfx

licanhua commented 5 years ago

OsMinVersion means TargetPlatformMinVersion. You need to change both TargetPlatformVersion and TargetPlatformMinVersion to 16299 or great. That also means that the running OS should be 16299+, and you can't deploy the app with min version to 16299 to OS older than 16299.

I don't know the certificate problem, please double check if it's the same problem as https://github.com/microsoft/react-native-windows/pull/3144

sashaxxd commented 5 years ago

How long should the assembly take? A couple of seconds?

Microsoft.NETCore.UniversalWindowsPlatform updated to 6.2.9 TargetPlatformMinVersion 16299

licanhua commented 5 years ago

@sashaxxd, The workaround works fine on my machine. It's possible that you didn't modify them everywhere.

Could you please open the solution, and modify all projects which postfixed with '(Universal Windows)'. and then save them.

image

For example, for ChakraBridge, make the setting as below: image

For testApp, it looks like this: image

sashaxxd commented 5 years ago

licanhua - Yes, everything worked out! Thank you very much for your help.

licanhua commented 5 years ago

Glad to hear that. Please keep this bug open. Above is just workaround There are two possible solutions:

  1. VS fix the [internal bug 983876].
  2. or react-native-windows current retarget to 16299 and above. It requires code change and document update.
nelsona commented 5 years ago

@licanhua This is working great for me if I use VS to build the APPX but when I try and build via MSBuild on the command line I get the following types of error in the the ReactNativeWebViewBridge project. It is complaining about not being able to find System so it reports errors like: error CS0518: Predefined type 'System.Int32'

Can you give me any advice on how I might be able to get this running properly through the command line please?

licanhua commented 5 years ago

@rozele Do you have VS2017 environment ready and try @nelsona 's project? I just reinstalled the whole system and am using vs 2019

licanhua commented 5 years ago

@nelsona I used VS 2019 and v141 msbuild tool, I run into a different error: LINK : fatal error C1001: An internal error has occurred in the compiler. [f:\repo\windows-rn59-testapp\node_modules\react-native-windows\Yoga\csharp\Yoga\Yoga.Universal.vcxproj] Add /v:diag /bl to msbuild will provide more logs for you. and you can open the binlog with http://msbuildlog.com/.

licanhua commented 5 years ago

It's a time consuming task. maybe we need to update all dependency like Yoga to the latest version, also verify and release a new package with min version to 16299. Also need to consume and verify the package with latest vs2017 and vs2019 Request to triage this bug.

licanhua commented 5 years ago

I'm using vs 2019, and repro step is the same as the bug described. vs2019 checks the certificate, so I updated it and put it in https://github.com/licanhua/windows-rn59-testapp To reproduce the problem, please update min version to 16299 for all packages

olafure commented 5 years ago

Are there any updates on this one? The msbuild issue effectively means that CI builds are impossible.

giregk commented 4 years ago

I have the same issue. I performed the following steps (VS 2019)

  1. right click solution -> manage NuGet Packages for Solution -> update Microsoft.NETCore.UniversalWindowsPlatform to 6.2.9 for all projects
  2. Update target and min version for each project as @licanhua suggested At that point, my project was broken. I had to :
  3. right click solution -> Project dependencies -> reconfigure dependencies like so
    • MyApp
      • yoga.uwp
      • ReactNative
        • ChakraBridge
        • ReactNativeWebViewBridge so the build order was back to ChakraBridge - ReactNativeWebViewBridge - ReactNative - yoga.uwp - MyApp
  4. add a reference to ReactNativeWebViewBridge in the ReactNative project
  5. add a reference to ReactNative in MyApp project

BUG 1: Now when I build my app In Debug config (x86), it builds and runs, but all my calls to Linking.openURL fail with the following native error Exception thrown: 'System.InvalidOperationException' in ReactNative.dll WinRT information: The API needs to be called from the UI thread.

BUG 2: even though the release build finishes quickly, the release app crashes at the launch. Clearly, react-native-windows is not ready for production.

Has anyone ever actually managed to publish a react-native-windows app ?

MayMaria commented 4 years ago

Facing similar issue while taking release build for uwp app. I am using Visual Studio 2017.

Environment: react-native -v: v0.59.10 npm ls rnpm-plugin-windows: ^0.4.0 npm ls react-native-windows: “0.59.0-legacy.2” node -v: 10.15.3 npm -v: 6.4.1

Using below command to generate a windows bundle file, "react-native bundle --platform windows --entry-file index.js --bundle-output windows/digital_expert_rn/ReactAssets/index.windows.bundle --assets-dest windows/digital_expert_rn/ReactAsset

Debug build happens quick and able to run the app. Release build is taking hours and getting a freeze.

  1. Though it takes time, has anyone succeeded in generating a release build?
  2. Does any of the solution above works completely? Found in few threads that release build can be taken, but app crashes on launch.
  3. If there is no option, can debug build be published to store? (Worst case)

Requesting immediate attention on this.

ghost commented 4 years ago

We are not investing in new features or lower priority bug fixes on the C# implementation of React Native for Windows (previously known as "vCurrent"). All investment moving forward is in the C++ infrastructure (previously known as "vNext") and that is the only option as of 0.61 (and was the default as of 0.60). If this issue is still relevant on the modern implementation please open a new issue. If this issue is of significant severity for a vCurrent app and vNext is not an option, re-open with justification.

chrisglein commented 4 years ago

This one is still an issue for vCurrent users. Sounds like there may be some recommendations above that we need to bake into documentation.

chrisglein commented 4 years ago

Steps that were confirmed to update the last app that hit this:

• Upgade Microsoft.NETCore.UniversalWindowsPlatform to 6.2.9 • Move the minimum supported Windows version to 16299 • Upgrade the react-native-windows plugin to 6.0.1

These are what we need to capture in some sort of troubleshooting documentation for consumers of vCurrent.

harinikmsft commented 4 years ago

Marking this for documentation. Plan to update the troubleshooting page of current- 0.59 branch in place. Here - https://github.com/microsoft/react-native-windows/blob/0.59-legacy/current/docs/SetupTroubleshooting.md

harinikmsft commented 4 years ago

Fixed by #4675