React-native-windows: react-native run-windows command is failing at build step

Created on 27 Sep 2019  Â·  48Comments  Â·  Source: microsoft/react-native-windows

Per @marlenecota this has started occurring with msbuild version update to 16.3.0.46305. This is causing the CLI to not work anymore.

Workaround is to build the project in VS instead of msbuild, run yarn start and run the project from VS.

CLI bug must-have

Most helpful comment

I was able to find a solution to the following error:
× Failed to restore the NuGet packages: Error: MSBuild tools not found. Make sure all required components have been installed (e.g. v141 support)

I used @alariej 's solution but because it took me a while to find it I decided to do a step by step solution with pictures.

Open Visual Studio Installer and press Modify on your studio version

image

First make sure that Univeral Windows Platform development is enabled (of course)

image

Close Individual Components and open up the Universal Windows Platform development panel which is highlighted below

image

Enable the two highlighted options and press modify to update

image

Once complete

Once you complete this process you could be able to run

npx react-native run-windows

Hope this helped.

All 48 comments

The error is like this:
F:\repo\react-native-windows\node_modules.folly\folly-2019.08.12.00\folly\portability\Builtins.h(44,25): error C2373: '__builtin_clz': redefinition; different type modifiers (compiling source file CustomViewManager.cpp) [F:\repo\react-native-windows\packages\react-native-windows-extended\windows\react-native-windows-extended.vcxproj]

Fixed by #3279

Has this actually been resolved? I get the msbuild error when running react-native run-windows

My react native windows version is: ^0.60.0-vnext.71

Can you try running react-native run-windows --logging to see if that provides more information on what is failing?

I get:
i Verbose: ON √ Found NuGet Binary Searching for MSBuild version 16.0 Searching for MSBuild version 15.0 Searching for MSBuild version 14.0 Searching for MSBuild version 12.0 Searching for MSBuild version 4.0 × Failed to restore the NuGet packages: Error: MSBuild tools not found. Make sure all required components have been installed (e.g. v141 support)

Note: I am able to get this to run via the visual studio instructions (after degrading my version of node to 10.16.3), but I'd prefer to run via the single command

@Joshua-David seems like an Windows SDK and path issue to find a version of MSBuild and tools. However, you may still run into what I did, the below permission issue?
Cheers

 √ Starting the React-Native Server
 √ Removing old version of the app
 Set-ItemProperty : Requested registry access is not allowed.
At C:\box\react\native\rnwinVnextConsuming\node_modules\react-native-windows\local-cli\runWindows\utils\WindowsStoreAppUtils.ps1:91 char:5
+     Set-ItemProperty -Path $RegistryKeyPath -Name AllowDevelopmentWit ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (HKEY_LOCAL_MACH...\AppModelUnlock:String) [Set-ItemProperty], SecurityException
    + FullyQualifiedErrorId : System.Security.SecurityException,Microsoft.PowerShell.Commands.SetItemPropertyCommand

√ Enabling Developer Mode
 Found package: C:\box\react\native\rnwinVnextConsuming\windows\AppPackages\rnwinVnextConsuming\rnwinVnextConsuming_1.0.0.0_Win32_Debug_Test\rnwinVnextConsuming_1.0.0.0_Win32_Debug.appx
Found certificate: C:\box\react\native\rnwinVnextConsuming\windows\AppPackages\rnwinVnextConsuming\rnwinVnextConsuming_1.0.0.0_Win32_Debug_Test\rnwinVnextConsuming_1.0.0.0_Win32_Debug.cer

Before installing this app, you need to do the following:
        - Install the signing certificate
You must provide administrator credentials to proceed.  Please run this script without the -Force parameter or from an elevated PowerShell window.
√ Installing new version of the app
 × Failed to deploy: Fail to check the installed app, maybe developer mode is off on Windows

After installing the cert manually (may not be needed) and running from an admin PowerShell / CMD it worked and viola, so this does not appear to be an issue now.

√ Found NuGet Binary
× Failed to restore the NuGet packages: Error: MSBuild tools not found. Make sure all required components have been installed (e.g. v141 support)

Repaired the whole Build tools suite and I still get this error.

Same error here (Windows 10, Node v13.9.0):

