autodeployment of tfs build - tfs

I have a software that up to now was run with UI or command scripts. My job was removing all UI and make it run automatically using tfs builds.
Using TFS 2012 VS 2012
My questions:
1. How to run software that it is being build. I tried with MSBuild Arguments using
/p:DeployOnBuild=True /p:DeployTarget=Package /p:CreatePackageOnPublish=True
/p:OutputPath=bin /p:VisualStudioVersion=11.0 /p:MSDeployPublishMethod=InProc
/p:MsDeployServiceUrl=localhost
/p:DeployIisAppPath=#"\\filer01\FDrive\public\documents\new\\"
No errors, but my testing solution doesn't produce anything. For testing it should create a file. Same code works fine from within custom code activity so it means the software doesn't run. I want to run software from source control.
Question 2. What is the best way to pass arguments from TFS Build Definition to software I am Building and Running? Can I call them from withing software?
Edit:
Solution:
custom activity:
var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = String.Format("{0}\\TestingForm.exe", binaries)
}
};
process.Start();
process.WaitForExit();

I've never tried the DeployIisAppPath argument but we routinely used TFS build definitions in the past to deploy our code to a remote IIS server. Works great. Maybe you can try dropping the DeployIisAppPath and deploying to local IIS instead?
The MSBuild arguments can be accessed during the build step. You can instruct MSBuild in your wpp.targets file to take those values and use them to alter the application files but it all depends how you want to use them.

Related

VS2015 build with TFS2013

