You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native Windows(C#)项目构建失败求助

解决React Native Windows项目构建错误(MSB3073/退出码9009)
  • 检查CodeGen工具路径是否存在
    找到项目里Microsoft.ReactNative.Managed.CodeGen.exe的引用路径,确认这个文件确实在对应位置。一般这个工具会跟着react-native-windows包装在node_modules\@react-native-windows\cli\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\bin\Release\net6.0目录下,手动看看文件有没有丢。

  • 清理后重新生成项目

    1. 删除项目根目录的windows文件夹
    2. 重新跑初始化命令:npx react-native-windows-init --overwrite --language=cs
    3. 先执行npm install确保所有依赖装全,再运行npx react-native run-windows
  • 调整项目目标框架版本
    打开Windows项目的.csproj文件,确认目标框架是net6.0或更高版本(CodeGen工具依赖.NET 6+)。如果版本不够,把<TargetFramework>节点改成net6.0-windows10.0.19041.0(或兼容的高版本),保存后重新构建。

  • 临时添加CodeGen路径到环境变量
    把CodeGen工具所在的bin目录临时加到系统PATH里,重启命令行/PowerShell后再试运行。比如在PowerShell里执行:

    $env:Path += ";C:\你的项目绝对路径\node_modules\@react-native-windows\cli\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\bin\Release\net6.0"
    
  • 手动验证.NET运行时
    虽然你已经跑过依赖检查脚本,但还是手动确认下.NET 6.0 SDK和运行时是否完整。打开命令行执行dotnet --list-sdks和dotnet --list-runtimes,确保能看到net6.0相关的条目。

内容的提问来源于stack exchange,提问作者Mr. Schrödinger

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 21:52:40