How to delete specific files after a build (tfsbuild 2010) - file

I'm currently working on a build process, and am running into a slight problem. I have the output directory set up for each project that I want as it's own, but now I would like to delete specific files from the main output directory (This is produced by one project that is set to be output to the build output directory)...
The directory looks like this:
Build Out Folder:
-Folder foo1
-Folder foo2
-Folder foo3
-Folder foo4
-foo.pdb
-foo.dll
Here, I need to delete both the .pdb file, and the .dll file.
I've tried putting this in my csproj file:
<Target Name ="AfterBuild">
<Delete Files="$(TeamBuildOutDir)\$(SolutionName)\**.dll"/>
<Delete Files="$(TeamBuildOutDir)\$(SolutionName)\**.pdb"/>
</Target>
Yet, haven't gotten the results wanted/predicted... I know exactly which file I need to delete (name and everything), just not how to delete them... This is not a web application, so it doesn't have to work for that criteria.

Related

Oneliner for SVN adding files inside unversioned subfolders

I have files that i want to add to svn that are inside a number of nested sub folders. All the subfolder tree is still unversioned.
Say i want to version file1 and file2 (but not file 3) inside subsubfolder and no other file inside subfolder (i.e. file0).
The current filesystem is as follows
trunk
|--subfolder
|--file0
|--subsubfolder
|--file1
|--file2
|--file3
Trunk is versioned, subfolder and subsubfolder are not versioned.
svn add /subfolder/subsubfolder/file1
gives
svn: warning: W155010: The node 'trunk/subfolder/subsubfolder' was not found.
svn: E200009: Could not add all targets because some targets don't exist
svn: E200009: Illegal target for the requested operation
I wonder if there is a quick, potentially one-liner, command to add those files instead of going through adding all the subfolders along the way (without adding their content) and then finally adding the files.
Use the --parents option. Here is an example:
svn add --parents /subfolder/subsubfolder/file1

Robocopy Script with exceptions not working

I'm trying to move a bunch of folders from directory A to directory B.
The folders I would like to move have .csvs and .jps inside.
Directory A contains the following files that must remain in directory A (bat, cmd, py, csv, txt). Basically, all subdirectories of Source directory go, while all files stay. Not sure how everyone else would do this?
Visually it looks like this
Directory A
-Folder 1 (to be moved)
-Folder 2 (to be moved)
-Folder 3 (to be moved)
-Folder 4 (to be moved)
-cmd files
-python scripts
-csv files
-bat scripts
My code is below. It fails to move anything returns the following error:
Error 32 - 'Deleting Source Directory' is being used by another process (must be the batch script doing the command below). I'm glad it fails because I don't want to delete the source directory, I want to delete the subdirectories within the source directory. Any ideas?
robocopy /move SOURCE_DIR DESTINATION_DIR /XF *.cmd* *.log* *.py* *.csv* *.bat*
Should I make this a two command script instead? First one copies the subdirectories, and the second deletes them?

Loop through a directory in Talend