I'm trying to do a teambuild for a VS2015 solution with TFS2013.
On the buildserver VS2015 is installed and I changed the buildtemplate so msbuild has an argument \tv:14.0, but when a start a build I get the following error:
C:\Program Files
(x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets (96):
Invalid static method invocation syntax:
"[Microsoft.Build.Utilities.ToolLocationHelper]::GetPlatformSDKDisplayName($(TargetPlatformIdentifier),
$(TargetPlatformVersion))". Method
'Microsoft.Build.Utilities.ToolLocationHelper.GetPlatformSDKDisplayName'
not found. Static method invocation should be of the form:
$([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(a,
b)).
The buildserver has been restarted but I still get the error.
I also checked this thread: Build failed in TFS but no real answer was given there. Is there anyone that knows how to solve this.
I was experiencing the exact same error. I determined that TFS2013 was the RTM version so we installed TFS2013 Update 5. Now if I run using the *.12.xaml process template with the /tv:14.0 /p:VisualStudioVersion=14.0 parameters the build succeeds. I have also made a copy of the *.12.xaml build process and named it *.14.xaml and changed the Run MSBuild steps ToolVersion property to "14.0" and this build works as well, without the parameters.
You need to customize the build process template by finding all the Run MSBuild for Project MSBuild activity, then set the ToolVersion to "14.0" and set ToolPath to target to MSBuild14 (by default: "C:\Program Files (x86)\MSBuild\14.0\Bin"). After that, check in the build process template and re-queue the build.
Check the solutions here:TFS 2013 building .NET 4.6 / C# 6.0

How to Invoke and Kill Executable in TFS Build Definition?

I am developing a Web API solution. This EXE listens and responds to localhost:8080/abc/.
I have developed a Test solution for this executable.These tests simply verify responses from localhost:8080/abc/.
I have already successfully created a build definition that:
Gets and compiles the solution.
Gets and compiles the tests.
Runs the tests.
My problem here is, the tests are failing, because the EXE isn't up and running. How do I bring up the EXE for the tests, and kill it after the tests are done? Could this be done solely in the build definition itself? Say via MSBuild Arguments in the "Build process parameters"? Hopefully there is a simple solution to this...
Thanks in advance!
I can't manage to solve this in the build definition alone.
I found the solution in modifying the build template (via Edit Build Definition... -> Process), by adding InvokeProcess controls in the build flow. Have these controls call BAT files that instead run / kill the EXE.

Schedule a task after deployment

I need to setup a scheduled task in Windows Task Scheduler (v2.0 on Windows Server 2008 R2) right after my web site deploys.
I am using TFS 2010 to build my application, and apparently my MSBuild Arguments contain arguments /P:DeployOnBuild=True /P:DeployTarget=MSDeployPublish /P:CreatePackageOnPublish=true /P:MSDeployPublishMethod=WMSvc.
I know that I can use Schtasks.exe to setup a scheduled task via command line, I also know there is a runCommand provider for MsDeploy. So I thought I could use runCommand to run Schtasks.exe with required parameters.
My question is how I do it in TFS and MsBuild. I assumed I could pass some parameters to MsBuild, and they would be transferred "as is" to MsDeploy, but I could not find how I do it.
If it must be after the build, you'll need to use the postSync msdeploy argument to execute a runCommand. Since postSync is not available from Visual Studio's MSBuild tasks, you'll need to generate a package and then run the generated cmd file with the postSync argument tacked onto the end.
Package.cmd -postSync:runCommand="c:\windows\system32\schtasks.exe arguments"
If it should be after the build, you can include an additional provide by adding the following to your publish profile (pubxml), .wpp.targets file or your project file:
<ItemGroup>
<MsDeploySourceManifest Include="runCommand">
<Path>"c:\Windows\system32\schtasks.exe" "Arguments here"</Path>
</MsDeploySourceManifest>
</ItemGroup>
It's not officially guarantees that providers run in order, but in practise they do. You might need to hook a target into the right event, though, so you can register your runCommand after the other providers.

Trying to run corflags from TFS Build 2010

I am using an InvokeProcess activity in TFS 2010 to try and run the corflags application on a built exe.
C:\Builds\4\testing\Sources\BuildAssets\corflags.exe C:\Builds\4\testing\Binaries\Executable.exe /32bit+
However I am getting the following message:
corflags : error CF001 : Could not open file for writing
I am running the TFS Build Agent on my local machine because I am currently in a testing phase, and when I run the exact same command from the command line, the corflags application completes without error.
Any ideas would be greatly appreciated.
I'm not familiar with the specific situation but some general ideas:
Who is the build running as? Does that user have permissions to the output path?
Another consideration is: Has the build completed before it attempts to execute your command?
Try changing the command to be something really simple eg Type "OutputFile" - Does this hit the same issue? If so, it's a permission/timing issue. If not, it's the specific command - but at least we'll have narrowed the problem down.
I don't know the corflags either, but it is using a file in the workspace (a file that is downloaded from Version Control). There is a readonly flag on this file by default.
So if you need this file to be writable:
1) either checkout the file if you need this file in your version control and afterwards check it in again (tf checkout / tf checkin)
2) remove the file from version control if the file is created by the app
3) remove the readonly flag with the attrib command.

Running Delphi builds under TFS MSBuild

Wanting to build and test a bunch of Borland Delphi 6 projects that are integrated with ASP.NET services. Had been using WANT and CruiseControl for building Delphi. With TFS Build agent we can tie all together and do some testing. I am looking for guidance and direction.
One issue I see is that there is no "solution" in a Delphi project to be given to MSBuild as a '<'SolutionToBuild'>'.
<SolutionToBuild Include="There is no such thing as a Delphi.sln">
<Targets></Targets>
<Properties></Properties>
</SolutionToBuild>
Also, I have references to <UsingTask> but am a little unsure how to use them. The <UsingTask> allows run custom task for Delphi command-line compile.
Your guidance would be appreciated.
Can you upgrade? Delphi 2006+ uses MSBuild by default. There is nothing to configure.
You can use MSBuild to run the Delphi command line compiler. It's been a while, but I'm pretty sure either the IDE supports command line compilation or there is a stand-alone compiler that can be run from the command line. In either case, you would need to create an <Exec> task that runs the appropriate command line build tool with the required parameters.
When you say you have "references to <UsingTask>" do you mean that you are importing an external MSBuild task? The <UsingTask> element is used to pull in a custom MSBuild task that resides in an external assembly (DLL). Once the task is imported, you use it just like you would any other built-in task.

Resources