1

I am trying to copy some files on post-build event. These directories are on the same local repository. I was successful to copy these files on the target path however I am having some issues when I build the proj under the target path. I get code 4 error. I think what's causing the problem is that there are some files not accessible on the target path that was included on the post-build command. I am thinking of a possible solution but is still quite unsure how to perform that. Currently when I checked the post-build command on the target path, it does have a post-build command included. Is it possible to clear command on the target paths post-build event? Like make it as the default value.

I am using this code command for the post-build event:

xcopy $(SolutionDir)repo\Project\*.* $(SolutionDir)Artifacts\Project\src\ /y /s /exclude:$(SolutionDir)excludelist.txt

And when I try to build the project on the target path (Artifacts), I got this error:

Can't read file: C:(SolutionDir)\Artifacts\Project\src\excludelist.txt

I understand that excludelist.txt is not accessible since the directory included on the post-build command is on the original directory where the Artifacts folder was copied. So I am wondering if I can however make the post-build command of Artifacts empty by default.

Any help would be appreciated. Thanks!

UPDATE: (solved)
This solution works for me! enter image description here

  • Welcome to StackOverflow. To help you get help please provide more details. "I am trying to copy some files on post-build event." : Please show how. " I get code 4 error" : Normally there is additional error description, please share that. – Jon P Jan 09 '20 at 01:48
  • See this previous post for possible help https://stackoverflow.com/questions/3861474/command-copy-exited-with-code-4-when-building-visual-studio-restart-solves-it – Chris Catignani Jan 09 '20 at 01:53
  • @JonP Hi, thanks for the advise :) I've edited it already. Hope you can help me out. – ros_beginner Jan 09 '20 at 03:09
  • @ChrisCatignani Hi, I had already tried that solution. Sadly, it doesn't work for me though. Thanks btw – ros_beginner Jan 09 '20 at 03:13
  • Did you see the answer posted by Vemul…. It there he states: Another possible issue is that the underlying folder cannot be accessed. If so, trying performing "start xcopy" instead of "xcopy". This will open another command window but with admin priveleges. – Chris Catignani Jan 09 '20 at 03:28
  • @ChrisCatignani that's great! the error doesn't occur after using "start xcopy" instead of just "xcopy". But is it possible to make the default post-build event of the copied Artifacts empty? – ros_beginner Jan 09 '20 at 06:05

0 Answers0