Kevin
Kevin

Reputation: 348

Azure Devops SelfHosted Agent MSBuild post build launching exe from incorrect path

We are setting up CI via Azure Dev Ops pipelines. As a proof of concept I am using the VSBuild step on a self hosted build agent. I hoped this would most closely mirror how we are currently building our applications.

This is my simple pipeline, created using the UI pipeline editor. pipeline

My solution requires a post build event. This post build event invokes MSBuild.exe and passes it an MSBuild project file in xml format -- just a bunch of parameters to pass through to the assembly that MSBuild then launches.

If I remove all of our pre and post build scripts, my agent builds and publishes flawlessly. In attempting to add our postbuild script, in the Build solution step I received this error:

Error MSB6004: The specified task executable location "C:\Program Files\postBuildApplication\postBuildApplication.exe" is invalid

Here is the devops build log: devops build log

I included the "CopyingFilesToOutputDirectory..." to illustrate that the solution builds, but then DevOps shows the task, and then job, failing because the post build fails.

I verified the path to msbuild.exe is the same as when I build locally in visual studio. And the file path parameter passed to MSBuild is the correct file.

Here is a snippet of the script file being run by MSBuild: script snippet

Building locally in VS with either the assemblyname or the assemblyfile parameter works. But in both cases I get the same error in my Dev Ops build agent.

I have verified the postBuild.exe is installed correctly. The registry contains the correct values, and my environment Path variables are set correctly.

I have ensured the user the Agent runs on has sufficient file access to the directory of the post build.exe

Ultimately, my questions are: Why is my build agent attempting to load this exe from the wrong path? Do I need to fix the configuration of my build agent in some way? Am I missing something for the user that was created when I made the build agent?

To recap:

I verified the path to msbuild.exe is the same as when I build locally in visual studio. And the file path parameter passed to MSBuild is the correct file.

I have verified the postBuild.exe is installed correctly. The registry contains the correct values, and my environment Path variables are set correctly.

I have ensured the user the Agent runs on has sufficient file access to the directory of the post build.exe

Building locally in VS with either the assemblyname or the assemblyfile parameter works. But in both cases I get the same error in my Dev Ops build agent.

All of my user agent capabilities are defaults, but I have verified all the paths are correct. I also tried adding a capability for my postbuild.exe and postbuild.build.dll.

Body of the yaml for my pipeline:

  pool:
  name: LocalBuildAgent
  demands:
  - msbuild
  - visualstudio

variables:
  solution: '**\*.sln'

steps:
- task: VSBuild@1
  displayName: 'Build solution **\*.sln'
  inputs:
    solution: '$(Parameters.solution)'
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'
    clean: true
    restoreNugetPackages: true
    msbuildArchitecture: x64
    logProjectEvents: false
    createLogFile: true
    logFileVerbosity: diagnostic

- task: PublishSymbols@2
  displayName: 'Publish symbols path'
  inputs:
    SearchPattern: '**\bin\**\*.pdb'
    PublishSymbols: false

- task: CopyFiles@2
  displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
  inputs:
    SourceFolder: '$(system.defaultworkingdirectory)'
    Contents: '**\bin\$(BuildConfiguration)\**'
    TargetFolder: '$(build.artifactstagingdirectory)'
    CleanTargetFolder: true

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'

Upvotes: 0

Views: 77

Answers (0)

Related Questions