Azure DevOps Pipeline 上的 .Net Framework 4.8 应用程序生成错误

问题描述 投票:0回答:1

我有一个 .Net Framework 4.8 应用程序,解决方案中有多个项目。 主项目 (.csproj) - “项目 A”的调试和发布配置的平台目标为“x86”,而其他项目的调试和发布配置的平台目标为“任何 CPU”。解决方案构建(编译)在 Visual Studio 中很好,但是当我尝试使用 VSBuild@1 任务创建和运行 YAML 构建管道时,它失败并出现错误。这些错误是由以“项目 A”作为引用的测试项目引发的,抛出错误就像未添加“项目 A”作为引用一样。但添加了项目 A 作为测试项目的参考。

顺便说一句,我对 YAML 管道不熟悉,但我相信 YAML 管道非常适合 .net 应用程序。

抛出的错误都是以下类型: 错误 CS0234:命名空间“xx.xx.xx.ProjectA”中不存在类型或命名空间名称“MessageHandler”(是否缺少程序集引用?) “Build-Windows”是一个 Windows 自托管代理,它是 Windows Server 2019 操作系统。我已经尝试了很多方法来解决,但没有运气。我缺少什么?任何帮助将非常感激! 我的 YAML 管道如下所示:

trigger:
- none
 
variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'
 
pool: Build-Windows
 
steps:
- task: NuGetToolInstaller@1
  displayName: ⬇ NuGet - Install
  inputs:
    versionSpec: 
    checkLatest: true
 
- task: NuGetCommand@2
  displayName: 🔄 NuGet - Restore
  inputs:
    command: 'restore'
    restoreSolution: '$(solution)'
    feedsToUse: 'config'
    nugetConfigPath: NuGet.Config
 
 
- task: VSBuild@1
  displayName: 🏗 Build 
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:OutDir=$(Build.ArtifactStagingDirectory)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
    clean: true
 
 
- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
 
- task: PublishBuildArtifacts@1
  displayName: ⬆ Publish Artifacts
  inputs:
    ArtifactName: Package
    TargetPath: $(Build.ArtifactStagingDirectory)

我尝试更改目标平台并多次更改 YAML 构建管道,但没有成功。

.net compilation azure-yaml-pipelines
1个回答
0
投票

可能会出现一些问题。 “干净”的构建机器环境可能会导致您在本地机器上看不到的问题。

检查您的构建配置:

并在项目处于

Any CPU
配置下时查看 x86 是否正在构建。

如果不是,那么可能发生的情况是您在某个时刻构建了

x86
并且构建
Any CPU
平台正在使用之前构建的版本。您在管道中需要做的是确保首先构建
x86
版本,然后构建
Any CPU
版本。

© www.soinside.com 2019 - 2024. All rights reserved.