Azure DevOps经典构建管道无法访问跨项目仓库项目
问题:Azure DevOps构建管道无法访问同一组织下其他仓库的项目引用
我的项目「WinningsAPI」引用了同一Azure DevOps组织下另一项目「Winnings」仓库中的项目,本地Visual Studio 2022运行正常,但用经典编辑器创建的构建管道构建WinningsAPI时,出现以下错误:
##[error]D:\a\1\s\WinningsAPI.sln.metaproj(0,0): Error MSB3202: The project file "D:\a\1\Winnings\Winnings.CoreData\Winnings.CoreData.csproj" was not found.
已将Winnings仓库的安全设置为允许组织内所有人读取,也为构建管道配置了读取权限,但问题仍未解决。完整构建报告如下:
Starting: Build solution ============================================================================== Task : Visual Studio build Description : Build with MSBuild and set the Visual Studio version property Version : 1.214.0 Author : Microsoft Corporation Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/visual-studio-build ============================================================================== "D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.214.0\node_modules\azure-pipelines-tasks-msbuildhelpers\tools\vswhere.exe" -version [17.0,18.0) -latest -format json "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\msbuild.exe" "D:\a\1\s\WinningsAPI.sln" /nologo /nr:false /dl:CentralLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.214.0\node_modules\azure-pipelines-tasks-msbuildhelpers\tools\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=289fdd5e-8a3a-4f93-b828-4d1258871307|SolutionDir=D:\a\1\s|enableOrphanedProjectsLogs=true"*ForwardingLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.214.0\node_modules\azure-pipelines-tasks-msbuildhelpers\tools\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="D:\a\1\a\\" /p:platform="any cpu" /p:configuration="release" /p:VisualStudioVersion="17.0" /p:_MSDeployUserAgent="VSTS_bbd45d84-e1e3-43e0-afab-c6da9b77da75_build_13_0" Build started 9/6/2023 6:43:26 PM. Project "D:\a\1\s\WinningsAPI.sln" on node 1 (default targets). ValidateSolutionConfiguration: Building solution configuration "release|any cpu". ##[error]D:\a\1\s\WinningsAPI.sln.metaproj(0,0): Error MSB3202: The project file "D:\a\1\Winnings\Winnings.CoreData\Winnings.CoreData.csproj" was not found. D:\a\1\s\WinningsAPI.sln.metaproj : error MSB3202: The project file "D:\a\1\Winnings\Winnings.CoreData\Winnings.CoreData.csproj" was not found. [D:\a\1\s\WinningsAPI.sln] ##[error]D:\a\1\s\WinningsAPI.sln.metaproj(0,0): Error MSB3202: The project file "D:\a\1\Winnings\WinningsDataAccess\WinningsDataAccess.csproj" was not found. D:\a\1\s\WinningsAPI.sln.metaproj : error MSB3202: The project file "D:\a\1\Winnings\WinningsDataAccess\WinningsDataAccess.csproj" was not found. [D:\a\1\s\WinningsAPI.sln] Project "D:\a\1\s\WinningsAPI.sln" (1) is building "D:\a\1\s\WinningsAPI.csproj" (2) on node 1 (default targets).
解决步骤
1. 添加额外仓库的拉取步骤
构建管道默认仅拉取当前项目仓库代码,需手动添加「Winnings」仓库的拉取配置:
- 打开经典编辑器的构建管道,找到「Get sources」步骤(没有则添加)
- 点击「Add repository」,选择「Winnings」仓库
- 设置拉取路径为
$(Build.SourcesDirectory)/Winnings,保证目录结构和本地一致,让MSBuild能找到对应项目文件
2. 修改解决方案中的项目引用路径
检查本地WinningsAPI.sln文件的项目引用路径,确保为相对路径而非绝对路径:
- 用文本编辑器打开WinningsAPI.sln,找到类似如下的绝对路径引用行:
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Winnings.CoreData", "D:\a\1\Winnings\Winnings.CoreData\Winnings.CoreData.csproj", "{GUID}" - 修改为相对路径,示例:
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Winnings.CoreData", "../Winnings/Winnings.CoreData/Winnings.CoreData.csproj", "{GUID}" - 保存修改并提交到仓库,重新运行构建
3. 验证构建服务账号的项目级别权限
除仓库读取权限外,需确保构建管道使用的服务账号(通常为「Project Collection Build Service ({组织名})」)在「Winnings」项目级别拥有读取权限:
- 进入Winnings项目,点击「Project Settings」→「Permissions」→「Users」
- 找到对应构建服务账号,确认其拥有「Read」权限;若无则添加账号并赋予该权限
4. 检查VS Build任务的参数配置
在VS Build任务中,避免设置会覆盖默认路径的参数,比如不要手动修改SolutionDir参数,确保其使用默认的$(Build.SourcesDirectory)值
内容的提问来源于stack exchange,提问作者Dennis
相关产品推荐
相关产品推荐

