Copy dll to another project in post-build but SolutionDir is level down - visual-studio

I want to copy dll from a project to another in same solution in post-build, but all the solution Directory doesn't help me and nothing in Marcos did.
for example:
pro1 in C:/A/B/Pro1
pro2 in c:/A/B/Pro2
solution in C:/A/B/SolutionFolder
I want to copy pro1.dll to pro2/bin
The problem is the SolutionDir is C:/A/B/SolutionFolder
I need to go one level up. I tried these and others nothing helped!
xcopy "$(TargetDir)$(TargetFileName)" "$(SolutionDir)..\Pro1\bin)"
xcopy "$(TargetDir)$(TargetFileName)" "$(SolutionDir)" "(..\Pro1\bin)"
with () and without them
Edit:
And I need to copy this file to 2 directions not only one. I tried && but it didnt work

Related

Copy a file in Post Build of Eclipse/Truestudio

I was using arm-objcopy but it doesn't work with my .h file I need to copy to another project.
xcopy "../${project_loc}/src/folder/file.h" "....\OtherProject\folder\folder2\file.h" /Y
The error I get is "Invalid number of parameters". Earlier it was working enough to delete the existing file and ask "Is this File or Directory". /Y is supposed to quiet that according to xcopy docs, but then I find Copy file(s) from one project to another using post build event...VS2010 which suggests otherwise? Either way it didn't let the copy happen quietly.
Project_loc from What are the predefined variables in eclipse?
I would've thought this wouldn't take an hour. Google disagrees with me.
Edit
I flipped the first set of / to \ and now I'm back to
Does ....\Project\folder\folder2\file.h
specify a file name or directory name on the target (F = file, D =
directory)?
xcopy "${ProjDirPath}\src\folder\file.h" "..\..\OtherProject\folder\folder2\file.h" /Y
I had a typo somewhere in the destination, but I used ${ProjDirPath} as ${Project_loc} did not exist for the source.

Command Line - Delete Files in Location 2 if they Exist in Location 1, then copy to Location 2

I have looked through a lot of the questions here, and have put together about as much as I can without running into problems.
Goal - I want to check files in Folder 1 that have a date modified of > yesterday. If they exist in Folder 2, I want them deleted in Folder 2. Finally, I want to copy them over to Folder 2.
Here is what I have for the delete step.
cmd /k For %%F In ("Path_Folder_1\*.*") Do If Exist "Path_Folder_2\%%~nxF" Del "%%F" "Path_Folder_2\%%~nxF"
I figured I would do the copy step later, unless it can be combined with this step. Also, I do not know how to integrate the date check into this. I've seen "forfiles" but am not able to understand how to do the same thing with it.
Thanks so much for your help!

I'm looking for a script that will rename files and place them in a new folder

Essentially what I am looking to create is a script that will rename files in a folder, create a new folder with a specific name and place the renamed file in that new folder.
So, for instance, let's say that I had 2 files called:
test-spa.txt
test-ger.txt
I would then want to create 2 folders called spa and ger, respectively, place the appropriate file into each folder then rename the file by removing the language component; the resulting files in each folder would be test.txt.
Thanks,
Jaime
So here is the simple solution I came up with to create folders and place specific files in them. So long as I have the bat file in the same folder it works great:
#echo off
md spa ger
move file.txt EN\file.txt
move file-spa.txt spa\file.txt
move file-ger.txt ger\file.txt
I'm wondering if there is something missing that may cause an issue, such as specifying that this should only work in the current directory?

Excluding folders in Winrar

