locked
Build Events Error RRS feed

  • Question

  • Hi all trying to use the Build Events that are on the property page of the project I wish to copy a Directory so it's placed within the release folder when i compile.

    I write the following post build.

    [code]
    copy"$(ProjectDir) Reports" "$(TargetDir)"
    [/code]

    It works and my code complies but i get the following error message any one now why?



    Error    1    The command "copy"C:\C# Work\ReportTest\ReportTest\ Reports" "C:\C# Work\ReportTest\ReportTest\bin\Release\"" exited with code 123.    ReportTest



    Thanks!!!
    Wednesday, February 7, 2007 12:31 PM

Answers

  • After looking all day found a solition that works


    xcopy "$(ProjectDir)Reports" "$(TargetDir)Reports" /i /d /y


    Thing is I have never used post build until yesterday so was hoping you could help me out still

    I understand the xcopy statement  but do not know what the /Switches means ???
    Thursday, February 8, 2007 3:50 PM
  • /I - treat as a directory if copying multiple files
    /Q - Do not display the files being copied.
    /S - Copy subdirectories unless empty.
    /E - Copy empty subdirectories.
    /Y - Do not prompt for overwrite of existing files.
    /R - Overwrite read only files.

    These are commonly used switches when working with build scripts.

    Michael Taylor - 2/8/07
    http://p3net.mvps.org

     

    Thursday, February 8, 2007 4:03 PM

All replies

  • Copy only works with files.  It won't copy an entire directory.  You'd have to create the directory first and then copy it.  XCopy will copy both files and directories.  Note also that you have an extraneous space in your first directory which will cause problems.

    Michael Taylor - 2/7/07
    http://p3net.mvps.org

     

    Wednesday, February 7, 2007 5:23 PM
  • thanks for the reply the thing is it does coppy he folder over to the destination but gives the error.
    So how can I achieve the placing of the folder in the same directory as the exe upon compiling the application???
    Thursday, February 8, 2007 2:18 PM
  • What I do is use a post-build event (be sure to only do it if successful) and then use XCOPY with the /E /Q /R /Y to copy all the files from the source to the destination.  The path you'd use is $(TargetDir)newDir to copy to a subdirectory of the build directory.  Normally I copy data out of the output directory but you can copy into it as well.

    So, in summary if you want to copy a Reports directory to the output of your application you'd do this:

    xcopy /E /Q /R "$(ProjectDir)Reports" "$(TargetDir)Reports"

    This would copy the entire Reports directory under your project directory to the Reports directory in the output irrelevant of whether the files already existed or not.  Furthermore it would copy all subdirectories as well.

    Michael Taylor - 2/8/07
    http://p3net.mvps.org

     

    Thursday, February 8, 2007 2:41 PM
  • sorry to be a pain  tried out your last post and still got an error.


    Error    2    The command "xcopy /E /Q /R "C:\C# Work\ReportTest\ReportTest\Reports" "C:\C# Work\ReportTest\ReportTest\bin\Release\Reports"" exited with code 2.    ReportTest


    Any ideas why?
    Thursday, February 8, 2007 3:40 PM
  • After looking all day found a solition that works


    xcopy "$(ProjectDir)Reports" "$(TargetDir)Reports" /i /d /y


    Thing is I have never used post build until yesterday so was hoping you could help me out still

    I understand the xcopy statement  but do not know what the /Switches means ???
    Thursday, February 8, 2007 3:50 PM
  • Add the /I option and see if the problem goes away.

    Michael Taylor - 2/8/07
    http://p3net.mvps.org

     

    Thursday, February 8, 2007 3:59 PM
  • /I - treat as a directory if copying multiple files
    /Q - Do not display the files being copied.
    /S - Copy subdirectories unless empty.
    /E - Copy empty subdirectories.
    /Y - Do not prompt for overwrite of existing files.
    /R - Overwrite read only files.

    These are commonly used switches when working with build scripts.

    Michael Taylor - 2/8/07
    http://p3net.mvps.org

     

    Thursday, February 8, 2007 4:03 PM
  • Thank for the hep
    Thursday, February 8, 2007 4:10 PM
  • Just found a knowledge Base article regarding command switches for copy and xcopy
    hope this can be useful for any one who like me has had trouble.
    Thursday, February 8, 2007 4:31 PM