I have a Directory with many sub-directories in it including one named as OLD. This OLD folder could also be inside any of the sub directories and contains archived files.
Root Directory A
SUB-DIRECTORY A
file1.txt
file2.txt
SUB-DIRECTORY B
file1.txt
file2.txt
OLD
SUB-DIRECTORY C
file1.txt
file2.txt
SUB-DIRECTORY D
file1.txt
OLD
SUB-SUB-DIRECTORY E
file7.txt
OLD
I need to create a job in Talend which shall look for all OLD folders (in main and in sub directory both) and delete the files from that folder. I can use tFilelist to and mask the files to be deleted. But unable to figure out how to configure the job to look for OLD folder in all sub directories and delete those files also.
What you need to do is in the tFileList put your main folder choose check box include sub directories and in the FileList type drop down list choose Directories. Your file mask should be "OLD" or if it is anything more "OLD".
Iterate and use the parameter ((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"))
to capture your sub directories. Now you can use this folder path in a tFileDelete Which can also delete folders
follow below approach..
Add tFileList and configure to Travers over all the directories.
now use if conndition connection from tFileList
Add tJava and connect with iterator connection
Add tFileDelete after tJava and connect with IF condition.
Add below condition inside if condition.
((String)globalMap.get("tFileList_2_CURRENT_FILEPATH")).contains("OLD")
Now you will get the all files from all the directories above code will give pass to the files which has the "OLD" in there file path.
I have not tested but you can try it.

how to copy _PublishedWebsites Files?

In Fact, I use Visual Studio 2013, and I want to copy the _PublishedWebsites Files using a batch file after deployment of my build , so this is an image to my Build Definitions:
I'm using in the batch file, this command:
xcopy /s ...\_PublishedWebsites\subfolders ...\main\Service >> ...\output.txt
To be sure that the copy works well, I wrote the result of copying operation in output.txt, so the result is:
0 File(s) copied
I noticed that the copy operation was done before than the _Publishedfiles files are created.
Do you know how can I copy the _Publishedfiles files after their complilation ?
In addition, I don't have the rights for changing in .xaml files :(
Use publish profile and type file system which will copy _PublishedWebsites to sharelocation/location
for publish profile see
https://msdn.microsoft.com/en-us/library/dd465337%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
If you know _PublishedWebSites directory on build machine you can copy files to path you want . You can do something like this, i used this task for same issue.
<ItemGroup >
<MyProjectSource Include="$(OutputRoot)/MySource/**/*.*" />
</ItemGroup>
<Target Name="AfterCopy" AfterTargets="WebPublish">
<Copy SourceFiles="#(MyProjectSource)"
OverwriteReadOnlyFiles="true" DestinationFolder="$(PublishFolder)/% (RecursiveDir)"/>
OutputRoot = your _PublishedWebsites path
MySource = your project
PublishFolder = your destination folder
You can do like this in your csproj file or if you use tfs build definition you can add a copy file task step to defintion and just fill paramaters.

Moving/Grouping Files Unix

I have one folder with about 1000 files and I want to group them according to their resepctive parent folders.
I did ls- R > updated.txt to get the original setup of folders and files.
The updated. txt looks like this:
./Rhodococcus_RHA1:
NC_008268.fna
NC_008269.fna
NC_008270.fna
NC_008271.fna
./Rhodoferax_ferrireducens_T118:
NC_007901.fna
NC_007908.fna
./Rhodopseudomonas_palustris_BisA53:
NC_008435.fna
./Rhodopseudomonas_palustris_BisB18:
NC_007925.fna
./Rhodopseudomonas_palustris_BisB5:
NC_007958.fna
./Rhodopseudomonas_palustris_CGA009:
NC_005296.fna
NC_005297.fna
So, by looking at this file, I know what files go into what folder. The folder with all the 1000 files together looks like this:
results_NC_004193.fna.1.ebwt.map
results_NC_004307.fna.1.ebwt.map
results_NC_004310.fna.1.ebwt.map
results_NC_004311.fna.1.ebwt.map
results_NC_004337.fna.1.ebwt.map
results_NC_004342.fna.1.ebwt.map
results_NC_004343.fna.1.ebwt.map
results_NC_004344.fna.1.ebwt.map
and so on...
You can see that the filenames of all the 1000 files are dependent on their original names in the folder setup(if that's a good way to explain it).
I want to move these results_XXXXXXXX files to folders (have to create new folders) with the original setup. So it should be something like this:
./Rhodococcus_RHA1: (this is a folder)
results_NC_008268.fna.1.ebwt.map
results_NC_008269.fna.1.ebwt.map
results_NC_008270.fna.1.ebwt.map
results_NC_008271.fna.1.ebwt.map
./Rhodoferax_ferrireducens_T118:
results_NC_007901.fna.1.ebwt.map
results_NC_007908.fna.1.ebwt.map
I don't really know how to do this... maybe some kind of mov command? I'd appreciate help with this problem.
Run the following command from the folder where you have those 1000 files. The path/to/original/files is the path to the original files (the one that you did ls -R). you should get a list of mv commands. Verify several of them to confirm that those are correct. If so, add | sh next the command and rerun it to execute those commands. If you don't have all the corresponding files in the 1000 files folder, you would get mv commands that would return "file not found", that can be ignored or piped to /dev/null. This assumes that you always have a file in original folder so that it knows where to move the file. If not, some of those 1000 files won't be moved. As always, take a good backup before you do this.
find path/to/original/files -type f | awk -F"/" '{ path=$0; sub($NF, "", path); printf("mv results_%s.1.ebwt.map \"%s\"\n", $NF, path);}'

Resources