简体   繁体   English

启动新的 react-native 项目时找不到 .Net 核心

[英]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.

相关问题 使用angularjs模板启动新项目时出现.Net Core System.Net.Http.HttpRequestException异常 - .Net Core System.Net.Http.HttpRequestException exception while starting a new project using angularjs template 为什么我的本机 .DLL 项目找不到我的 .NET .dll? - Why can't my native .DLL project find my .NET .dll? .NET Core API 调用 .NET 项目中的方法表示在 app.config 文件中找不到连接字符串 - .NET Core API call to a method in a .NET Project is saying it can't find Connection strings in the app.config file .NET 4.7.1项目不能使用.NET Core 2.0库 - .NET 4.7.1 project can't use .NET Core 2.0 library React Native API 调用 .NET 核心后端仅在启用 React Native 调试器网络检查时工作 - React Native API Calls to .NET Core backend only work when React Native Debugger Network Inspect Enabled 无法添加项目.net core 2参考,但可以添加dll .net core 2参考 - Can't add a project .net core 2 reference but can add a dll .net core 2 reference 无法发布适用于linux-64的.NET Core项目 - Can't publish .NET Core project for linux-64 无法添加xunit测试项目.NET Core - Can't add xunit test project .NET Core Visual Studio找不到.NET Core SDK? - Visual Studio can't find .NET Core SDK? 在ASP.NET Core中找不到ClientAssertionCertificate - Can't find ClientAssertionCertificate in ASP.NET Core
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM