16
votes

how can I simulate the build process of Azure Devops pipeline on the local machine before pushing it to branch to test the possible errors.

the solution gets build locally correct with no errors and warnings. also from the VS command line MSBuild builds the solution with no errors but on some push tries the pipeline build throws many errors mostly related to preprocessor defenition and precompiled header.

I wanted to know how can test the same process locally on my machine without pushing to repo.

azure-pipelines.yml
-------------------
pool:
  vmImage: 'vs2017-win2016'

steps:
- task: MSBuild@1
  displayName: 'Build solution'
  inputs:
    platform: 'Win32'
    configuration: 'release'
    solution: 'mysolution.sln'
- task: VSTest@2
  displayName: 'Run Test'
  inputs:
    platform: 'Win32'
    Configuration: 'release'
    testAssemblyVer2: |
     **\*.Test.dll
     !**\*TestAdapter.dll
     !**\obj\**
    runSettingsFile: project.Test/test.runsettings
    codeCoverageEnabled: true 
3

3 Answers

7
votes

If you are using a git repsotiory you can create another branch and make a pull request. As long as the pull request is not set to auto complete the code will not get committed to the repository.

If you are using a TFVC respository you can setup a gated build that is configured to fail. The pipeline should be a copy of your original pipeline but add a PowerShell task at the end of the build pipeline that throws a terminating error. Be sure to setup this gated build on a separate branch so it does not block normal development.

Write-Error "Fail here" -ErrorAction 'Stop'

You can now make pull requests or trigger a gated build without the code actually being commited.

You can use AzurePipelinesPS to install an agent on your local machine with the Install-APAgent command if you need another agent.

0
votes

I'm only a few hours into to development with Azure, but I think I found a solution that would work for you. I happen to already have the solution in place. Use gradle, then the default YML just runs gradle and you don't have to worry too much about it after the first run. In the gradle file you could also spin up a docker image if you want and build on that.

0
votes

The issue you have is most likely related to the difference between your local environment and the one on build agent where this YAML pipeline execute the build. Testing it locally (even if it would be possible) will not help as it will be executed in your environment, where you know already that every component required for the successful build are already installed. On the other side on the environment where build agent is running the build there seems to be missed components (or different versions) which cause your build to fail. Try to compare list of installed components and environment variables (like PATH) on your local machine and on build agent - there might be some difference between them.