TFS 2015 vNext UsingTask - tfs

Until last year we used a an MsBuild file for our build definitions. Since this year we want to use the new vNext buildsystem in the TFS 2015.
And this is my question:
In the xaml file we have a line like
<UsingTask TaskName="ReplaceTextInFile" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
to use it later in the xaml like
<ReplaceTextInFile
InputFilename="$(someFolder)$(someOtherFolder)\someFile.config"
OutputFilename="$(someFolder)$(someOtherFolder)\someFile.config"
MatchExpression="$(somePattern)"
ReplacementText="$(someText)"
/>
How do I implement this to the new vNext???

Because this is an MsBuild snippet you've posted, you could simply use the Run MsBuild task and execute the old project file.
But if you are set on porting, then you have a few options:
Use one of the Replacement extensions from the VSTS marketplace, there are a few, I personally have good experiences with this one or this one.
Create a powershell/shell/batch script that does what you want and use the (inline) (power) shell task to run the script as part of your build. Powershell has very powerful regex options using -match and -replace.

Related

autodeployment of tfs build

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.

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.

TFS Build Error While Invoking custom build file via TFS Build definition

I use TFS 2010, VS 2010.
I wrote a custom msbuild proj file which I use locally to build my solution. I use MSBUILD.exe TFSBuild.proj and it does everything in my local machine. (I have a taregt called 'DoMyBuild' which kicks off the build and does everything.)
I have used this in the DefaultTargets attribute as below:
<Project DefaultTargets="DoMyBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
I am trying hard to configure this to use my build server with a build definition. In the build definition, under Process - I configured 'Upgrade Template' and in the build process paramters, have given the path to this TFSBuild.Proj file.
Ideally. TFS should start 'DoMyBuild' target as I read. But it gives a error looking for 'EndToEndIteration' not defined. So, I believe it is still doing a DesktopBuild which I dont want. I want to use my custom target to kick start. Is this possible ?
Any help is very much appreciated.
Thanks, Mani
You problem is discussed here.
Make sure you have at least an EndToEndIteration target defined in your MSBuild project.
<Target Name="EndToEndIteration"
Condition=" '$(IsDesktopBuild)'!='true' "
DependsOnTargets="$(EndToEndIterationDependsOn)" />

Using MSBuild task for ftp a directory in TFS 2010

Is there any tutorial to show how can I use MSBuild tasks like FtpUploadDirectoryContent to copy file/directory to a remote host using FTP in Team Build 2010? I never used a MSBuild task in TFS 2010.
Just put it in the AfterBuild target of one of your projects - probably best to put it in the project that's at the top of your dependency graph. You can add a condition if you don't want it to run in Visual Studio, or if you only want to do the FTP transfer for a particular build configuration. For example:
<Project>
...
<Target Name="AfterBuild" Condition="'$(BuildingInsideVisualStudio)'!='true'" >
<!-- Insert your FTP task here -->
</Target>
</Project>
See How to: Extend the Visual Studio Build Process
You might consider modifying your build process template (WF) and using the InvokeProcess activity call out to FTP.exe.
There are also a handful of FTP activities and command line utilties if the built in Windows FTP command line client doesn't work for you.

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