Okay, I am going nuts here. I have searched and tried every command I can find to try to copy the result of my build to another directory on the network. So basically I want to build the project, then have the created .DLL copied and overwrite the one on the network. Here is my latest try that I found online:
xcopy /i /e /s /y /f $(TargetPath) "\\SERVER\Folder1\Folder2\Binaries"
This just does not seem to work! Can somebody give me an example of how I can write this line that will work?
Related
I am currently trying to set up an "automatic build process" on mac for my C++ "Hello World Project" that uses Cmake & visual studio code.
My current workflow to build in terminal or with vscode's tasks.json is the following, and I find them very tedious to do.
cmake ... (to generate the cmake & make files inside the build folder)
make (inside the build folder to create the application's executable)
./{application's executable}
Thus, I have have looked into the following
vs code's prelaunch task
cmake's add_custom_commands
custom bash script
python scripts
But I'm a bit lost with the above try-outs, and need some helps. My end goal is to automatically build and run the updated code by either pressing F5 in vscode or calling a custom ./{command} in terminal.
Combining everyone's suggestions, the approach I took is to create a task.json that contains the following command-flow
cmd1: cmake to generate the makefiles & cmake files to a build folder
cmd2: make -j 8 to build with multiple cores
cmd1 && cmd2
Then I made two different launches in launch.json. The major difference between them is the prelauch task. One of them is "cmd1&&cmd2", and another one is only "cmd2". That way I can have two hotkeys like F5 and F7 for me to choose. If the folder structure & files weren't added or removed I will hit F7 which only calls the "cmd2" pre-launch task, otherwise F5.
I think a better approach is to either write a bash script or dig deeper in cmakelist.txt which I believe it has the "if statements" that determine when should it do "cmd1 &&cmd2" or just "cmd2" alone. That way, I don't need two hotkeys to build/debug and run in vscode (don't know if it is possible, I haven't try yet.)
If anyone has done it, please comment below or create a new answer.
Thank you all!
You can run
cmake --build
after the first time you configured the build. Optional parameters include the build directory and targets to build.
Basically, I have two projects, one which compiles to a dll and the other which consumes that dll. Right now I have a pre-build script which copies the dll into the dependent projects binary folder for use:
copy "$(SolutionDir)\DLLProj\Binaries\$(PlatformName)_$(Configuration)\DLLProj.dll" "$(SolutionDir)\DependentProj\Binaries\$(PlatformName)_$(Configuration)\"
This script seems to copy the dll upon first build but then on subsequent build and runs it is not being updated. At first I thought this was because my dll was not being rebuilt but I dont think this is the case. The only thing I can think of is that maybe my copy command is only running when there isn't a dll file found in my dependent project's folder? So the old dll just sits in there unless I clean or rebuild my project and then a new dll is copied to that location. If this is the case is there a command to make sure to delete or remove the dll from my dependent project upon exit? or any other way to ensure proper dll's on subsequent builds?
EDIT:
Try modify your copy command(make sure replace the existing file using echo y|copy):
echo y|copy "$(SolutionDir)\DLLProj\Binaries\$(PlatformName)_$(Configuration)\DLLProj.dll" "$(SolutionDir)\DependentProj\Binaries\$(PlatformName)_$(Configuration)\"
And make sure the copy command runs after you have built your DllProject.
Another solution:
I prefer using .bat instead:
1.delete old version of .dll file:
echo y|del "$(SolutionDir)\DependentProj\Binaries\$(PlatformName)_$(Configuration)\DLLProj.dll"
2.copy updated version
copy "$(SolutionDir)\DLLProj\Binaries\$(PlatformName)_$(Configuration)\DLLProj.dll" "$(SolutionDir)\DependentProj\Binaries\$(PlatformName)_$(Configuration)\"
As a result, your .bat file should be look like:
echo y|del "$(SolutionDir)\DependentProj\Binaries\$(PlatformName)_$(Configuration)\DLLProj.dll"
copy "$(SolutionDir)\DLLProj\Binaries\$(PlatformName)_$(Configuration)\DLLProj.dll" "$(SolutionDir)\DependentProj\Binaries\$(PlatformName)_$(Configuration)\"
The usual solution is xcopy /d. This flag tells xcopy to only copy your DLL if the destination is outdated or missing.
I have a project in Visual Studio 2013 which is setup to copy resource files into proj.win32/Debug.win32 directory (this is the debug build directory). The copying is being done during Pre-Link Event with the following command:
xcopy "$(ProjectDir)..\Resources" "$(OutDir)" /D /E /I /F /Y
My question is can I do this copying on each run of the project in spite of compilation or linking is being done. (I need this to be able to modify my resources and check on each run if I lake the new parameters).
I am trying to add resource files to my Visual Studio C++ project, but my images do not seem to be copying correctly during the build step. When developing within a C# environment, this was easily achieved by right clicking on the resource file(an image or what have you) and editing the "Copy to output directory" option. This option does not seem to exist within the C++ environment. Here is a picture of the C# environment to better illustrate the option that I am looking for:
I tried doing roughly the same thing within the C++ environment but, like I said, the option simply does not exist. Instead it only gives a "content" option, with a "yes" or "no". The tool tip says that this is related to a deployment resource, however the resource is not deployed during the project build. I would also like the entire folder to be copied upon build; here is another picture:
Does anyone know how I can replicate this within a C++ environment?
EDIT
I tried using a post-build event script, but nothing appeared in the output directory. I am trying to copy the "Resources" folder, which I show in the second image. Here is the script that I am using:
xcopy "$(ProjectDir)Resources" "$(TargetDir)Resources" /e /y /i /r
Did I do something wrong in that? I don't even see any errors in the build log.
Your post build script worked for me. Yes, it is disappointing that the C++ project solution does not make doing so easier.
Add the project output to the installation project as content Files
In MS Visual Studio 2008, it's very easy to copy non-C# files, such as an XML file, in a C# project to the output folder. Just add the file to the project, select it in Solution Explorer, then select Properties, and there's a choice named "Copy". You can choose "Do not copy", "Copy", and "Copy If Newer".
But in C++, it's not so easy, probably because there was never anything similar in earlier versions of Microsoft's compilers. The only option I have is to add a post-build event with an old-fashioned DOS command line command to copy the file to the target path. There's no way I know of to compare the dates on the input and target files, if the target file already exists.
I tried adding the files to my C++ project in the same was as I would in a C# project. The options for the files included a custom build step. I tried putting the copy command in there, but it didn't work.
Is there some way I don't know about to get the same result as I get in C#: a nice, clean, easy way to specify that a file get copied from the project folder to the output folder if it is newer than the file in the output folder?
Thanks very much!
RobR
In your post-build event, you could use robocopy instead of the basic copy command (it is more intelligent, can somewhat manage file modification dates e.g. robocopy /xo <...>)
see http://technet.microsoft.com/en-us/library/cc733145%28v=WS.10%29.aspx
xcopy "source file name" "destination" /D /Y should do it. When tested in a command window, backslashes instead of forward slashes were required.