Answered by:
Copy Task for Empty Sub directories, Copy Count and Files List

Question
-
Does anyone know how I can achieve the following from MSBuild Copy task? (Not XCOPY or ROBOCOPY)
1. Copy empty sub folders recursively while copying?
2. How can I get the number of files / folders copied?
3. How can I get the verbose output (status) which include the list of files / folders being copied?
I believe we can achieve most (or all) of the above with XCOPY or ROBOCOPY. But I have been asked to use Copy Task.
Can anyone please help?
Ven
Thursday, May 14, 2020 5:48 PM
Answers
-
Hi Venh,
For your requirement, I'm afraid that you can't do that in project file. There are not related parameters to implement this requirement. Please refer this document about Copy task .
So we suggest you could create a exe script file with ITaskItem Interface, which can do what you want, and then run it with <Exec> Task in project file.
Best Regards,
Dylan
MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com
- Proposed as answer by Dylan Zhu-MSFTMicrosoft contingent staff Monday, May 25, 2020 7:44 AM
- Marked as answer by Venh Monday, May 25, 2020 8:06 AM
Friday, May 15, 2020 3:26 AM
All replies
-
Hi Venh,
For your requirement, I'm afraid that you can't do that in project file. There are not related parameters to implement this requirement. Please refer this document about Copy task .
So we suggest you could create a exe script file with ITaskItem Interface, which can do what you want, and then run it with <Exec> Task in project file.
Best Regards,
Dylan
MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com
- Proposed as answer by Dylan Zhu-MSFTMicrosoft contingent staff Monday, May 25, 2020 7:44 AM
- Marked as answer by Venh Monday, May 25, 2020 8:06 AM
Friday, May 15, 2020 3:26 AM -
Thanks a lot for the quick and prompt response Dylan. I had already gone through that link before posting here. So, I understand that Copy task out of the box doesn't have that capability and I have to build a custom exe or utility to achieve this. Correct?
I would rather go /stick with Robocopy / Xcopy in that case.
Ven
Friday, May 15, 2020 7:11 AM -
Hi Venh,
Yes, it should be to avoid msbuild spending too much time reading proj file. So you need a script file to implement these requirements.
Best Regards,
Dylan
MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com
Friday, May 15, 2020 10:00 AM -
If your project needs to be buildable on operating systems other than Windows, and that is why you would rather not use XCOPY or ROBOCOPY, then an inline task with RoslynCodeTaskFactory may be a good solution.
- Proposed as answer by Dylan Zhu-MSFTMicrosoft contingent staff Monday, May 25, 2020 7:44 AM
Tuesday, May 19, 2020 2:45 PM