如何解决启动新的本机项目时找不到.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
工作正常,我也无法理解为什么找不到它?这是我的项目的屏幕截图:
解决方法
请改为在https://github.com/microsoft/react-native-windows上发布:)
RNW不支持.net核心。对于托管rnw应用程序,仅支持“用于UWP应用程序的.net框架”。为了确保您已安装它,请按照文档入门页面中所述的rnw-dependencies脚本进行操作。
更新:我重新阅读了您的问题,现在我对它的理解更好了。这是特定于codegen项目的,这可能是我们的错误。我已提了一个问题供我们跟踪:https://github.com/microsoft/react-native-windows/issues/6201
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。