0

I have a post-build event as follows:

FOR %%F in ("$(SolutionDir)OcrLibrary\$(OutDir)*.dll") DO (IF EXIST "%%F" (ECHO "Skipped: %%F.") ELSE (COPY "%%F" "$(TargetDir)"))

%%F          > C:\Solution\OcrLibrary\bin\debug\*.dll
$(TargetDir) > C:\Solution\Project\bin\debug\
$(TargetDir)\GetFilename(%%F) > How to check for existence?

This enumerates *.dll files and copies them if they exist (which is not the intention). Instead it should check if they already in the target directory and skip them accordingly.

I couldn't figure out how to build a path to each target file using the %%F placeholder. Any pointers would be appreciated.

Raheel Khan
  • 14,205
  • 13
  • 80
  • 168
  • 1
    Have you considered using an MSBuild target with the [Copy task](https://msdn.microsoft.com/en-us/library/3e54c37h.aspx) instead? – Jimmy May 10 '16 at 10:42
  • Thanks. I haven't used MSBuild customizations before. Trying it now. – Raheel Khan May 10 '16 at 14:21
  • @Jimmy: Looking at the first few examples, it appears that I'd have to unload the project, open it for editing and add XML elements when a new task is required. This may be powerful but perhaps overkill for what I'm trying to achieve. – Raheel Khan May 10 '16 at 14:28

0 Answers0