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
Related
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.
I defined VSTS build process till Publish Artifact steps. By default, VSTS agent creates 5 files in Publish Artifact location (c:\vsts-agent_work\1\a) including important build file i.e zip folder. When I checked zip folder, I found long path where my build files are located. folder path in zip -
\Content\C_C\vsts-agent\_work\1\s\ABCProject\obj\Release\Package\PackageTmp
I got to know that source of zip file is source directory after looking in _work folder-
C:\vsts-agent\_work\1\s\ABCProject\obj\Release\Package\PackageTmp
I wanted one folder (RDLCReports Folder) in C:\vsts-agent\_work\1\s\CCM2015MVC\obj\Release\Package\PackageTmp directory. I managed to create that folder using copy files task. I did this step before Publish Artifact step.
Problem is when Publish Artifact step is completed, I didn't get that folder in zip file.
below is snapshot of VSTS build process-
below is Publish Artifact location -
Please let me know how can add that folder in zip? and I also want to know which source path VSTS build has considered to make it as zip folder?
The contents in folder (c:\vsts-agent_work\1\a) is created at the Visual Studio Build task step. So that even if you managed to create RDLCReports folder in C:\vsts-agent\_work\1\s\CCM2015MVC\obj\Release\Package\PackageTmp using copy file task. It will not be copied and zipped to c:\vsts-agent_work\1\a again.
There is a workaround to achieve this. If you want to keep the folder structure in the zip file, You can follow below steps:
1,You need to add a Extract file task to extract the zip file in folder $(build.artifactstagingdirectory) to a different folder (eg.$(Agent.BuildDirectory)/Temp)
2, Add the copy file task to create RDLCReports folder inside the extracted folder in $(Agent.BuildDirectory)/Temp
3, Add a Archive files task to archive the files in the folder
$(Agent.BuildDirectory)/Temp where folder RDLCReports is created.
Make sure uncheck option Prepend root folder name to archive paths and check Replace existing archive
(For above example. My test project is named AboutSite and the zip file is AboutSite.zip. And the folder structure is Content\C_C\agent\_work\1\s\AboutSite\AboutSite\obj\Release\netcoreapp2.0\PubTmp\Out. You need to make a little change to the paths and file name according to your project.)
For your project you may find the contents in C:\vsts-agent\_work\1\s\ABCProject\obj\Release\Package\PackageTmp is the same with your zip file. So there is an another workaround is to add copy file task and target this path C:\vsts-agent\_work\1\s\ABCProject\obj\Release\Package\PackageTmp . And then add the archive file task to archive this folder. However this workaround cannot keep the origin file structure.
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.
I want to add a rule to ignore all apart from the files within a 'Build' folder, but not the folder itself.
I currently have the below which ignores all but the Build folder, but I want only the files within the Build folder, ignoring the folder itself.
# Ignore everything in the root except the Build directory.
/*
!.gitignore
!Build/
It doesn't matter, because git doesn't track folder, only their content.
And if their content is ignored or empty, you won't be able to add their folder, even if that folder is displayed in git status as "untracked".
If Build as some content which isn't ignored, you will be to add said content with the shortcut git add Build: that doesn't mean Build/ is "ignored" or "not ignored": it is just a container.
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