How to use MSBUild 2010 to write scripts - msbuild

I am working on MSBuild 2010 and TFS 2010. Heard that one can also use MSBuild apart from using Windows Workflow. My question is how? How do i create a MSBuild project and see the .proj file just like i used to in TFS 2008/ MSBuild 2008

If you have builds that you've created in TFS 2008 that you want to use now, create a build definition that uses the UpgradeTemplate.xaml. This template was created for porting over earlier TFS builds and lets you specify the TfsBuild.proj file that was used in TFS 2008.
Other than that, if you are just looking to use MSBuild scripts instead of the workflow in your build process, you can do that as well (though it is more difficult now.) In VS 2010, you can specify what you want to build when creating a build definition - it defaults to solutions in source control but it can be any msbuild script. Just select an msbuild script that you've created and go from there. For this route, I would recommend the DefaultTemplate.xaml, which you will definitely need to modify along the way.

Related

Cannot analyze multple VS Solutions via SonarQube integrated with TFS 2012 build

I followed the instructions on the "SonarQube Setup Guide for .NET Users" (http://redirect.sonarsource.com/doc/sq-setup-guide-for-dotnet-users.html) to setup a SonarQube 5.1.2 server and integrated with TFS 2012. Even though the document describes how to integrate SonarQube with TFS 2013 XAML builds and TFS 2015 Build vNext, I was able to somewhat integrate it with TFS 2012 XAML build. Here are the sequence of steps in the TFS 2012 XAML.
call InvokeProcess build activity (with WorkingDirecotry set to the directory containing the VS Solution file to be compiled such as C:\Builds\...\ClassLibrary3 to call MSBuild.SonarQube.Runner.exe begin ... (MSBuild SonarQube Runner version 1.0.1)
Call Microsoft MSBuild activity to compile 1 or more VS Solutions such as C:\Builds\...\ClassLibrary3\ClassLibrary3.sln
call InvokeProcess build activity (with WorkingDirecotry set to the directory containing the VS Solution file previously compiled) to call MSBuild.SonarQube.Runner.exe end
The problem is that I can only analyze one compiled VS Solution even if multiple VS Solutions are compiled. This is because the working directory must be the same when calling MSBuild.SonarQube.Runner.exe and MSBuild. The MSBuild activity's working directory is set to where the VS Solution file is located but will differ for each VS Solution compiled but MSBuild.SonarQube.Runner.exe can only specify one working directory. Is there a way to analyze multiple VS Solutions? I don't think there's a way to change MSBuild activity's working directory is there? Thx.
The best way to proceed is be have one project in SonarQube for each of your solution, and use the Portfolio Management plugin (commercial) to perform the aggregation of all these projects on the server side to offer the big picture. See http://www.sonarsource.com/products/plugins/governance/portfolio-management/ & on Nemo how it integrates all Apache projects for example: http://nemo.sonarqube.org/dashboard/index?id=Apache
Another way would be to craft a *.proj file that will include all other projects to build.
Another way, which I wouldn't recommend, is to invoke MSBuild.SonarQube.Runner begin for every solution that you build, then movie the contents of every .sonarqube\out folders to a single one (aggregate it), and call MSBuild.SonarQube.Runner end from that location.
Another way would be to upgrade to TFS 2015, and check how its MSBuild task behaves.

TFS Build without solution file

We use TFS 2008 server for our builds.
I need to create a build from a non Visual Studio project without solution file (only make files for custom compiler). But Build Wizard doesn't allow me create build project file without solution.
Is is posible to create TFS build for such project?
Thanks.
You will need to have either a solution or project defined. What you can do is inside the .proj file create a custom task to handle your scenario.
I would need to better understand what you needed done in order to provide a better answer.

TFS2010 build for VS2005 Projects

We have migrated few projects from TFS2008 to TFS2010 by using the method-
1.Attch TFS2008 DB to TFS2010 DB
2.Tfsconfig import
3.Delete the project not required.
There are few projects in the migrated projects which use VS2005. They do not want to do any change in their project and want to use VS2005 to work with migrated projects. We have applied couple of patches in VS2005 and now they are able to access the TFS2010 projects from VS2005.
However we are clueless about the build configuration. We have configured build server for their Collection...now what configuration needs to be changed in TFsbuild.proj to make the build run again.
Is there any more steps required to make the build work?
Any help would be very much appreciated.
Thanks Upfront.
Kabir
If you have not had a build definition for you TFSbuild.proj then you will need to create one. In your build definition, you will need to choose UpgradeTemplate.xaml as the build process template. In TFS 2010 this template is used to run legacy build definitions.
See how to run build with the UpgradeTemplate.xaml here.
I also found this useful post in the MSDN Build Automation forum that tells you the differences between 2010 and 2005 build processes.

Automate publish of ClickOnce using Visual Studio 2008

I have a Visual Studio solution file (.sln), with several projects (VB.NET and C#, .vbproj, and .csproj files, respectively), and I have a Windows application, and I use ClickOnce to publish it.
Now, I need automate the Publish option using MSBuild or another good solution (cmd, VBScript, or BAT scripts).
How can I do it?
Well, ClickOnce uses MSBuild to publish itself. Therefore I would recomment to use MSBuild for your build-automation. See the reference on MSDN.
The first step is easy. You just run MSBUild with 'Publish'-target from the console. The settings made in Visual Studio are applied.
However, there are some tricky bits. For example, when you run it from the command line, the version number isn't increased. In my project I've solved this by passing the version-number from the build script.
Another tricky-part is when you want to run the build script on your build-server without Visual Studio installed. There you might have to copy some to make it work.

Building VS2008 solution using MSBuild 2010?

Is it possible to build a VS2008 solution (C# and VC++ projects) using the automated MSBuild built into TFS2010? When I niavely just run it, the build fails because the 2008 Solution file needs to be upgraded (and presumably so would the project files). Can I tell MSBuild 2010 to just build the 2008 files?
Does this blog post happen to work out for you? There are several ways you can get it working but just depends on your particular setup.
http://blogs.msdn.com/madhurig/archive/2009/11/25/building-vs2008-projects-with-tfs-build-2010.aspx