Excluding files/folders from VSTS publish - azure-devops

We are using the new VSO/VSTS style build within TFS on premise, 2015 Update 1 as of yesterday.
During the publish build artifacts stage we want to copy all the files/folders from a root bar 2 sub folders.
ie:
$\somefilestopublish1\...
$\somefilestopublish2\...
$\somefilestoexclude1\...
$\somefilestoexclude2\...
Currently I have **\* as the contents argument which obviously will publish everything. I have tried appending ;-:<exclude_pattern> as suggested by a Google search but that just stopped all output and resulted in an empty folder.
Is there a way to use the minimatch expression to exclude folders or will I need to swap to explicitly selecting the folders to publish instead.

Minimatch use "!" to exclude the given pattern. You could specify it with following format:
!(somefilestoexclude1|somefilestoexclude2)
Following is the example:
With !(bin|obj), "bin" folder and "obj" folder under "WindowsFormsApplication1" folder are not copied to artifact.

!/$tf/** works for me. I've opted to shorten that to !/$*/**
http://www.globtester.com/ helped. The $ symbol doesn't have to be escaped despite conflicting guidance on msdn: https://msdn.microsoft.com/en-us/library/bb383819.aspx.

Suppose you want to collect all the *.nupkg files in your solution (for instance the ones you create during build) and copy them to another folder, but you want to exclude the ones you get through the package restore, you need to specify the following:
**\*.nupkg
!packages\**
It's important to specify them in this order. Placing the exclusion on the packages folder on top, will result in the Copy task copying all the *.nupkg files.

This worked for me for folder try this !**\Uploads***
For file **!(Web.config)
Above example is for excluding a folder and file available in same folder path.

On TFS 2017 Update 1 if you are using the Copy Files task and you want to copy all files from the $(Build.SourcesDirectory) but exclude the $tf folder what I found to work was the following.
In the Contents text box enter the following two lines.
**\*
!$tf\**
This post on social.msdn.microsoft.com is what helped me figure this out.

Related

Excluding a folder in .gitignore

I am trying to exclude a folder in my project and have added the following lines to the .gitignore:
logs/
tempStorage/
libraries/lib/
The first two are excluded but the last one is still being updated. That folder contains DLLs that are generated by another project in the solution.
I am using Visual Studio 2022. When I rebuild the solution the project target lib updates the DLLs. I don't want to store these in git.
Do I need to do something in git like delete the files?

.gitignore not ignoring a folder within a directory

It seems a straightforward one, but having researched multiple ways to do it, I can't gitignore a folder within a directory.
I have a root directory which contains all of my code in it. Because it has some back-end NodeJS stuff in it, it has a 'node_modules' folder which contains hundreds of files. As a result, when I try to upload the entire parent folder, GitHub says there's too many files to upload and tells me to reduce the number I'm uploading.
The crucial part is though, the folder has to be uploaded as a whole, as it itself is within a GitHub repository with other files with different folders in.
That means when I go onto my repository, I need this folder's files to display within the folder, and not separately within the repository. I need all of the files to be within this folder, within the parent repository, excluding the node_modules folder.
For example ->
Parent repository -> Child Directory (what I'm uploading) -> Individual files
I've tried to add the node_modules folder to my gitignore through the following methods:
Adding: node_modules/ to my gitignore file
Writing: echo node_modules >> .gitignore through my terminal
Adding a separate gitignore file within my node_modules file with a * in it
None of them have worked and I can't find any other solutions. For reference I'm using a Mac.
Does anyone have any idea what I'm doing wrong, or how it'd be best to do it?
By default, you do not need to include the node_modules folder in your repositories because the package.json file contains all of your project's dependency information. This means that anyone who clones your repository can run npm install and have the entire node_modules folder without problems.
To solve this you can create your own .gitignore file, creating a new file at the root of your project and renaming it to .gitignore (writing exactly that way). Then you can open it with any text editor and add */node_modules to one of the lines.
This will likely solve your problem.

Ignore folders gitignore in repo

In my bitbucket repo I am trying to ignore all folders that contain _vti_cnf or even just the contents of these folders.
These folders are created throughout the system are are specific to each user and should not be in our repo. They are not in just one directory, they are peppered throughout.
I have tried :
_vti_cnf/
_vti_cnf/*
*_vti_cnf/*
And they keep wanting to be included in my repo. How can I ignore any folder that either begins with or contains this name no matter where it is in the repository.
Thanks for your help.
You can exclude paths or files recursively by prefixing the pattern with **/, i.e. in your case via **/_vti_cnf/.

VSTS Release - Copy Files from subfolder

I have a "Release" that I intend to use to publish to a remote share.
I have created a Copy Files task which works. However my build artifacts are all below two subfolders [UI] Build/drop. I want to copy the contents of the drop folder rather than the entire thing. Unfortunately I only seem to be able to copy the entire thing!
Task (copies all files and folders):
Source Folder: $(System.DefaultWorkingDirectory)/
Contents: **
Target Folder: \\myshare\test
So I tried to only copy the contents (with support from this article) of UIBuild/drop but nothing gets copied in any of these cases:
Changing Source Folder to $(System.DefaultWorkingDirectory)/[UI] Build/Drop.
Keeping Source Folder as it was but changing Contents to [UI] Build/drop/**
Keeping Source Folder as it was but changing Contents to **/[UI] Build/drop/**
Keeping Source Folder as it was but changing Contents to **/drop/**
What am I doing wrong?
After some digging I realised its because there was a square bracket in my artifact. Once I changed my artifact to not use the square bracket everything started working.
Im not sure if its related but this post on minimatch within gulp helped give me the nod

Nuget: How to copy a files to root folder without including in project

If you put any files in the Content folder of a Nuget package, during installation these files are:
Copied to the root of the target project and
Included in the project.
Is there any way to make Nuget skip action 2, i.e. to copy them but not include them in the project?
I know I can do this with a Powershell script that goes in and removes the files from the project. But I don't think that's a very robust method.
Can I achieve this without relying on Powershell?
You can try adding your contents directly in the package instead of the "contents" folder.
Files outside "contents" would be ignored by NuGet while trying to add content files.
Then you can do just the copying part using your powershell scr