-2

I am trying following post build event in some of my projects

copy /Y "$(TargetDir)*.dll" "$(SolutionDir)MyMainApp\bin\*.dll"

But getting error

Error The command "copy /Y "D:\myslolution\myimplementation\bin\Release*.dll" "D:\myslolution\MyMainApp\bin*.dll"" exited with code 1.

Any idea what's wrong in it? strange thing is on multiple rebuild it sometimes work

Kamran Shahid
  • 3,954
  • 5
  • 48
  • 93

2 Answers2

2

Please check your two project folders in your side.

For example, bases on your description, I have two projects, I set the post-build event command line in the myimplementation property:

enter image description here

If I build the project, I will get this dll file:

enter image description here

strange thing is on multiple rebuild it sometimes work

If so, please clean and build your project, view it again. My understanding is that if your project code was not changed after you build it first time, it would not update the dll file or call the build event again even if you build it. It would show you up-to-date messages in your VS output window. But if you clean it, and then build it again, it would copy the dll again.

Jack Zhai
  • 6,230
  • 1
  • 12
  • 20
  • Thanks Jack.I still get the error. Actually i have multiple projects which are referencing same DTO, BLL assemblies. Can this be the reason? – Kamran Shahid Dec 08 '17 at 09:24
  • @Kamran Shahid, If it was called by other projects/processes, my understanding is that it would impact this build event. Of course, you can test it after you disable/remove the references, view the result. – Jack Zhai Dec 08 '17 at 09:27
  • @Kamran Shahid, What about this issue? Can it copy the .dll file to that correct path now? – Jack Zhai Dec 11 '17 at 01:48
1

I think the syntax for the copy command should be: copy /Y D:\myslolution\myimplementation\bin\Release\ *.dll D:\myslolution\MyMainApp\bin\

(\ *.dll after the source parameter, otherwise files that start with Release, and end with .dll are targeted)

you could try the command first in a cmd window to verify the syntax, before adding it to the post build.

After verifying the copy command syntax you can change it to:

copy /Y "$(TargetDir)\*.dll" "$(SolutionDir)\MyMainApp\bin\"

Gwen Royakkers
  • 431
  • 2
  • 11
  • No. i can't hardcode the file path. it's relevant to project – Kamran Shahid Dec 07 '17 at 12:27
  • I didn't mean you should hardcode the path, (only for testing if the syntax for the copy command is correct).In your case: copy /Y "$(TargetDir)\*.dll" "$(SolutionDir)MyMainApp\bin\" – Gwen Royakkers Dec 07 '17 at 12:29
  • tried copy /Y "$(TargetDir)*.dll" "$(SolutionDir)MyMainApp\bin\" But same result – Kamran Shahid Dec 07 '17 at 12:39
  • 1
    @KamranShahid you missed the backslash after $(TargetDir) again. Look closely at your error message and at this answer. "Release*dll" is not a folder. – Crowcoder Dec 09 '17 at 11:27