启动新的本机项目时找不到.Net核心

问题描述

我按照this教程为Windows项目创建了新的react-native。 我使用VS Code工作,但要运行该应用程序,必须安装Visual Studio Community,否则启动时会出现错误:

error Unable to find vswhere

使用this tutorial中的所有选项安装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.

我尝试搜索解决方案,推荐的解决方案是this。 所以我检查了我的命令行。运行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

即使dotnet --list-sdks工作正常,我也无法理解为什么找不到它?这是我的项目的屏幕截图:

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)