Skip to content

Calling the restore target in VS leads to a deadlock #15108

@nkolev92

Description

@nkolev92

Problem Description

vnext/PropertySheets/External/Microsoft.ReactNative.Common.targets

Calls the restore target in VS.
This can easily lead to a deadlock because it ends up with the restore task accessing a component that's UI thread bound without the synchronization from JTF.

The restore is not designed to work in VS.
The restore target also cannot be invoked during build/design time build.

Correctness - restore and build have a contract that's based on the assets file and nuget.g.props and nuget.g.targets.
The restore must be completed before the build starts, otherwise whatever NuGet restored will not be considered at build time. https://learn.microsoft.com/en-us/nuget/reference/msbuild-targets#restore-target
Similar thing applies to the design time build, restore would need to be independently invoked, which is not achievable via msbuild.

Performance and Reliability - Restore makes network calls that may take a while. This inevitably will lead to a UI delay for C++ projects where the DTB runs on the UI thread.
Worst case scenario, it leads to a deadlock, see https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2562416.

Steps To Reproduce

React native project and load it in VS. It may deadlock. Private sources increase the likelihood of a deadlock.

Expected Results

No response

CLI version

N/A

Environment

VS 2022 latest

Community Modules

No response

Target React Native Architecture

None

Target Platform Version

None

Visual Studio Version

None

Build Configuration

None

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

No response

Metadata

Metadata

Labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions