microsoft / react-native-windows

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

Commit changes when failing VS AutoLinkCheck #7809

Open NickGerleman opened 3 years ago

NickGerleman commented 3 years ago

In VS Builds we run nx react-native autolink-windows --check, which does a dry run of autolinking logic. This is done to avoid mutating build files during the actual build.

An alternate approach is to write the files, then fail the build, messaging the user that their files were updated. This still requires multiple builds, but removes a trip to the command-line for manual steps.

As a proof of concept I tried the following sequence of events:

  1. Started a build
  2. Mutated packages.config during the build
  3. Canceled the build
  4. Started a solution build

The new NuGet package was restored on the next build, meaning we should be able to fail the build a single time and have changes picked up the next.

So, we could change the current:

Warning: Auto-linking changes were necessary but '--check' was specified. Run 'npx react-native autolink-windows' to apply the changes.

to

Auto-linking updated your project. Please rebuild for changes to take effect.

chrisglein commented 3 years ago

Sounds like a potential improvement in the experience. @jonthysell thoughts on viability and side effects?

jonthysell commented 2 years ago

It is certainly an alterative - the design was to make sure autolinking never stopped VS users (ie. no error, no fail), and that, as essentially "power users" of RNW, a VS user wouldn't want their build files updated without their explicit intervention.