A Day with Winrar
All I wanted to do was exclude folders and their contents using wildcards, and even after reading the docs, it turned into a guessing game...
So my test bed looks like:
C:\!tmp1\f1
C:\!tmp1\f1\f1.txt
C:\!tmp1\f1\a
C:\!tmp1\f1\a\a.txt
C:\!tmp1\f2
C:\!tmp1\f2\f2.txt
C:\!tmp1\f2\a
C:\!tmp1\f2\a\a.txt
And I am executing:
C:\>"c:\program files\winrar\winrar.exe" a -r !tmp1.rar !tmp1
which gives me a rar with !tmp1 as the root (sole top level folder).
The exclude switch is -x<filepathpattern> and may be included multiple times.
So, given that we want to exclude f2, and all its subcontents...
-x*\f2\*
removes the contents, but leaves f2
-xf2
does nothing - includes all
-x\f2
does nothing - includes all
-x*\f2
does nothing - includes all (now I'm mad), so surely it must be..
-x\f2\
nope, does nothing - includes all. So it has GOT to be...
-x*\f2\
hell no, does nothing - includes all. and I already know that
-x*\f2\*
removes the contents, but leaves f2. Onward we go...
-x*f2\
does nothing - includes all. Grrrr. Aha! how about...
-x!tmp1\f2\
nope, does nothing - includes all. WTF. Alright, So it has GOT to be...
-x!tmp1\f2
Holy moly, it worked! Hmmm, then how come....
-x*\f2
does not work? This was the little demon that sent me down this crazed path to begin with and should have worked!
Given all that, do I dare try to go after */a/* directories, removing contents and the dirs?
-x*\a
does not work, of course, does nothing.
-x*\*\a
does not work, of course, does nothing.
-x!tmp1\*\a
nope. But...
-x*\a\*
removes contents of both dirs, but leaves the folders. So, in desperation I can use the -ed switch which will not store empty folders, but this is a broad hack, I want to eliminate the folders specified not all empty folders.
With my animosity growing toward winrar, I am passing the baton of information forward with an eye to that glorious day when we will know how to specifically exclude a folder and its contents using wildcards and not using the -ed switch.
(Quite old question but still may be relevant)
Maybe what you simply needed was this :
-x*\f2 -x*\f2\*
two exclude switches, should remove directory f2 and all its contents.
An even older question by now, but came across this question so I reproduced your folder structure and, at least nowadays (Winrar 5.11, not the latest but quite new), this works:
-x*\f2
So the whole command line is:
"C:\Program Files\WinRAR\Rar.exe" a -m5 -s !tmp1.rar !tmp1 -x*\f2
And this is what is stored in the .rar file:
!tmp1\f1\a\a.txt
!tmp1\f1\f1.txt
!tmp1\f1\a
!tmp1\f1
!tmp1
Similarly, if you use -x*\a, all a folders are excluded, storing this:
!tmp1\f1\f1.txt
!tmp1\f2\f2.txt
!tmp1\f1
!tmp1\f2
!tmp1
Finally, combining both parameters (-x*\f2 -x*\a), you get this:
!tmp1\f1\f1.txt
!tmp1\f1
!tmp1
To manage large list of files to be excluded, you can create text fie and write all excluded files/folders relative to the source folder:
1) create file list.txt, write the name of excluded files/folders
note: * refer to the source, all files/folders are relative to the source folder
*\f2
*\f3
2) Run the command
rar a -r -x#list.txt target.rar source-folder

User VisualStudio PostBuild with place-marker

After successfully build, I want to copy the content of the the folder to the destination.
I've learned that this will work fine:
copy "$(TargetPath)" "$(TargetDir)\..\..\..\TB-Annotation Editor\bin\Debug\Plugins\$(TargetFileName)"
But I am interested to copy all *.exe, all *.dll and all *.txt files into the destination and this could cost a lot of lines for each plugin. Now I wanted to ask if there is any possibility to use place-marker instead of fixed filenames.
this does not work and raise event "Error Code 1"
copy "$(TargetDir)*.*" "$(SolutionDir)bin\Debug\plugins\"
Regards
** Solved except .dll *
I'm very sorry, seems to be not an error because of the "*" but of the folder which is called same twice:
copy "$(TargetDir)*.*" "$(SolutionDir)MyProject\bin\Debug\plugins\"
Goes correct to:
"copy
"C:\Daten Laptop\PAG\Net\MyProject\Solution\Plugins\DSP - Alphablend\bin\Debug\DSP - Alphablend.exe"
"C:\Daten Laptop\PAG\Net\MyProject\Solution\MyProject Main\MyProject Main\bin\Debug\plugins\DSP - Alphablend.exe""
But when using ".dll" instead of ".*" (DLL does not exist, because at the moment it is selected as *.exe) it does throw error code 1 again.
To my mind the best way of doing this is setting file properties and project properties. This requires no additional lines at all. If you set "output folder" property for project, "copy local" flags for referenced libraries and change "Build action" and "Copy to output directory" properties for your txt files (they should be included to solution) you get what you want.

Resources