Azure DevOps Pipeline运行efbundle.exe报错:未设置DOTNET_BUNDLE_EXTRACT_BASE_DIR
解决Azure DevOps Pipeline中运行efbundle.exe的提取目录错误
问题描述
运行efbundle.exe时出现以下错误:
Failure processing application bundle. Failed to determine location for extracting embedded files. DOTNET_BUNDLE_EXTRACT_BASE_DIR is not set, and a read-write cache directory couldn't be created. ##[error]Bash exited with code '159'.
原因分析
.NET应用捆绑包(如efbundle.exe)需要可读写目录来提取嵌入式依赖文件。Azure DevOps Pipeline默认环境中,默认缓存目录无足够读写权限,且未指定DOTNET_BUNDLE_EXTRACT_BASE_DIR环境变量,导致无法创建提取目录。
解决方案
修改Pipeline的YAML脚本,手动设置DOTNET_BUNDLE_EXTRACT_BASE_DIR环境变量为Pipeline Agent的临时目录(该目录默认具备读写权限),再执行efbundle.exe:
修改后的YAML片段:
- stage: 'Deploy' jobs: - deployment: strategy: runOnce: deploy: steps: - bash: | export DOTNET_BUNDLE_EXTRACT_BASE_DIR=$(Agent.TempDirectory) chmod +x $(System.ArtifactsDirectory)/drop/efbundle.exe $(System.ArtifactsDirectory)/drop/efbundle.exe
关键说明
$(Agent.TempDirectory)是Azure DevOps Agent内置的临时目录,拥有完全读写权限,适合作为捆绑包的提取目录。- 通过
export命令设置环境变量,确保efbundle.exe运行时能读取到该配置。
内容的提问来源于stack exchange,提问作者Rosdi Kasim
相关产品推荐
相关产品推荐

