1

We have a build pipeline set up with a "Visual Studio Build" step. I just need it to copy one of the project files into the build folder before publishing it to our server. Trying to copy a .runsettings project file for unit testing. So far I've tried setting the file to "Copy to Output Directory" in its properties, I've tried using both copy and xcopy in the post-build event command line and tried a few different syntaxes for that in the xml csproj project file. Everything that seems to work fine locally, doesn't do anything through azure. My brain has been wracked thoroughly!

Any help would be greatly appreciated!

Edit: This is what the copy settings look like: enter image description here

I tried this as well as ***.runsettings in contents as suggested.

Here is the log from my last copy attempt

2020-05-29T20:07:01.3481827Z ##[section]Starting: Copy .runsettings to: E:\Backend_work\116\a 2020-05-29T20:07:01.3669241Z ============================================================================== 2020-05-29T20:07:01.3669530Z Task : Copy files 2020-05-29T20:07:01.3669781Z Description : Copy files from a source folder to a target folder using patterns matching file paths (not folder paths) 2020-05-29T20:07:01.3670032Z Version : 2.164.1 2020-05-29T20:07:01.3670179Z Author : Microsoft Corporation 2020-05-29T20:07:01.3670406Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/copy-files 2020-05-29T20:07:01.3670656Z ============================================================================== 2020-05-29T20:07:01.9575993Z found 1 files 2020-05-29T20:07:01.9583367Z Copying E:\Backend_work\116\s\UnitTests.runsettings to E:\Backend_work\116\a.runsettings 2020-05-29T20:07:01.9674455Z ##[section]Finishing: Copy .runsettings to: E:\Backend_work\116\a

frostymm
  • 19
  • 1
  • 6
  • Do you get any error when you use post-build event in pipeline? Please check the build log to see whether there is any useful information. – Cece Dong - MSFT May 29 '20 at 02:22
  • copy E:\\_work\77\s\UnitTests\.runsettings E:\\_work\77\s\UnitTests\..\VerificationTool\bin\Release\ 1 file(s) copied. But the files just aren't there. After publishing the build artifacts, the built folder does not contain the file. – frostymm May 29 '20 at 15:42

1 Answers1

0

I've tested with the following post-build event command line and it copied the file in pipeline as expected:

copy "$(ProjectDir)Settings1.runsettings" "$(SolutionDir)TestCaseProject\bin\$(ConfigurationName)\*"

Pipeline log:

enter image description here

Including using enter image description here, you can also try adding a Copy files task in Pipeline to copy the file:

enter image description here

Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39
  • Both of those solutions state that the file was copied in the logs but they never make it into the build directories. I set the pipeline task to copy to $(build.artifactstagingdirectory) and I tried setting the post build event to copy to $(ProjectDir)$(OutDir). Both of them state success but the file isn't copied. – frostymm May 29 '20 at 15:38
  • Do you use Microsoft-hosted agent or Self-hosted agent? Do you specify correct location? Please add the entire log in your original post. – Cece Dong - MSFT Jun 01 '20 at 10:04
  • I have no idea. I believe I have the source location correct and the output is just "$(build.artifactstagingdirectory)". I don't actually know how much of the log I'm allowed to post. My work is very focused on security. I'll update the original post with more info though. – frostymm Jun 01 '20 at 17:06
  • The log indicated copying file from "E:\Backend\_work\116\s\UnitTests\.runsettings to E:\Backend\_work\116\a\.runsettings". Please go to the build agent and check whether the file there. And share the `publish artifact` task log. – Cece Dong - MSFT Jun 02 '20 at 07:01