We use TFS 2010 with VS 2010 for PHP web projects. Actually we do not have any .proj or .sln file, so i have made my own to make builds, it looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<ItemGroup>
<ZipFiles Include="**\*.*"/>
</ItemGroup>
<Target Name="Zip" >
<Zip Files="@(ZipFiles)" ZipFileName="$(OutDir)myzip.zip" />
</Target>
<Target Name="Build" DependsOnTargets="Zip">
<Message Text="My Build Complete - $(BuildNumber) - $(TeamProject) - $(BuildProperties)" />
</Target>
<Target Name="AfterBuild">
<MakeDir Directories="Testing" />
<Message Text="My AfterBuild- $(BuildNumber) "></Message>
</Target>
</Project>
I have configured build numbers in build definition in VS as "$(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.r)" , and drop folder on network path is created correctly.
The problem is that $(BuildNumber) or $(TeamProject) or $(BuildProperties) are empty. Also it seems that "My Afterbuild" is never executed.
Why are my variables empty and how to get build number from build definition as specified?
To run AfterBuild
targets:
<DefaultTargets="AfterBuild" />
<Target Name="Build" DependsOnTargets="Zip">
<Target Name="AfterBuild" DependsOnTargets="Build">
For me is not clear why Zip
target should be executed before the Build
target?
EDIT:
You have to update template file defaultTemplate.XAML
by adding manually BuildNumber to the MSBuild command line so command Line would be like:
<mtbwa:MSBuild CommandLineArguments="[String.Format("
/p:SkipInvalidConfigurations=true
/p:BuildNumber={1} {0}",
MSBuildArguments,
BuildDetail.BuildNumber)]" />
See the original article regarding this trick: TFS2010 – Where is $(BuildNumber)?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With