生成失败,出现错误MSB4226:导入的项目|反应本地窗口

时间:2019-05-10 02:24:08

标签: reactjs windows native

Visual Studio 2017和我已经安装了所有必需的构建工具。但是当我运行react-native运行窗口时。它显示错误,如下面的代码

C:\native\myapp>react-native run-windows
Restoring NuGet packages
Building C:/native/myapp/windows/com.tet.windows.sln
Found MSBuild v15.0 at C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin
Building Solution: C:/native/myapp/windows/com.tet.windows.sln
Build configuration: Debug
Build platform: x86
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\native\myapp\windows\com.tet.windows\com.tet.windows.csproj(171,11): error MSB4226: The imported project "C:\Program
 Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\WindowsXaml\v15.0\Microsoft.Windows.UI.Xaml.CSha
rp.targets" was not found. Also, tried to find "Microsoft\WindowsXaml\v15.0\Microsoft.Windows.UI.Xaml.CSharp.targets" i
n the fallback search path(s) for $(MSBuildExtensionsPath) - "C:\Program Files (x86)\MSBuild" . These search paths are
defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\msbuild.exe.Config". Confir
m that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Current.targets(1
08,3): error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\
VC\VCTargets\Platforms\Win32\Platform.targets" was not found. Confirm that the path in the <Import> declaration is corr
ect, and that the file exists on disk. [C:\native\myapp\node_modules\react-native-windows\Folly\Folly.vcxproj]
Build failed with message Error: Command failed: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" "C:/native/myapp/windows/com.tet.windows.sln" /clp:NoSummary;NoItemAndPropertyList;Verbosity=quiet /nologo /p:Configuration=Debug /p:Platform=x86 /p:AppxBundle=Never /p:PlatformToolset=v141 /p:VisualStudioVersion=15.0. Check your build configuration.

1 个答案:

答案 0 :(得分:0)

由于开始使用VS 2019,我也遇到了类似的问题。它只说到了该文件:

__attribute__((fallthrough))

打开它,然后找到此节点中的内容:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\msbuild.exe.Config

更改该值以准确导航MSBuild当前所在的位置。就我而言,更改为:

<projectImportSearchPaths>
      <searchPaths os="windows">

值: Microsoft Visual Studio \ 2019 \ Enterprise \ MSBuild \ Microsoft \ VisualStudio

希望有帮助。