TFS include files and folders within the Delete Files Task - tfs

I need to use the 'Delete files' task in a VNext build definition (TFS 2018). after 'Publish Artifact' task I am using the 'Delete File' task to delete all the files and folder in the drop folder but except the below ones and used the pattern like in Contents section
!bin/
!Views/
!Scripts/
!Content/
!Reports/
!Web.config
I found that we can use exclusion pattern, but it's not working. How can I make this work?

Delete Files task uses the minimatch patterns.
Q: What's a minimatch pattern? How does it work? A: See:
https://github.com/isaacs/minimatch
https://realguess.net/tags/minimatch/
http://man7.org/linux/man-pages/man3/fnmatch.3.html
Thus, you could use !(bin), it will remove other folders except the bin folder.
For Web.config it should be !(Web.config)
If this still not work, you could use a copy file task to copy the folder as workaround. Details please refer Levi Lu's reply in this question: How to exclude some directories and files from deliting in Delete Files task
For multiple folder you can write
!(bin|views)

Related

When to prefix a BUILD file (*.BUILD) in Bazel

In its C++ unit testing tutorial, Bazel suggests adding a root level gtest.BUILD file to the workspace root in order to properly integrate Google Test into the test project.
https://docs.bazel.build/versions/master/cpp-use-cases.html
Why would one create a new BUILD file and add gtest prefix to it rather than adding a new build rule to an existing BUILD file in the workspace? Is it just a minor style preference?
Because if you added a BUILD file somewhere in the workspace (e.g. under //third_party/gtest/BUILD) then that file would create a package there.
Then, if you had targets declared in that BUILD file, would their files exist under //third_party/gtest, or would they exist in the zip file that the http_archive downloads? If the former, then there's no need for a http_archive because the files are already in the source tree; if the latter, then the BUILD file references non-existent files in its own package. Both scenarios are flawed.
Better to call gtest's BUILD-file-to-be something that doesn't create a package, but that's descriptive of its purpose.
The build_file attribute of http_archive can reference any file, there's no requirement of the name. The name gtest.BUILD is mostly stylistic, yes, but it also avoids creating a package where it shouldn't. You could say it's an "inactive" BUILD file that will be "active" when Bazel downloads the http_archive, extracts it somewhere, and creates in that directory a symlink called BUILD which points to gtest.BUILD.
Another advantage of having such "inactive" BUILD files is that you can have multiple of them within one package, for multiple http_archives.

How can you copy a project from Jenkins into a folder?

We have the Jenkins folder plugin. When a new folder is created, and 'Add an item' is selected, none of the projects from the containing Jenkins database are available to be copied in the 'copy from' selection. What's the easiest way to copy an existing Jenkins project into a new folder?
You need to specify the absolute path.
For example if you create folder
Util
And inside Util you want to copy job "FooJob" from the base level in "copy from" specify
/FooJob
Or of FooJob is inside folder Bar specify
/Bar/FooJob
Select your project
Choose "Move"
Select your folder from the drop-down
The answer given by krtrego (use absolute paths) is correct -- but: you can also copy the job on filesystem level, which is preferable in many cases. That is, on Linux, do
cp -ar $JENKINS_HOME/jobs/jobXYZ $JENKINS_HOME/jobs/folderABC/jobs
Shutdown Jenkins beforehand and start it afterwards (or do not shutdown, and just "reload configuration from disk" afterwards).
Depending on the definition of "easy", this might be the best choice, since
If you're copying many jobs, then this is only way that jobs won't start before you completed moving all of them ("Folder copy" on GUI-level does not work in "quiet-down" mode).
The Folder copy operation sometimes takes ages (literally) for certain jobs.
Tagline: for anything but the most simple tasks, it will be good to avoid Folder Move/Copy.

TFS copy and deploy: exclude files using minimatch

According to many different SO-questions, it should be possible to exclude files being copied/deployed using the Task "Copy and Publish Build Artifacts" in the new TFS build system.
However it doesn't work for me (it is not excluding anything). What could I be doing wrong:
This should work (I know the question is old but I needed an answer myself)
**\!(System.Windows.Interactivity.resources.dll|*.dll.config|*fluentassertions*)
This is a known issue of the build task “Copy and Publish Build Artifacts”,bitbonk.
Q: This step didn't produce the outcome I was expecting. How can I fix it?
This step has a couple of known issues:
Some minimatch patterns don't work.
It eliminates the most common root path for all paths matched.
Source Link: Utility: Copy and Publish Build Artifacts
Well, it's nothing business with your settings of minimatch. It's just not work for that build task. Certainly, you can also doulbe check your minimatch with Copy Files task to verify this.
For now, you can avoid these issues by instead using the Copy Files step and the Publish Build Artifacts step.
Note: If it's still not working on copy files step, you should pay attention to the architecture of file when using minimatch. There must be something wrong on it.
The task copies the files base on the contents you entered one line by one line and the "!" only exclude the files during the copy, it does not delete the files that already been copied. So with the "**\*" you entered in the first line, all the files have already been copied and published. You need to remove the first line in "Contents". And for the excluded files, if there are in the same folded, you need to exclude them in one line. For example: using
!?(1.txt|2.txt)
to exclude both 1.txt and 2.txt file instead of using
!1.txt
!2.txt

Teamcity is not copying all the folders

I've now setup a MSBuild script to create the folders and files I need in the right structure for my MVC project. I'm then setting Teamcity up to look at the folder with only the files I want to have and copy that to the artifacts folder. So far, so good!
However, There is a few folders in the structure that are empty, and Teamcity does not copy these folder, even if I've set it up to copy the mainfolder and everything in it.
Is there a way to force Teamcity to copy everything - and by that I mean EVERYTHING in my folder, or does it simply not work?
Teamcity Artifact path settings:
Website => Release
You may find your answer in this post : How do I exclude the contents of a directory but not the directory itself in MSBuild
It's not Teamcity but still MsBuild. The problem is that msbuild's include does not include empty directories...
We manage to work around this and skip the empty folders. Therefore this was no longer an issue. However, still don't know how to copy empty folders. My understanding from doing research for a long while now is that it simply doesn't work.

Is it possible to access files stored in TFS’s source control from the TFSBuild.proj file before the “Get” build task?

I’m using a few custom MSBuild tasks that are checked into source control. I would like to import these tasks into my TFSBuild.proj file that TFS uses to build the project. Right now I have created a 2nd project file that includes all of the uses of these custom tasks. I do this because I can run this project file after the workspace has been created and the files have been downloaded.
Is there a way to reference the files on the server from the build project so that I don’t have to do this 2 step process?
I wish the following would work.
<Import Project="$/My/Server/Path/Custom.tasks.targets" />
This question is related to another question. In my case the tasks are checked into source control so that the build machines don't have another required install. Placing the tasks locally doesn't work very well in this case.
If you put the tasks and the .targets file(s) in the same version control folder as your TFSBuild.proj file (or in a sub-directory beneath it), TFS Build will download all of that content to your build agent prior to kicking off your build script.

Resources