Azure Pipelines VSBuild 配置无效

标签 azure azure-pipelines-build-task azure-pipelines-yaml sln-file

我是 Azure 新手,我继承了由不再在公司工作的其他人构建的管道。它在很多方面都被破坏了,所以我试图在我收到的原始损坏的基础上构建一个新的。我一次执行一个命令来解决问题。目前以下任务失败:

- task: VSBuild@1
    displayName: Build Solution
    inputs:
      solution: $(BuildParameters.solution)
      msbuildArgs: /p:DeployOnBuild=true /p:WebPublishingMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\$(BuildConfiguration)\\"
      platform: $(BuildPlatform)
      configuration: $(BuildConfiguration)

我研究了其他类似的堆栈溢出帖子,但仍然无法弄清楚问题是什么。我收到的警告是这样的:

Warning MSB4126: The specified solution configuration "$(BuildConfiguration)|$(BuildPlatform)" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration.

这是我迄今为止尝试过的:

  1. 我尝试删除平台和配置设置(上面第一个引用的代码的最后两行)。这导致了 54 条其他警告,因此这似乎是一个坏主意。

  2. 接下来,我将这两行放回已删除的位置,而是添加了以下内容:/p:Configuration=Debug/p:Platform="Any CPU"到列出的参数字符串的最开头msbuildArgs 设置。这消除了 54 个新警告并恢复了原来的错误(换句话说,它没有任何效果)

还有另一个堆栈溢出问题:TFS Build error MSB4126 (solution configuration is invalid) how to fix似乎有一个解决方案,但我不知道如何实际应用这个解决方案。该票证中有一个 Azure UI 的屏幕截图,我什至不知道如何访问 Azure 的该页面来查看这些选项。我的猜测是,这个人没有使用 yaml 文件来设置管道并以旧的方式进行操作,但我不想以这种方式配置它,因为我更希望让 yaml 文件定义管道并存储它在我的 git 存储库中。

注意:我也一直在查看与该项目相关的 sln 文件,试图理解它,我想我不确定该文件的基本概念...

任何建议都会有所帮助,谢谢

最佳答案

看起来有两个变量未定义:

$(BuildConfiguration)
$(BuildPlatform)

确保变量已在管道 yaml 中或变量选项卡上定义。

参见:

将值设置为对解决方案有意义的值。我们无法猜测这些值,因为它们通常特定于正在构建的解决方案。

关于Azure Pipelines VSBuild 配置无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66265328/

相关文章:

azure-devops - 在构建任务中强制执行 PowerShell

linux - 如何在vsts在线构建任务中在linux上安装azCopy?

Azure - 创建 bool 变量并在多个任务中使用它

azure-devops - 如何将 Azure Pipelines YAML 批量转换为 Github Actions YAML?

azure - 使用 Azure PowerShell 分配 AD 角色

azure - 使用 Terraform 为 Azure 存储帐户启用版本级不变性支持

azure - auto-ml-forecasting-many-models 检索训练结果

azure - 如何以编程方式向外部用户授予对 azure 资源组的访问权限

asp.net-mvc - 发布到Azure并启动应用程序后,表没有自动生成?