TFS Build Queries for Non .NET supported files - tfs

We are using TFS for maintain file versions of our database.
We do not have any .NET application in our Source Control; only HTML and supported CSS files only.
Is it possible through TFS Build Automation process to create Zip package and Deploy the package to drop location?
Note: We Do not have any .NET project or solutions only need to deploy folder(with HTML and supported files) in zip format.
I somewhere read that TFS build definition compulsorily needs .SLN files to have build project.
We don't want to build anything or test anything
Just want to create zip and deploy same to drop location.
I have tried some tweaking of Build Definition.
But in New Build definition in process tab it asks me for Items to build, where my selection is restricted to .NET supported files only.

You will need to create a custom MSBuild project file (.proj) to perform the work that you need. You can test this file locally in the command line and then when it is ready, you can point the Build process at it.
This is a good starting point for you http://www.developerfusion.com/article/84411/customising-your-build-process-with-msbuild/
The MSBuild Community Tasks (https://github.com/loresoft/msbuildtasks) contains a Zip task which should make the job a lot easier.

Judging by your description, you are using 2010 or later. What I would do is to create a custom build template that does all of what you are looking for. If you start with default template obviously you would want to remove all of the compile and test activities and replace it with the zip and copy it to the binaries directory (From there it will be moved to the drop). You could do 1 of two things for the solution file requirement, create a fake solution file in the workspace and use that knowing it won't be compiled. Or you could, in the template, remove the Argument BuildSettings which is the object that contains the solution file and configurations.

Related

TFS - Versioning file in a drop folder

We currently use TFS 2010 for controlling some of our .NET projects.
I'd like to know whether it's possible to provide some kind of versioning within TFS for a specific folder on a network share for example.
The idea being is to control release packages (zips) for every release we do. As this bit is done by some other person (not technical and he doesn't use Visual Studio or any tech tool), it'd be great to streamline the process of versioning the zip files for every release.
Technically speaking:
We've setup this folder \servername\releasezips and every time I drop a file named release.zip, it would automatically commit (push) this file to the TFS server (no comments needed) and furthermore, once the file contents change (meaning that someone dropped another version of the file in there), the system would again push the file to TFS, but with a following version.
Is this possible somehow? I've seen somewhere that I could programatically have some extra control over TFS, using REST API.
Thanks in advance!
Thanks for your tips, Daniel and PatrickLu-MSFT.
As I said, I did want something straighforward, some kind of control similar to what box.com provides, where you associate a local folder on your machine with the cloud. So, once you drop files in the local folder, the small box client synchronizes it along with the cloud. If access the box.com, I can see the different versions of that specific file.
So what I did was, I've created a small .NET app to monitor the folder and any new files dropped in there would get checked in to our TFS server, by using the tf command line (of course ignoring work items or comments).
So, progamatically within the .NET app, it builds up the tf required commands for processing and versioning the recently dropped files and therefore, executes them.
By the way, I could have used the Team Foundation API in order to do the same job, but it would demand way more effort.
Cheers
According to your description, you want to commit/check in files during the build/release pipeline.
It's not a recommend way to check-in generated build files and modify source code during a build pipeline. If you really want to do this, you could edit the build workspace files and use tf commands in custom activity and call the powershell eq:
cd $env:BUILD_SOURCESDIRECTORY
$TFFile = Get-Item "C:\Program Files (x86)\Microsoft Visual Studio 1x.0\Common7\IDE\TF.exe"
$tfOutput = [string]( & $TFFile.FullName checkin /noprompt /override:"***NO_CI*** New version is $newVersion." /comment:"***NO_CI*** New version is $newVersion." 2>&1)
Another way is installing TFS Power Tool and use the Windows PowerShell Cmdlets to check in the files. Refer to this link for more details: PowerShell and TFS: The Basics and Beyond
For version the dropped files, you could take a look this similar question: TFS Build Copy to Versioned Folder
Basically, you have to customize build definition with custom activity and based on build.buildnumber variable to generate/create .zip file.

MSBuild Logging

I am relatively new to tfs. I am creating msbuild logfiles during a build, but they are not getting moved to the drop location.
I am attempting to move a teambuild from 2010 to 2013. Due to versioned namespaces, I recreated the workflow template from a fresh default from the tfs server. The build is successful and the binaries are placed in the drop location via custom activity.
MSBuild is used four times on the workflow. Each has a unique LogFile name and use the same LogFileDropLocation. I get the binaries without the logfiles in the drop location. Using a diagnostic build, I do see that LogFileDropLocation has the correct drop location. However, my log files remain on the agent and do not get moved to the drop.
In the 2010 build, I get binaries and four logfiles in the drop location.
My question is, should Microsoft.Teamfoundation.Build.Workflow.Activities.MSBuild handle the copy/move of the log files, as I suspect, or later in the workflow? MSDN and the several books I have don't actually discuss how msbuild handles the logging. I am hoping someone knows specifically how MSBuild handles the logfile.
You need to put the XML files in your project and mark them as Content. They will be copied to the bin folder as output.
Example: Create a new project in visual studio. Them create an empty .xml file in the root of the project under source control. Right click and mark it as Content. Build the project.
You should see the bin folder has been created and the .xml file has been copied to that location.
This output is considered "compiled" or "generated" even though it is a copy. You may want to do some build processing to add parameters later.
When calling the MSBuild utility you can add parameters and have MSBuild handle the log file the way you want. I don't know the TFS workflow you've described so see how you could add that there.
You command can look something like this:
MSBuild.exe /target:Build Solution.sln /filelogger /fileloggerparameters:LogFile=C:\path\to\file\build.log;Verbosity=normal
Loggers are explained here (under Switches for Loggers): https://msdn.microsoft.com/en-us/library/ms164311.aspx
Verbosity is explained here: https://msdn.microsoft.com/en-us/library/microsoft.build.framework.loggerverbosity.aspx

TFS - Workspace to build definition with only required files

In our project we are building project with TFS build definition feature.In TFS build definition there is one option like "workspace" where we mention all require folders which contains file which used to build project successfully. We have separate folders as per requirements which contain different units. this units are in large numbers hence when we build project and mention any folder in workspace then it extract all files in that particular folder. actually we require only few of them for project build because we used different files per project but that files under same roof.
could any one help us that how we build our project with only require files in workspace rather than whole folder?
Status =Active Source control folder =$/Artiion/ADO/LibForms/Loginf.pas: Build agent Folder=$(SourceDir)\LibForms\Loginf.pas
above example works fine
There is no reasonable way to do this. When you tell TFS Build what source folders to use, that is what you are telling it: get these folders. In theory I suppose you could modify or write your own process template and provide custom fields in which you could provide data to the build process about what files you need for that build, and then create some custom action to call out that would then replace the standard TFS Get function in the process template. But what would be the purpose? If you have certain files that are to be included in the solution build, then simply have separate solutions or projects which would include the appropriate files. Then build the specific solution based on which subcomponents you need, and then only those files will be built and copied to the drop location. Sure, they would still have been retrieved in the build agent's workspace, but they would not have been used in the actual build or placed in the drop location. If that's not good enough, and you need to actually Get different groups of files per build, then you should rearrange your files so that the necessary files are in the appropriate subfolders.

Dropping a build in a fixed location

I have a build process that I've defined with a custom build process template, and I'm looking for some advice on how I can solve a problem I've run up against.
The build process (TFS 2012) is used to build the code that drives our load tests, and I have a separate process that needs to reference a specific path within the drop folder so that it is always using the latest version of the load test code. Automated load testing, pretty standard stuff.
However, I'm wondering if there is a way to get the TFS build to overwrite files it finds in the drop folder. Right now I have it set up to drop to a very specific folder, and not put anything that would change in the folder name (no build number, date, etc.). The thought is, this way the automated utilities that rely on those files have a fixed point to look at.
However, when I currently run the build it gives me error TF42064: The build number '<build>' already exists for build definition '<build>'.
Currently I have the build definition set up to only retain the latest build, because this process is specifically for those automated tools. We have other build processes that are fired for debugging/troubleshooting/logging purposes. Is there a way to get the build definition to overwrite the drop folder each time, or will I have to dig into the .XAML template file to have it delete the folder it finds before the build fires?
The way I approached this requirement was to start with the default template and let the build copy to the normal drop location which allows me to keep historical builds in the same way as all other builds.
Once the build has been completed I then copied to a single drop location from the standard drop location by extending the standard build template, the activity was added just before Check-In gated changes.
The steps involved were as follows:
Within SharedResourceScope:
Delete Unified Drop Location
Create Unified Drop Location
Copy Directory (source: BuildDetail.DropLocation)
By default TFS Build creates a new folder, using the unique build name/number, and drops the files there.
If you want to change this behaviour to overwrite files in a known location (instead of creating a new folder each build) you need to modify the build workflow/XAML (as #Oswald mentioned in the comments).
You can read about customizing TFS Builds from the ALM Ranger Build Guidance on CodePlex: http://vsarbuildguide.codeplex.com/

TeamBuild - Is it possible to choose what projects to compile at build-time?

I am automating my build process using TeamFoundation and I need to choose what projects to compile according to the .proj file from the build. Here is the full scenario:
I have a .proj file which uses a .sln file in order to compile a solution which contains 2 websites. The .sln file is configured to compile both websites in Release configuration.
My goal is to compile only 1 website per build type, namely I want the BuildType1 to compile website 1 and BuildType2 to compile the website 2.
Is is possible to "modify" the .sln in such a way that I can unmark one of the websites to compile? Since it is an automated process, I can't change the .sln manually every time I want to compile only one website.
Look at the SolutionToBuild section in the TFSBuild.proj file.
<SolutionToBuild Include="$(BuildProjectFolderPath)/path/MySolution.sln">
<Targets>MyCustomTarget1;MyCustomTarget2</Targets>
<Properties> Configuration=Release</Properties>
</SolutionToBuild>
There are two main ways you can control the build:
create a separate Build Type in your Team Explorer. This will have its own completely independent TFSBuild.proj file, so it can build the same code-base in a completely different way. Set the SolutionToBuild up to build just what you want (as described in the accepted answer).
Use one Build Type, and set its TFSBuild.proj up to use a property to control what is built (this requires more in depth understanding od MSBuild scripts). In the Queue New Build dialog you can then use the /p: command line flag to set the property as you need it. e.g. "/p:IncrementalGet=false;IncrementalBuild=false;ForceGet=true" will force a normally incremental build to do a full rebuild. This is useful for occasoinal situations, but not a good idea for day to day builds as you have to set the parameters by hand every time.

Resources