How to pass arguments to command line build task in VSTS? - azure-devops

Can anyone briefly explain to me how to add build and pass arguments to command line build task in VSTS (TFS Online) or suggest me some good links?

The build task is actually a wrapper around MSBuild. So whatever you can achieve using MSBuild, can be passed to the build task.
MSBuild Documentation

Related

NDepend Task for Nant

I am in process of creating a Nant BuildFile which will use MSBuild, Nunit, Ncover and Ndepend for compilation, unit test, code coverage and Code quality check. I am not able to find any task for Ndepend in Nant. It would be helpful if someone can share the task syntax.
Regards
Anuj
The command line options are available at:
http://www.ndepend.com/docs/ndepend-console
These can be executed through Nant scripts as mentioned in below link:
http://ncodex.googlecode.com/svn/tags/0.3.0.50/Build/Packages/nDepend/bin/NAnt/ReadMe.txt
There is just one mandatory argument. All other arguments can be passed in any order.
It is a popular tool and I am surprised not many posts are available. I missed the command line argument page in NDepend site because it is by the heading NDepend Console. Hope it helps others going forward!!

Pause TFS build definition via powershell

I would like to create a powershell script that pauses a TFS build definition programmatically. So far, tf.exe doesn't seem to offer any kind of functionality for that. Is there any library or api I can use to achieve this?
There is no easy way known to do that in TFS build. Perhaps stop the build service(the build will hang up ) can be easily executed when the scheduled scripts are running.

Queuing a build using Powershell

I want to use a powershell script to queue a TFS build( prompting the user to enter the custom build defination) and wait until the build completes and check the status of that build and do a copy if it succeeds or exit if it fails. I would like to thank you in advance for taking time to answer my question
The simplest way is to use tfsbuild.exe command. This tool is located in Drive:\Program Files\Microsoft Visual Studio xx\Common7\IDE. More detail info to use start command: https://msdn.microsoft.com/en-us/library/ms181742(v=vs.100).aspx
You can also use a script using the APIs, How to queue another TFS (2012) Build from a TFS Build AND pass process parameters?
Which things your want to copy? In the build definition, you can specify a drop folder to copy your build outputs in it.

Fail a Build if Code Coverage is Low in Visual Studio Online

I'm trying to fail builds in Visual Studio Online when Code Coverage is below a threshold.
Is there anyway to do it under Visual Studio Online or I have to do it using the XAML Build Definitions.
It is possible to control build result with code coverage percentage result in both vNext build system and XAML build.
In vNext build, you need to add the PowerShell step in the build definition, and run one PowerShell script to determine whether the build failed or succeed. Check this blog for the details of the PowerShell script: http://blogs.msdn.com/b/tfssetup/archive/2015/11/06/controlling-build-result-with-code-coverage-percentage-using-build-vnext.aspx
If you work with one XAML build, you need to create a custom build activity in which contains the logic to fail or pass a build based on code coverage result. Then include to use the build activity in the build definition. See: http://blogs.msdn.com/b/tfssetup/archive/2015/11/06/controlling-build-result-based-on-code-coverage-percentage-for-xaml-builds.aspx
My preferred method is to use the standard XAML build process in Azure DevOps pipeline. Use the code analysis task to fail the build if coverage is below a threshold.
See: https://learn.microsoft.com/en-us/archive/blogs/tfssetup/controlling-build-result-based-on-code-coverage-percentage-for-xaml-builds

Automatization Build Server TFS 2008 (vs 2008)

I use VS 2008, Team Explorer and TFS. I'm looking to automate your builds by executing TFSBuild.exe command.
I follow those steps:
Open TeamExplorer, in VS2008, connected to TFS;
My Team Project has a Build (named MainBuild) in Builds. Then, I do Query New build option.
I fill the properties in window dialog opened:
build Definition: Mainbuild
Build Agent: Machine1BuildAgent
drop folder for this build: \Machine1\Build_drop
priority in queue: Normal
MsBuild command-line arguments:
/p:BuildAll=false /p:RunTest=false /p:SkipClean=true /p:SkipGet=true /p:SkipLabel=true /p:SkipGetChangesetsAndUpdateWorkItems=true
In MDSN I have seen TFSBuild command and this sample:
The following example builds the Nightlies build type which is in the AdventureWorks team project on server01. The resulting build is located on Machine1 in the BuildDrop directory.
TFSBuild start http://server01:8080 AdventureWorks Nightlies /m:Machine1 /d:"C:\BuildDrop"
edit: Now, for my issue, how can I do automation for build MainBuild for set the values for "MsBuild command-line arguments" using TFSBuild.exe command ? I'm looking for a way to automatically have the TFS Build Agent job run nightly with command-line arguments..
I need similar command line like this:
TFSBuild start http://machine01:8080 MyteamProject MainBuild /m:Machine1 /d:"\Machine1\Build_drop" /p:BuildAll=false /p:RunTest=false /p:SkipClean=true /p:SkipGet=true /p:SkipLabel=true /p:SkipGetChangesetsAndUpdateWorkItems=true
I need pass the arguments (MsBuild command-line arguments) to TFSBuild.exe command and automatize the TFS build.
any sample scripting code ?
You can pass MSBuild properties to TFSBuild using the /msBuildArguments switch
TFSBuild start http://machine01:8080 MyteamProject MainBuild /m:Machine1 /d:"\Machine\Build_drop"
/msBuildArguments:"/p:BuildAll=false;/p:RunTest=false;/p:SkipClean=true;
/p:SkipGet=true;/p:SkipLabel=true;/p:SkipGetChangesetsAndUpdateWorkItems=true"
Alternatively, you could also specify these properties in the response file TFSBuild.rsp.
I'm not sure I understand your question clearly, but if you're looking to automate your builds by executing MSBuild from the command-line, you can create a batch file to execute the necessary command using the command-line arguments you want. Then add a scheduled task to 'Scheduled Tasks' in Windows so that this batch file is executed on a regular (e.g. nightly) basis.