MSBuild + Team Build 2008 Presentation
Software Development, Team System February 1st, 2009
You can download MSBuild & Team Build 2008 presentation.
Tags: MSBuild, Presentations, Team Build, Team System 2008
You can download MSBuild & Team Build 2008 presentation.
Tags: MSBuild, Presentations, Team Build, Team System 2008
When MSBuild was first released, it was seen as a stopgap measure. Prior to its introduction, building a non-trivial .NET project from the command line was a daunting challenge. Either command line options have to be carefully laid out or third-party libraries like NAnt have to be brought in.
Recently MSBuild Extension Pack was released on CodePlex. Run by Mike Fourie and a team of 5 developers, this successor to FreeToDev MSBuild Extensions has over 170 different tasks for MSBuild. Many of these tasks support a MachineName argument allowing the actions to be performed on a remote machine.
The team summarizes the tasks into these categories:
Tags: MSBuild
The other day I got a question: How can I deploy an app via ClickOnce using Team Build?
There is not out of box way to do that, but we can do it with a simple workaround:
we should overload the target AfterCompile in TFSBuild.Proj to call MSBuild Task Publish and can pass the PublishDir property:
<Target Name="AfterCompile"> <MSBuild Condition=" '@(SolutionToBuild)'!='' " Projects="@(SolutionToBuild)" Properties="Configuration=%(ConfigurationToBuild.FlavorToBuild); Platform=%(ConfigurationToBuild.PlatformToBuild); SkipInvalidConfigurations=true; VCBuildOverride=$(MSBuildProjectDirectory)\TFSBuild.vsprops; FxCopDir=$(FxCopDir);OutDir=$(OutDir); PublishDir=$(OutDir); ReferencePath=$(ReferencePath); TeamBuildConstants=$(TeamBuildConstants); $(CodeAnalysisOption);PublishDir=\\qa1Srv\drops\publishedVers\ " Targets="Publish" /> </Target>
Tags: MSBuild, Team Build
A question I got today: “How can I configure my Team Build for an incremental build?”.
So, it’s simple.
Add the PropertyGroup definition to the end of the TFSBuild.proj file, before the closing </project> tag.
Set the following properties:
<PropertyGroup> <SkipClean>true</SkipClean> <SkipInitializeWorkspace>true</SkipInitializeWorkspace> <ForceGet>false</ForceGet> </PropertyGroup>
Set IncrementalBuild property to true. To do it, add the PropertyGroup definition to the end of the TFSBuild.proj file, before the closing </project> tag.
<PropertyGroup> <IncrementalBuild>true</IncrementalBuild> </PropertyGroup>
Source – msdn:
Team Build 2005: http://msdn.microsoft.com/en-us/library/aa833876(VS.80).aspx
Team Build 2008: http://msdn.microsoft.com/en-us/library/aa833876.aspx
Tags: MSBuild, Team Build, Team Build 2008, Team System 2008
Microsoft announce the public release of a new developer tool - Source Analysis for C#.
Inside Microsoft this tool’s name is StyleCop and it enforces code style guidelines on the code we write
Source Analysis comes with a set of default rules analyzers covering approximately 200 best practice rules. These rules are full compatible with the default layout settings in Visual Studio 2005 and Visual Studio 2008.
Specifically, these rules cover the following, in no particular order:
After installation, Source Analysis can be run from within the Visual Studio IDE. You can set this up to be run as a part of your build process as documented here. Since this is plugged in as a MsBuild project you can use it in as a part of Team Foundation Build process as well.
Running Source Analysis:
And the results are:
Download it from: http://code.msdn.microsoft.com/sourceanalysis
Read full details:http://blogs.msdn.com/sourceanalysis/archive/2008/05/23/announcing-the-release-of-microsoft-source-analysis.aspx
Tags: C#, Code Analysis, Coding Standards, MSBuild, Team System, Team System 2008, Visual Studio 2008, Visual Studio Team System
Next week I’ll give a session at TechEd 2008 In Eilat, Israel. The session will introduce you how you can control your database changes and integrate it into your agile development methodology.
Do you want to control your database changes?
Do you want to test your database with unit test and even run static analysis on it?
Do you want better life and easier deployment of database schema changes to production database?
If one of your answers is YES, come to hear me.
Session Details:
Session’s Agenda:
Microsoft opened up the meetings application at http://www.face2facemeeting.com/teched/. If you want to meet me and talk with me on development, WCF, LINQ, ALM or anything else – contact me! I’ll be glad to see you!
Meet you there…
Tags: Events, Lectures, MSBuild, Team Build 2008, Team System 2008, VSTS DB Pro
The ability to remove entries from ItemGroups is one of the new features of MSBuild 3.5.
To remove an Item from an ItemGroup in MSBuild 2.0 you would have to create a new ItemGroup from the old one and skip the Item that you needed removed.
In MSBuild 3.5 we can achieve it by using the Remove parameter.
Example:
<ItemGroup> <Files Include="a.cs" /> <Files Include="b.cs" /> <Files Include="c.cs" /> <Files Include="d.cs" /> <Files Include="e.cs" /> <Files Include="f.cs" /> <Files Include="g.cs" /></ItemGroup>
Some times we want to restrict some data from this group in a target. In order to do it, we should use the Remove parameter:
<ItemGroup> <Files Remove="a.cs" /> <Files Remove="e.cs" /> <Files Remove="f.cs" /></ItemGroup>
Read more at msdn.
Tags: MSBuild, Team Build, Team Build 2008
Many users want to modify the default build number of Team System Team Build which looks like: <Build-Type-Name>_<Date>.XXX.
You can change it by writing a custom task and call it in the BuildNumberOverrideTarget target of the MSBuild file. In this example the task will generate a unique build number based on current time:
using System;using Microsoft.Build.Utilities;using Microsoft.Build.Framework; namespace MaorDavidBlog.Samples.MSBuild{ public class BuildNameGenerator:Task { private string _buildName; public override bool Execute() { _buildName = DateTime.UtcNow.ToString(); return true; } [Output] public string BuildName { get { return _buildName; } } }}
The attribute “Output” indicates that BuildName property is output of the custom task.
Then, register the task in TFSBuild.proj file.
<!-- Add using task line just after import statement - - ><UsingTask TaskName="MaorDavidBlog.Samples.MSBuild.BuildNameGenerator" AssemblyFile="$(MyCustomTasks)\MaorDavidBlog.Samples.MSBuild.dll"/> <! -- Override the target towards the end of proj file - - ><Target Name = "BuildNumberOverrideTarget" > <BuildNameGenerator> <Output TaskParameter="BuildName" PropertyName="BuildName"/> </BuildNameGenerator> </Target>
Next time you’ll execute your build, you’ll see your custom build name.
Tags: MSBuild
I got today hysterical message from a good friend that implementing in his company automatic build with Team System. The message was: "Maor, How can I copy wildcards With MSBuild? Please help!!!".
Okay. What you should do my dear friend is:
1. Create an item list if you have more than one file to copy. You can do it with the CreateItem task:
<CreateItem Include="$(MyDir)\*.*"> <Output TaskParameter="Include" ItemName="MyFilesToCopy" /></CreateItem>
2. Copy!
<Copy SourceFiles="@(MyFilesToCopy)" DesginationFolder="$(MyPutputDir)" />
3. Execute your build script.
Ah, by the way, if you want to recursively copy files using the <Copy> task, read this post from MSBuild Team Blog.
Enjoy!
Tags: MSBuild
VSTS for DB Professionals (aka "Data Dude" or "VSDBPro") provides great tools for schema and data compare.
Like most Visual Studio-based project systems, the core tasks inside the VSDBPro project implemented as MSBuild tasks. The two core activities for Database Projects (.dbproj), “Build” and “Deploy” are implemented by two MSBuild tasks named “SqlBuildTask” and “SqlDeployTask.”
Sometimes, we also need to automate the schema and data compare processes. We can do it with new MSBuild dedicated tasks that shipped with Power Tools for Data Dude
Currently available for VSTS 2005)
How should you use it?
First, install the Power Tools. Download from here. (notice that the power tools requires Data Dude Service Release 1 installed).
After you installed the power tools you can use the tasks in your MSBuild script.
Example:
<!--Import the settings--> <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0 \TeamData\Microsoft.VisualStudio.TeamSystem.Data.PowerTools.Tasks.targets"/> <Target Name ="DataCompare"> <SqlDataCompareTask SourceConnectionString="Data Source=(.);Integrated Security=True;Pooling=False" SourceDatabaseName="SourceDB" TargetConnectionString="Data Source=(.);Integrated Security=True;Pooling=False" TargetDatabaseName="TargetDB" OutputPath = "$(temp)" OutputFileName = "DataCompare.sql"/> </Target>
Notice that the task does not allow you to compare against the project right now. Same way you can use the SqlSchemaCompareTask.
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0\TeamData\Microsoft.VisualStudio.TeamSystem.Data.PowerTools.Tasks.targets"/><Target Name ="SchemaCompare"> <SqlSchemaCompareTask SourceConnectionString="$(SourceConnectionString)" SourceDatabaseName="$(TargetDatabase)" TargetConnectionString="$(TargetConnectionString)" TargetDatabaseName="$(TargetDatabase)" OutputPath = "$(IntermediateOutputPath)" OutputFileName = "$(TargetDatabase)SchemaCompare.sql" IgnoreChecks ="true"/></Target>
The properties exposed by the MSBuild tasks are documented via an accompanying XSD file located in:
%ProgramFiles%\Microsoft Visual Studio
8\Xml\Schemas\1033\MSBuild\Microsoft.VisualStudio.TeamSystem.Data.PowerTools.Tasks.xsd
Tags: MSBuild, VSTS DB Pro