.net - 启动新的 react-native 项目时找不到 .Net 核心
问题描述
我按照本教程为 windows 项目创建了新的 react-native 。我在 VS Code 中工作,但是要运行该应用程序,我必须安装 Visual Studio Community,否则它在启动时给了我错误:
error Unable to find vswhere
在我使用本教程中的所有选项安装 Visual Studio 后,错误变为:
Failed to restore the NuGet packages: Error:
C:\Users\Alyona\Documents\Programming\accounting_app\node_modules\react-native-
windows\Microsoft.ReactNative.Managed.CodeGen\Microsoft.ReactNative.Managed.CodeGen.csproj : error :
Unable to locate the .NET Core SDK. Check that it is installed and that the version specified in
global.json (if any) matches the installed version.
我尝试寻找解决方案,推荐的是这个。所以我检查了我的命令行。运行dotnet --list-sdks
后只有一个版本:
3.1.402 [C:\Program Files\dotnet\sdk]
global.json
我在我的项目中使用以下文本创建了文件:
{
"sdk": {
"version": "3.1.402"
}
}
但是在我运行npx react-native run-windows
命令后,出现以下错误:
Failed to restore the NuGet packages: Error:
C:\Users\Alyona\Documents\Programming\accounting_app\node_modules\react-native-
windows\Microsoft.ReactNative.Managed.CodeGen\Microsoft.ReactNative.Managed.CodeGen.csproj : error :
Unable to locate the .NET Core SDK. Check that it is installed and that the version specified in
global.json (if any) matches the installed version.
C:\Users\Alyona\Documents\Programming\accounting_app\node_modules\react-native-
windows\Microsoft.ReactNative.Managed.CodeGen\Microsoft.ReactNative.Managed.CodeGen.csproj : error
MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found.
A compatible installed .NET Core SDK for global.json version [3.1.402] from
[C:\Users\Alyona\Documents\Programming\accounting_app\global.json] was not found
解决方案
请改为在https://github.com/microsoft/react-native-windows上发帖:)
RNW 不支持 .net 核心。对于托管 rnw 应用,仅支持“用于 UWP 应用的 .net 框架”。为确保您安装了它,请遵循文档的入门页面中描述的 rnw-dependencies 脚本。
更新:我重新阅读了你的问题,我现在更好地理解了。这是特定于 codegen 项目的,这可能是我们的错误。我已经提交了一个问题让我们跟踪它:https ://github.com/microsoft/react-native-windows/issues/6201
推荐阅读
- python - 在Python中按特定顺序对x轴进行分组条形图排序
- c# - 用于 Unity 对话系统目的的 XML 解析具有属性的嵌套对象
- couchbase - 我如何以最佳方式执行此 N1QL SELECT 查询?
- wordpress - Wordpress 插件服务页面
- kotlin - 从 Intellij 运行时,Micronaut Kotlin 测试不起作用
- google-app-engine - 应用引擎或计算引擎 - 我可以同时使用 SSL
- python - 使用异步信号量进行数据库会话
- java - 找出哪个类/实例持有对打开文件的引用
- django - formset_factory 是否继承了它扩展的表单的清理/验证方法?
- javascript - 如果我已经保存了更改,我应该如何在返回时避免未保存更改的“警报”?