You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装.NET及Power Apps CLI后执行pac pcf init命令报错求助

Power Apps CLI (pac) 报错:找不到.NET运行时的解决建议

我按照微软教程创建首个Power Apps组件框架(PCF)组件,已安装.NET SDK 8.0.203、.NET Runtime 8.0.3,全局安装了Power Apps CLI,但运行以下命令时:
pac pcf init --namespace SampleNamespace --name LinearInputControl --template field --run-npm-install

出现错误:

You must install .NET to run this application.

App: /Users/xyz/.dotnet/tools/pac
Architecture: x64
App host version: 8.0.3
.NET location: Not found

Learn more:
https://aka.ms/dotnet/app-launch-failed

Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=osx-x64&os=osx.14&apphost_version=8.0.3


当前环境信息

我的.NET版本:
dotnet --version

8.0.203

详细环境信息:
dotnet --info

.NET SDK:
 Version:           8.0.203
 Commit:            5e1ceea679
 Workload version:  8.0.200-manifests.4e94be9c

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  14.4
 OS Platform: Darwin
 RID:         osx-x64
 Base Path:   /usr/local/share/dotnet/sdk/8.0.203/

.NET workloads installed:
There are no installed workloads to display.

Host:
  Version:      8.0.3
  Architecture: x64
  Commit:       9f4b1f5d66

.NET SDKs installed:
  8.0.203 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_ROOT       [/Users/xyz/dotnet]

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

PATH已包含路径:

:/Users/xyz/dotnet:/Users/xyz/.dotnet/tools

解决建议

  • 修正DOTNET_ROOT环境变量:从dotnet --info可见,实际.NET安装路径为/usr/local/share/dotnet,但当前DOTNET_ROOT指向/Users/xyz/dotnet,路径不匹配导致pac无法找到.NET。执行以下命令临时修正(重启终端后生效):

    export DOTNET_ROOT=/usr/local/share/dotnet
    

    若需永久生效,编辑~/.zshrc或~/.bash_profile(根据使用的Shell类型),添加上述export命令后执行source ~/.zshrc(或对应配置文件)。

  • 重新安装Power Apps CLI:先卸载现有pac工具,再重新安装,确保工具与当前.NET环境正确关联:

    dotnet tool uninstall -g Microsoft.PowerApps.CLI.Tool
    dotnet tool install -g Microsoft.PowerApps.CLI.Tool
    
  • 调整PATH优先级:确保/usr/local/share/dotnet在PATH中,且优先级高于其他可能的.NET路径。执行echo $PATH检查,若未包含则添加:

    export PATH="/usr/local/share/dotnet:$PATH"
    

    同样可写入Shell配置文件实现永久生效。

  • 验证架构匹配:确认pac工具与.NET均为x64架构(当前环境已显示一致,此步可快速排除架构不兼容问题)。


内容的提问来源于stack exchange,提问作者R.R

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 12:51:00