I have created a Copy and Publish Build Artifacts build step in TFS 2015 with the following parameters:
Copy Root: $(build.sourcesdirectory)\bin\Installers
Contents: **
The according to https://www.visualstudio.com/pl-pl/docs/build/steps/utility/copy-and-publish-build-artifacts it should not copy the subdirecttories but unfortunately it does it!
How to copy and publish build artifacts whitout subfolders?
Please add the suffix of the files after **, then you won't get the subdirectories. For example, in the following setting, you'll only get .txt and .dll files under $(build.sourcesdirectory)\bin\Installers, but you won't get .txt and .dll files in any sub folders under $(build.sourcesdirectory)\bin\Installers:
You can use **.* instead of **.
Related
TL/DR: In a release step, how do I find a .nupkg file that was definitely created in a build process and copy it to a drop folder for use in a release task?
Using TFS 2018, I am trying to copy a .nupkg file created in a prior Build task to the drop folder.
...In the Build Process...
From the log, I know that the file was created.
Successfully created package
'C:\agent_work\9\a\StaticHelpers.1.0.0.nupkg'.
What I am trying to figure out is how I can find this file and copy it to the drop folder. Using Build Variables for inspiration, I have tried the following. At first, I thought it was successful because of what the log said.
Source Folder: $(Agent.BuildDirectory)
Contents: *\*.nupkg
Target Folder: drop
Result:
found 1 files Copying C:\agent_work\9\a\StaticHelpers.1.0.0.nupkg to
drop\a\StaticHelpers.1.0.0.nupkg
All that means is that I can create a release process that takes that file and copies it in a copy release step, right?
...In the Release Process...
Not right. There is nothing in the drop folder when I created a copy file release task and tried to select the nuget package that was definitely created in the build. What I need to do is take that *.nupkg file created during the Build process and copy it to a network share.
So I tried to hard-code the folder based on what I copied from the build log.
Source Folder: drop\a
The release failed, showing this in the log:
[error]Unhandled: Not found SourceFolder: C:\agent_work\r4\a\drop
Either I am copying the file to the wrong location or I am reading from the wrong location. What folders do I need to use so that I can see the *.nupkg file in my release task?
In your build process, don't use a Copy Files task, use a Publish Artifacts task. That will publish an artifact "attached" to the build that a release will automatically pick up during deployment.
These are my MS build arguments
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\CC
What should I use to Publish only binaries using Publish artifacts. I am getting code files only.
If you just want to output the files without zip, then you can try below ways:
Specify the argument OutputPath only (without specify the package
related arguments):
e.g:
/p:OutputPath="$(build.artifactstagingdirectory)\cc"
You can also output the target files to a shared path (UNC path):
e.g:
/p:OutputPath="\\myshare\DirA\0313"
Then use Copy and Publish build Artifacts task to publish the
files. Alternatively you can add a Copy Files task to copy the
files from OutputPath to a Temp folder, then use Publish
build Artifacts task to publish the files from Temp folder.
Reference the first screenshot.
Another workaround is using the publish profile:
Create a Folder publish profile, you can chose a shared folder
to publish. (Refer to this link to create the publish profile)
Add below MSBuild arguments in VS build or MSbuild task:
/p:DeployOnBuild=true /p:PublishProfile=YourPublishProfile
Check the published artifacts.
Reference the second screenshot:
In my TFS 2017 build definition, I am trying to copy a folder with a specific name (Package) towards my Artifacts directory. I am only interested in the specific folder itself, not in it's parent folders.
Can someone enlighten me on how I should make this work?
Current configuration for the Copy Files task:
Source: $(agent.builddirectory)
Contents: **\Package***
Target Folder: $(build.artifactstagingdirectory)\MyArtifact
This results in the following folderstructure while my only interest is the Package folder:
\MyArtifact\folderX\s\folderY\folderZ\folderA\Package
With TFS2017update1 and above, VSTS, you could simply check Flatten Folders under Advanced option in Copy Files Task. The easiest solution for now.
This will flatten the folder structure and copy all files into the
specified target folder.
Not sure if you are working on 2017 release version, and there is no Flatten Folders option. You need to specify the copy root if you want to copy files only without folder structure. You can use $(Build.StagingDirectory) as a target for this. Afterwards use the Publish task with $(Build.StagingDirectory) as copy root and publish everything from this root to the drop.
Detail step and screenshot please take a look at the answer from Eddie in this question: Copy one file in target directory on deploy from visual studio team services
If the relative path to "package" does not change, you can specify the detailed path in "Source" to achieve the feature you want.
For example, configure the Copy Files Task:
Source Folder to: $(agent.builddirectory)\folderY\folderZ\folderA\Package
Contents to: **
Target Folder to: $(build.artifactstagingdirectory)\MyArtifact\Package
You will get the folder structure you want.
While all answers were correct in some way, it was not what I intended to achieve.
I ended up creating my own PowerShell script to copy the package folder and it's contents to the Staging Directory:
$BasePath = [System.IO.Path]::GetDirectoryName("$(SolutionPath)")
$Search = "PackageTmp"
$Destination = "$(Build.StagingDirectory)"
Get-ChildItem -Path $BasePath -Filter $Search -Directory -Recurse | Copy-Item -Destination {Join-Path $Destination $(ArtifactName)} -Recurse -Force
IN TFS 2017 on-premises site, I've put together a TFS build that generates several database builds and SSIS package builds. it produces the desired dacpac and ispac files. However, when created, these files are placed in a hierarchy, based on the particular project structure. It looks something like this:
Database1
\bin
\Release
\database1.dacpac
Database2
\bin
\Release
\database2.dacpac
ssisPackage
\bin
\Development
\ssispackage.ispac
I would like to copy all of these files (*.dacpac and *.ispac) to a single
directory (flattened) when pushing them out to my team. However, the Copy Files task is copying them and preserving the folder structure.
The Contents block of the "Copy Files" task is:
**\bin\$(BuildConfiguration)\**\*.dacpac
**\bin\Development\*.ispac
and the Target Folder is
$(build.artifactstagingdirectory)
Is there a way to move this files to the target folder without the folder hierarchy, resulting in:
OutputFolder
\database1.dacpac
\database2.dacpac
\ssispackage.ispac
Thanks for the advice
Refer to these steps to achieve your requirement:
Create a bat file with code below and add to your project, then check into source control (%1 means first argument, %2 means second argument)
Code:
pushd %1
for /r %%a in (*.pdb) do (
copy "%%a" %2
)
popd
Add Command Line build step to your build definition
Note: This code is used to copy pdb files, you need to modify it per to requirements.
in Jenkins, I have a job downloadAgents that is responsible of creating a folder and populating it with some files. Then the folder is saved as an artifact with the following folder structure
dev\downloadAgents\target\dependency\ios
Then I need to copy the contents of the ios folder into the workspace of another job (into a specific folder).
I have added the Copy artifacts from another project step. And it does copy the artifacts, but it copies the full path
\dev\downloadIosAgents\target\dependency\ios
How can I tell jenkins to copy only one folder ios and everything that is inside it and, do not copy all folders that are before ios.
Also if there are already files in the destination folder, will it merge the 2 folders?
You can use regex for your copy (under "Artifacts to copy")-
dev\downloadAgents\target\dependency\ios***.*
** - all folders under ios
*.* - all file types
You can also specify the target directory, and you also have a flag for "Flatten directories". This will move all the files without the hierarchy of the folders (flat to your target directory)
Feel free to look at the plugin's home page:
https://wiki.jenkins-ci.org/display/JENKINS/Copy+Artifact+Plugin
In CopyArtifacts plugin specify the pattern: \dev\downloadIosAgents\target\dependency\ios\*.* or \dev\downloadIosAgents\target\dependency\ios\** - I don't remember exactly.
That should do the job.