1

I have built a simple pipeline to build my solution triggered by commits to the master branch using the Azure DevOps Pipelines. I have a problem with the post build copy commands failing and returning errors

my post build copy command:

copy /Y "$(TargetDir)$(TargetFileName)" "$(MY_PATH)$(TargetFileName)"

I get the following errors:

PostBuildEvent:
  copy /Y "D:\a\1\s\{some_path\file.dll}" "D:\a\1\s\BuildBin\{file.dll}"    
The system cannot find the path specified.
              0 file(s) copied.

the MY_PATH environmental variable is defined in the pipeline variables and using a "CmdLine" echo %MY_PATH% in the .yaml it echos the proper path in the console:

    Starting: CmdLine
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.177.3
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
echo %MY_PATH%
========================== Starting Command Output ===========================
"C:\windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "D:\a\_temp\1db7603c-e3c0-4e32-924f-c5b1fc2cf96e.cmd""
D:\a\1\s\BuildBin\
Finishing: CmdLine

I have defined the MY_PATH to be D:\a\1\s\BuildBin\ as I witnessed that this is the solution folder, the paths in the error are correct.

Also I have tried running a script to create the BuildBin folder as I thought the folder does not exists but its not the reason as I run the following in the .yaml:

steps:
- script: echo mkdir D:\a\1\s\BuildBin

I cant find any info on the topic any where, just this StackOverflow question and it was not helpful.

I'm running the job in Windows Windows Server 2019 environment. Needless to say the solution builds on my pc with no problems, it also builds fine in the pipeline, its just the copy that fails.

1 Answer 1

2

I had the same problem and fixed it with this solution:

  • for the pipeline yaml I added an additional param, could be any random name, I choose "AzureBuild" and set it to true:

enter image description here

  • for the *.csproj file I added a Condition to Exec with that defined param in mind:

enter image description here

Now this post build events are only fired for local builds and not on Azure DevOps builds.

1
  • took me a year, because stackExchange does not list this as my question for some reason, but it solved my problem, thanks !
    – Shubaka
    Commented May 10, 2022 at 8:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.