How to keep artifacts directory during the multi-configuration build in TFS? - tfs

I have a solution with multiple projects where some are web apps. I have set up a multi-configuration build in TFS vNext that builds the single app, creates an MSDeploy package, gets the proper staging configuration files and add or replaces the files in the package archive file.
I'd like to use the deployment files created as artifacts to be used in a Release Management pipeline. The problem is that the artifacts directory is purged before each build (i.e. build of a web application). At the end, only the artefacts of the last app that was built are left there.
I can certainly configure the step to copy the artifacts somewhere else, but then the question is how to delete it only at the very start of the build (and by that I mean the build of all projects).
Is there a way how to disable purging of the artefacts directory or how to perform an operation only at the beginning of the build? Has anyone similar experience?

Use the "Publish Artifacts" task to store the artifacts in a UNC location or in TFS itself so they're available for release.

Related

How to archive all the build versions (Artifacts) in target folder

Each time i generate my build through jenkins, my existing jar file in the target folder is overwritten by maven. For example: i have a existing version of 1.0 in jenkins target folder, now if i create a new build with version 1.1, the previous version in my target folder gets overwritten.
I don't want that to happen, i want to archive all the versions (because we might provide some of the old features to certain set of customers). i am just trying to understand is there way to do this in jenkins pipeline. I don't prefer plugins, it would be nice to do it declarative way using jenkins file.
First of all, it's not the best solution to store your artifacts just in target folder without any copying to other place. Usually all needed build artifacts are stored in Nexus or Artifactory repositories (of course, you can copy them to some local directory also). You can do that in pipeline Jenkinsfile as well, but you still require to install needed plugin. For example, for publishing artifacts to Nexus repo, you can use Nexus Platform Plugin, see this answer for details.
About overwriting your target folder, I'm not sure if it's cleaned by Jenkins by default. To clean workspace, you need to specify Discard old builds option in job configuration first.
Seems to be that you just execute mvn clean ... command, that's why target folder is cleaned, so I would recommend to check that first.

TFS 2017 release management artifact files from version control

I would like to access some files from source control (tfvc) while release management.
The sources I found are either build (type "Build") and the whole source tree (type "Team Foundation Version Control").
The type "Team Foundation Version Control" seems to match, but it is not allowed to select sub folder, e.g. "$/MyApp/branches/V2/scripts".
Do I need to create an artifact for the script files?
Instead of linking in a separate repository, I'd strongly recommend either publishing them as a build artifact (as the other answer mentions) or publishing them as a versioned NuGet package.
The reason is because everything that goes into a deployment should be versioned together. Scripts that are changing out of sync with everything else can cause abrupt deployment failures for unknown reasons. Let's say you linked those scripts in as an artifact and started a deployment along your pipeline from Dev -> Production. Dev deployment is fine. QA deployment is fine. Staging deployment is fine. Production deployment... fails? Because of an error in the scripts?
Whoops, someone committed a change to those scripts and introduced a bug. But the scripts weren't versioned, so you had no way of guaranteeing that the scripts being used in prior stages were the same as the scripts being used in your production stage.
You can save your source code as a artifact in your build process. Use the "Publish Artifact" step to publish your source code in Tfs or on a unc path. After that release management downloads your artifacts as the first step.

Release Management in TFS without build automation

We have an automated build process in place which creates the release artifacts for us.
These are copied to an FTP location and post certain processes, the packages are available for deployment to val, customer dev, UAT and prod.
I want to create a Release in TFS where the release should simply use the package from the ftp location instead of triggering a new build.
The process of moving the artifacts to the ftp using a detached build process is legacy and I'm afraid cannot be changed.
I would like to trigger a release ( at the moment I'm testing this using VSTS ) which will use the artifact from an ftp instead of triggering a build.
My build server / process is not in TFS and it's a large application with multiple components.
Trigger a release using the artifacts from an FTP instead of triggering a build is supported. But there's no default steps about download a FTP file for you to use. You need to use command or Powerscript to download.
In the release definition, delete all artifacts under the Artifacts tab. Then it won't download any files from your builds.
Create a bat file or Powershell script file, write the command/script to download those files you want. Here are some methods you could have a look:
How to script FTP upload and download?
How to download files from FTP site in one command line without user interaction (Windows)
https://tecadmin.net/download-upload-files-using-ftp-command-line/
Check the bat/script to TFS and run it in your release definition.

VSTS Build Not Dropping All Files for Web Application

When I started writing this question, my problem was that after a successful VSTS Build, I wasn't able to see the files relating to my web application project for release. Only the files from certain other projects in the solution were present. However, I just came across this question, which has helped.
I can now see the compiled .dll files for my web application project, after altering the configuration of the Content setting in the Build - that is, the contents of the Bin folder under that project. But I can't see anywhere the other files I need to copy the built web application to my server - the views, the scripts, the css, etc.
I'm finding the power and flexibility of VSTS's Build and Release functionality very confusing as it's complete overkill for our requirements. Up until now, I've just right-clicked on the web app project in Visual Studio selected Publish and used the File System publish method. Easy. Now that I want to automate the building and deploying of the application, it's many times more complicated!
So, can anybody tell me how I can get the solution to build in VSTS in such a way that I can then use a Copy Files task in the Release Definition to copy the files to our web server (the server isn't visible to the Internet so I'm using a locally-hosted Agent)?
In vNext build, to publish your build artifacts with the Copy files or Publish build artifacts steps. Try to use the local path on the agent where any artifacts are copied to before being pushed to their destination. For example:
Add /p:DeployOnBuild=true
/p:OutDir="$(build.artifactstagingdirectory)\" arguments in Visual
Studio Build step;
Change "Path to Publish" of Publish Build Artifacts task to
$(build.artifactstagingdirectory)\_PublishedWebsites\ProjectName:
Details please check the screenshot of build step with this question: How do I get the the expected output from a TFS 2015 build (to match my XAML build)?
Base on your comments, you have published the web app from Visual Studio. Usually, this action will generate a publish profile under Project/Properties/PublishProfiles folder. The settings you used to publish the web app is stored in the profile. So you just need to make sure this publish profile is checked into source control. And then in the TFS build, add following MSBuild arguments:
/p:DeployOnBuild=true /p:PublishProfile="publishprofile.pubxml"

Adding files via the build server to TFS in a deployment area which is in another location on TFS

I have an application which compiles and runs all okay on our TFS build server.
Now I need to place the files in a deployment area in TFS, as part of the build process on our build server, which is not a workspace that is being used by the build.
I have tried using MSBuild.ExtensionPack.VisualStudio.TfsSource and the Working Directory but this does not work and I need an alternative
We've done something similar by adding an msbuild proj to our source control and then after building our solution, we build this proj which then calls a copy task which moves some files to another folder. Think you can do something similar by editing the default template too (which we didn't want to do)

Resources