[英]Can't find .Net core when starting a new react-native project
I created new react-native for windows project following this tutorial.我按照本教程为 Windows 项目创建了新的 react-native。 I work in VS Code, but for the app to run I had to install Visual Studio Community, otherwise it gave me error on start:我在 VS Code 中工作,但要运行该应用程序,我必须安装 Visual Studio Community,否则它在启动时出现错误:
error Unable to find vswhere
After I installed Visual Studio with all options from this tutorial , error changed to:使用本教程中的所有选项安装 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.
I tried searching for solutions, and the one that was recommended was this .我尝试寻找解决方案,推荐的就是这个。 So I checked my command line.所以我检查了我的命令行。 After running dotnet --list-sdks
there was just one version:运行dotnet --list-sdks
后只有一个版本:
3.1.402 [C:\Program Files\dotnet\sdk]
I created global.json
file in my project with following text:我在我的项目中创建了global.json
文件,其中包含以下文本:
{
"sdk": {
"version": "3.1.402"
}
}
But after I ran npx react-native run-windows
command I got following error:但是在我运行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
I can't understand why it can't find it even though dotnet --list-sdks
works fine?我不明白为什么即使dotnet --list-sdks
工作正常也找不到它? Here's the screenshot of my project:这是我的项目的屏幕截图:
Please post on https://github.com/microsoft/react-native-windows instead :)请改为在https://github.com/microsoft/react-native-windows 上发帖:)
RNW doesn't support .net core. RNW 不支持 .net 核心。 For managed rnw apps, only the ".net framework for UWP apps" is supported.对于托管 rnw 应用,仅支持“.net 框架的 UWP 应用”。 To make sure you get it installed please follow the rnw-dependencies script that's described in the getting started page in the docs.为了确保您安装了它,请按照文档的入门页面中描述的 rnw-dependencies 脚本进行操作。
update: I re-read your question and I understand it better now.更新:我重新阅读了您的问题,现在我更好地理解了。 This is specific to the codegen project, this might be a bug on our end.这是特定于 codegen 项目的,这可能是我们这边的一个错误。 I've filed an issue for us to track it: https://github.com/microsoft/react-native-windows/issues/6201我已经提交了一个问题供我们跟踪: https : //github.com/microsoft/react-native-windows/issues/6201
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.