PS D:\dev\nodejs\my-app> react-native run-windows
 √ Downloading NuGet Binary
 √ Found NuGet Binary
 × Failed to restore the NuGet packages: Error: MSBuild tools not found. Make sure all required components have been installed (e.g. v141 support)

Bumping this as I am having the same issue.

For me the problem was the vswhere query being executed. In particular this one
"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version 2.0 -property installationPath -products * -requires Microsoft.VisualStudio.ComponentGroup.UWP.VC

returned no value (or rather const vsPath = VSWhere(requires.join(' '), version, 'installationPath'); in msbuildtools.js returned an empty value )

After i instealled universal windows platform development INCLUDING the c++ build tools optional dependency (based on the documentation found here https://devblogs.microsoft.com/cppblog/finding-the-visual-c-compiler-tools-in-visual-studio-2017/ )
It worked

I have the same issue.
I tried it with both the stable 0.60.0 and the beta version 0.61.5.
Got both times the same error:
× Failed to restore the NuGet packages: Error: MSBuild tools not found. Make sure all required components have been installed (e.g. v141 support)

Same

  • SDK Installed
  • Node 10.15.1
  • yarn 1.22.0
  1. react-native init <Project> --version ^0.60.0
  2. cd <Project>
  3. yarn add rnpm-plugin-windows
  4. react-native windows
  5. react-native run-windows
 i Build configuration: Debug
 i Build platform: x86
Running MSBuild with args /clp:NoSummary;NoItemAndPropertyList;Verbosity=normal /nologo /p:Configuration=Debug /p:Platform=x86 /p:AppxBundle=Never /p:PlatformToolset=v141 /p:VisualStudioVersion=15.0 /bl
 × Building Solution: Utilisation�:          100,0    Utilisation moyenne�: 100,0...
 × Build failed with message undefined. Check your build configuration.

Same problem here.

Same issue as @Kiyozz here, why is this closed when so many people report the same problem?

Same

* SDK Installed

* Node 10.15.1

* yarn 1.22.0


1. `react-native init <Project> --version ^0.60.0`

2. `cd <Project>`

3. `yarn add rnpm-plugin-windows`

4. `react-native windows`

5. `react-native run-windows`
 i Build configuration: Debug
 i Build platform: x86
Running MSBuild with args /clp:NoSummary;NoItemAndPropertyList;Verbosity=normal /nologo /p:Configuration=Debug /p:Platform=x86 /p:AppxBundle=Never /p:PlatformToolset=v141 /p:VisualStudioVersion=15.0 /bl
 × Building Solution: Utilisation�:          100,0    Utilisation moyenne�: 100,0...
 × Build failed with message undefined. Check your build configuration.

I am facing exact same issue.

Same issue as everyone else.

$ react-native run-windows --logging i Verbose: ON √ Found NuGet Binary Searching for MSBuild version 16.0 Searching for MSBuild version 15.0 Searching for MSBuild version 14.0 Searching for MSBuild version 12.0 Searching for MSBuild version 4.0 × Failed to restore the NuGet packages: Error: MSBuild tools not found. Make sure all required components have been installed (e.g. v141

Same here, with both stable and beta. I've added MSBuild to the path in the environment variables, but it doesn't solve the problem. I've also installed the v141 tools via VS2019, no luck there as well.

 √ Found NuGet Binary
 × Failed to restore the NuGet packages: Error: MSBuild tools not found. Make sure all required components have been installed (e.g. v141 support)

OK, solved for me. I had forgotten this point in the system requirements:

Enable the optional C++ (v141) Universal Windows Platform tools

This option is not available in the individual components of the Visual Studio Installer, but sort of hidden on the right side under Installation details -> Universal Windows Platform development -> Optional.

Can someone with moderate rights just clean up irrelevant information? I followed each and every step - including the one above that says it solved for them - but no go so far.

Still running into the same problem:

√ Found NuGet Binary
Searching for MSBuild version 16.0
Searching for MSBuild version 15.0
Searching for MSBuild version 14.0
Searching for MSBuild version 12.0
Searching for MSBuild version 4.0
× Failed to restore the NuGet packages: Error: MSBuild tools not found. Make sure all required components have been installed (e.g. v141 support)

What is the magic sauce to get "npx react-native run-windows" to work? How can we expect people to keep troubleshooting - when all they want is to just run-windows and get on with their lives?

Can someone with moderate rights just clean up irrelevant information? I followed each and every step - including the one above that says it solved for them - but no go so far.

Still running into the same problem:

√ Found NuGet Binary
Searching for MSBuild version 16.0
Searching for MSBuild version 15.0
Searching for MSBuild version 14.0
Searching for MSBuild version 12.0
Searching for MSBuild version 4.0
× Failed to restore the NuGet packages: Error: MSBuild tools not found. Make sure all required components have been installed (e.g. v141 support)

What is the magic sauce to get "npx react-native run-windows" to work? How can we expect people to keep troubleshooting - when all they want is to just run-windows and get on with their lives?

@kotpal If you're seeing the prompt that we searched for version 16, 15, 14, etc. then you're running an older version of react-native, which won't have the fixes that we're talking about. My guess is that because you're running this with npx, you'll only pick up whatever latest official version of the package is made public to npmjs. So until we cut a new version and post it on npm, you won't see these fixes. If you need these fixes then the only way is to clone the RNW repo locally and use yarn/node instead of npx in the command line, since npx will just download the latest official version from npm.

I was able to find a solution to the following error:
× Failed to restore the NuGet packages: Error: MSBuild tools not found. Make sure all required components have been installed (e.g. v141 support)

I used @alariej 's solution but because it took me a while to find it I decided to do a step by step solution with pictures.

Open Visual Studio Installer and press Modify on your studio version

image

First make sure that Univeral Windows Platform development is enabled (of course)

image

Close Individual Components and open up the Universal Windows Platform development panel which is highlighted below

image

Enable the two highlighted options and press modify to update

image

Once complete

Once you complete this process you could be able to run

npx react-native run-windows

Hope this helped.

@uhteddy Thanks for the detail instructions. It works for me. Recommend update the docs about this.

I was able to find a solution to the following error:
× Failed to restore the NuGet packages: Error: MSBuild tools not found. Make sure all required components have been installed (e.g. v141 support)

I used @alariej 's solution but because it took me a while to find it I decided to do a step by step solution with pictures.

Open Visual Studio Installer and press Modify on your studio version

image

First make sure that Univeral Windows Platform development is enabled (of course)

image

Close Individual Components and open up the Universal Windows Platform development panel which is highlighted below

image

Enable the two highlighted options and press modify to update

image

Once complete

Once you complete this process you could be able to run

npx react-native run-windows

Hope this helped.

This worked for me, awesome, this should be in the docs...

THANK YOU @uhteddy .. I was on the Individual components tab and for some reason Universal v141 tools are not visible there, so I thought that... OK, old instructions... v142 it is...

image

Same issue here on 0.62.0 preview 7. I've installed C++ platform tools (v141 and v142) and nothing. Visual studio 2019 on board.

Command line output:

npx react-native run-windows --logging
 i Verbose: ON
 √ Found NuGet Binary
Using Nuget: C:\Users\adria\AppData\Local\Temp\nuget.4.9.2.exe
Searching for MSBuild version 16.0
Looking for vswhere at: C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe
Found vswhere.
VS path:
Looking for vswhere at: C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe
Found vswhere.
VS version:
Looking for MSBuilt at: MSBuild\Current\Bin\MSBuild.exe
 × Failed to restore the NuGet packages: Error: MSBuild tools not found. Make sure all required components have been installed

I make it work with linkstrifer’s solution, but before, I uninstall everything from Visual Studio Installer

FYI if you're using what's in master (or once we ship 0.62 :) ) you'll be able to run the script in \vnext\scripts\rnw-dependencies.ps1 to check or install dependencies

Same issue here on 0.62.0 preview 7. I've installed C++ platform tools (v141 and v142) and nothing. Visual studio 2019 on board.

Command line output:

npx react-native run-windows --logging
 i Verbose: ON
 √ Found NuGet Binary
Using Nuget: C:\Users\adria\AppData\Local\Temp\nuget.4.9.2.exe
Searching for MSBuild version 16.0
Looking for vswhere at: C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe
Found vswhere.
VS path:
Looking for vswhere at: C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe
Found vswhere.
VS version:
Looking for MSBuilt at: MSBuild\Current\Bin\MSBuild.exe
 × Failed to restore the NuGet packages: Error: MSBuild tools not found. Make sure all required components have been installed

Same/similar issue. With 0.62.0-preview.8 I am having #4954 which leads to this current issue.

  "dependencies": {
    "react": "16.11.0",
    "react-native": "^0.62.0-0",
    "react-native-windows": "^0.62.0-preview.8"
  },
  "devDependencies": {
    "@babel/core": "^7.6.2",
    "@babel/runtime": "^7.6.2",
    "@react-native-community/cli": "^4.9.0",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.9.0",
    "eslint": "^6.5.1",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "^0.58.0",
    "react-test-renderer": "16.11.0"
  }
>npx react-native run-windows --verbose --logging --info
 i Verbose: ON

  System:
    OS: Windows 10 10.0.18362
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 9.29 GB / 15.74 GB
  Binaries:
    Node: 12.9.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.5 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    @react-native-community/cli: ^4.9.0 => 4.9.0
    react: 16.11.0 => 16.11.0
    react-native: ^0.62.0-0 => 0.62.2
    react-native-windows: ^0.62.0-preview.8 => 0.62.0-preview.8
  Installed UWP SDKs:
    10.0.18362.0
>npx react-native run-windows
 √ Found NuGet Binary
 √ Found MSBuild v16.0 at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin (16.6.30114.105)
â ‹ Restoring NuGet packages C:\Users\USERNAME\AppData\Local\Temp\nuget.4.9.2.exe
 √ Restoring NuGet packages
 √ Found MSBuild v16.0 at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin (16.6.30114.105)
 √ Found Solution: C:/PATH-TO-PROJECT/windows/rn.sln
 i Build configuration: Debug
 i Build platform: x86
 × Building Solution: ReactImage.obj : fatal error LNK1103: debugging information corrupt; recompile module [C:\U...
 × Build failed with message ReactImage.obj : fatal error LNK1103: debugging information corrupt; recompile module [C:\PATH-TO-PROJECT\node_modules\react-native-windows\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj]. Check your build configuration.
See C:\Users\USERNAME\AppData\Local\Temp\msbuild_9900.err

PSA:

Looks like there are some reorganization, and the thing you need to select in the installer is now C++ Universal Windows Platform tools

In the latest package I needed to manually find and check MSBuild package.

Then it installed and stopped throwing the error.

And started throwing this new error after partial build:
ReactImage.obj : fatal error LNK1103: debugging information corrupt; recompile module

Should I open a new issue?

And started throwing this new error after partial build:
ReactImage.obj : fatal error LNK1103: debugging information corrupt; recompile module

Should I open a new issue?

@andraz-at :
This is a known issue with VS 16.6, it's not specific to RNW:
https://developercommunity.visualstudio.com/content/problem/1042212/vs-166-compilation-fails-after-update.html

And started throwing this new error after partial build:
ReactImage.obj : fatal error LNK1103: debugging information corrupt; recompile module
Should I open a new issue?

@andraz-at :
This is a known issue with VS 16.6, it's not specific to RNW:
https://developercommunity.visualstudio.com/content/problem/1042212/vs-166-compilation-fails-after-update.html

so downgrade would be help?

And started throwing this new error after partial build:
ReactImage.obj : fatal error LNK1103: debugging information corrupt; recompile module
Should I open a new issue?

@andraz-at :
This is a known issue with VS 16.6, it's not specific to RNW:
https://developercommunity.visualstudio.com/content/problem/1042212/vs-166-compilation-fails-after-update.html

so downgrade would be help?

@longmans yes the options are to do one of the following:

  • downgrading to 16.5 would work (although 16.5 has a different bug regarding signing certificates for all UWP apps, which we've worked around - see #4958), or
  • use RNW from master which has a workaround we've added (#4962), or
  • we're going to be backport the workaround to 0.62 (and maybe 0.61 too?), or
  • cherry-pick the fix to #4962 to your own fork if you're in a hurry.

Same

  • SDK Installed
  • Node 10.15.1
  • yarn 1.22.0
  1. react-native init <Project> --version ^0.60.0
  2. cd <Project>
  3. yarn add rnpm-plugin-windows
  4. react-native windows
  5. react-native run-windows
 i Build configuration: Debug
 i Build platform: x86
Running MSBuild with args /clp:NoSummary;NoItemAndPropertyList;Verbosity=normal /nologo /p:Configuration=Debug /p:Platform=x86 /p:AppxBundle=Never /p:PlatformToolset=v141 /p:VisualStudioVersion=15.0 /bl
 × Building Solution: Utilisation�:          100,0    Utilisation moyenne�: 100,0...
 × Build failed with message undefined. Check your build configuration.

Same issue.

  • Node 12.18.0
  • yarn: 1.22.0
  • Build platform: x86
  • MSBuild Version: 16.0

Errors in --logging mode:

  1. error : Failed to open certificate(translate from russian): projectname_TemporaryKey.pfx.
  2. error : Required object not found(translate from russian) [C:\Users\username\testrn\projectname\windows\projectname\projectname.vcxproj].

Same

  • SDK Installed
  • Node 10.15.1
  • yarn 1.22.0
  1. react-native init <Project> --version ^0.60.0
  2. cd <Project>
  3. yarn add rnpm-plugin-windows
  4. react-native windows
  5. react-native run-windows
 i Build configuration: Debug
 i Build platform: x86
Running MSBuild with args /clp:NoSummary;NoItemAndPropertyList;Verbosity=normal /nologo /p:Configuration=Debug /p:Platform=x86 /p:AppxBundle=Never /p:PlatformToolset=v141 /p:VisualStudioVersion=15.0 /bl
 × Building Solution: Utilisation�:          100,0    Utilisation moyenne�: 100,0...
 × Build failed with message undefined. Check your build configuration.

Same issue.

  • Node 12.18.0
  • yarn: 1.22.0
  • Build platform: x86
  • MSBuild Version: 16.0

Errors in --logging mode:

  1. error : Failed to open certificate(translate from russian): projectname_TemporaryKey.pfx.
  2. error : Required object not found(translate from russian) [C:\Users\username\testrn\projectname\windows\projectname\projectname.vcxproj].

@Alkanores
Looks like you're running VS2019 against an old version of RNW (0.60). Can you upgrade to RNW 0.62? Or alternatively, use VS2017 if you need to stick with RNW 0.60

@asklar
How can I check RNW version?

@Alkanores it's in the command line you provided above: react-native init <Project> --version ^0.60.0
It should also be in your package.json in your project.

@asklar
This fields in my package.json:
"react-native": "0.61.5",
"react-native-windows": "^0.61.0-0"

@Alkanores I'm pretty sure you're running into a regression that was introduced into Visual Studio in version 16.5 and is present in 16.6 still.

Can you confirm what version of VS you're on?

"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version 16 -property catalog_productDisplayVersion

I added a workaround for the time being and backported it to 0.61 here, but it may not yet be available for you to consume. See #5100 . @NickGerleman can answer how/when this will be available for 0.61

@asklar
C:\Users\redfo>"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version 16 -property catalog_productDisplayVersion
16.5.2

@asklar
I need to create RN project with version 0.61(not 0.61.5) to fix this error, right?

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\ram> cd .\my-app\
PS C:\Users\ram\my-app> npx react-native run-windows --logging
 i Verbose: ON
 √ Found NuGet Binary
Using Nuget: C:\Users\ram\AppData\Local\Temp\nuget.4.9.2.exe
Searching for MSBuild version 16.0
Looking for vswhere at: C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe
Found vswhere.
VS path:
Looking for vswhere at: C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe
Found vswhere.
VS version:
Looking for MSBuilt at: MSBuild\Current\Bin\MSBuild.exe
 × Failed to restore the NuGet packages: Error: MSBuild tools not found. Make sure all required components have been installed
PS C:\Users\ram\my-app>

vs_installershell_meRYtaMhey

I have installed both VS19 and VS17 on Windows 10 (Version 1903), I am still getting the same error message "Looking for MSBuilt at: MSBuild\Current\Bin\MSBuild.exe
× Failed to restore the NuGet packages: Error: MSBuild tools not found. Make sure all required components have been installed". Please guide me to resolve it!

Hey guys - this thread is getting a little long, could you file new issues so we know we're looking at the right things? thanks.

thank you @uhteddy for your detailed post, it works for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

syedibrahimt picture syedibrahimt  Â·  3Comments

namrog84 picture namrog84  Â·  4Comments

datkinson picture datkinson  Â·  3Comments

shoaib picture shoaib  Â·  3Comments

dubiao picture dubiao  Â·  3Comments