Sunday, August 29, 2010

PowerConsole: Powershell inside your Visual Studio environment

Thanks to the new Extension Manager inside Visual Studio and the improved extensibility model, a long list of extensions is finding it’s way to the Visual Studio IDE. One of this extensions is PowerConsole written by Jianchun Xu. It’s a PowerShell console window that lives inside of the Visual Studio. Rather than just being a dumb shell, it actually ties into the Visual Studio DTE [explain]. This allows you to access parts of Visual Studio itself like your solution, project, files and even code.

With PowerConsole you have access to some of the Visual Studio parts. There’s a built-in variable created for you when PowerConsole loads; $dte. $dte gives you access to parts of the system, including your own solutions and files. Type “$dte” in the PowerConsole and press enter.

PowerConsole

SOA, the ugly truth…

Last week I was watching this presentation: Does my bus looks big in this?. Although it was recorded two years ago at QCon, it’s still completely true today. In this presentation ThoughtWorks' Chief Scientist Martin Fowler and Global Head of Architecture Jim Webber share their views of the typical corporate ESB, which in their view has grown too fat for its own good. Martin and Jim suggest the Web's architecture as a possible and more light-weight alternative, in line with their preference for agile approaches.

Not only the content is great but also the way how they present it makes this is a really valuable presentation. Check it out.

Silverlight Memory Management

Silverlight and memory management, it’s a tougher combination than you should think. Because of the way Silverlight is written, introducing memory leaks in different places happens easily. Much of Silverlight’s internals are build in native code (C++). The actions that you take in managed code can cause Silverlight to allocate large amounts of native memory on your behalf, be it for layout, rendering, image allocations, you name it.

Of course before you can start tracking memory leaks, you first need to know your current memory usage. A good starting point is the following blog post, which guides you through the different steps to start profiling your Silverlight application.

A must read for every hardcore Silverlight developer.

New TFS Power Tool: Backup and restore TFS

The TFS team continues making my life easier. As every TFS administrator probably knows, backing up and restoring a TFS server can be daunting.  There are potentially a lot of services and a lot of steps.  Microsoft listed all the steps required to create a good backup and restore plan(read more about it here), but it involves a lot of work and there are some easily forgotten steps(especially around guaranteeing consistency).

So I was really happy when Brian Harry announced their latest power tool to simplify exactly this backup and restore procedure. Read everything about this upcoming tool on his blog.

Introducing the TFS 2010 test features in your existing projects

You upgraded your existing Team Foundation Server installation to TFS 2010 and now you want to use the new test features for your existing projects. Sounds like a logical scenario but it isn’t something that works out-of-the-box. Some extra steps are required to make this work.

First of all you must add the new work item types, test case and shared steps, to your upgraded team project to use Microsoft Test Manager. These work item types, test case, and shared steps are included in the process templates for Microsoft Solutions Framework (MSF). For more information, see the following topics:

In addition to the new work item types, you must add link types and categories that are provided with version 5.0 of the MSF process templates. You must customize existing work item types to have the new fields appear on the work item forms. You must also upload a mapping file that specifies the work item type to support automatic creation of bugs or code defects by Microsoft Test Manager.

More information can be found on the MSDN website.

TF270015: 'MSTest.exe' returned an unexpected exit code. Expected '0'; actual '1'

Last week, after upgrading a client from Team Foundation Server 2008 to 2010, I got following error after restoring the build configuration

TF270015: 'MSTest.exe' returned an unexpected exit code. Expected '0'; actual '1'

This error message causes the build to fail.I was able to pin down the issue to the following situation:

  • You try to to build a VS 2008 solution and run associated tests from a .vsmdi file on a TFS 2010 Build machine.
  • One or more of the unit tests specified in a test list in the VSMDI file fails.

The problem is that you end up with a build that "partially succeeds" when some unit tests fail, but these test results are not available in the build report. The moment all your tests succeed, the build succeeds also and all test results are published correctly. Unfortunately there is no solution yet, a bug is opened on MSConnect. So hopefully this will be solved in the next Service Pack.

Sunday, August 22, 2010

AG_E_Unknown error in Silverlight

When I tried to open a Silverlight page, I encountered a very strange AG_E_UNKNOWN error. This one really wins a price in cleariness. You can not say that it helps you find the reason thanks to a really descriptive error message.

Anyway, it took me some time to find out that some indirect references where missing. After adding the correct DLL’s, the error message disappeared.

Free C# Ebook

Interested in C# programming, but you don’t know where to start? Have a look at this free ebook. This 197 page book is used by the Department of Computer Science in the University of Hull as the basis of their first year programming course.

Saturday, August 21, 2010

The fallacy of the Repository/DAO interface

In most applications you need to access a database sooner or later. So you implement a generic Repository/DAO interface on top of the ORM tool of your choice to simplify your data access code. The problem is that those interfaces are most of the time abused and don’t follow their original intent as described by Martin Fowler.

A typical implementation in .NET looks like this:

   1:  public interface IProductRepository
   2:  {
   3:     Product GetById(int id);
   4:     IEnumerable<Product> FindByDescription(string template);
   5:     IEnumerable<Product> FindByPrice(IRange<decimal> priceRange);
   6:     void Add(Product product);
   7:     void Remove(Product product);
   8:  }

As more functionality is needed, this repository keeps growing and growing. Not what you should describe as a maintainable solution. Luckily there are some solutions out there:



  1. The Query Object pattern as described by Martin Fowler. A good example of Query Object is the NHibernate ICriteria with all its classes.
  2. Another possible solution is the Specifications Pattern (by Eric Evans and Martin Fowler). Specification is again very powerful especially because easy to test. In .NET we have various implementations/interpretations based on LINQ.
  3. The last is a repository implementing IQueryable (as proposed by Fabio Maulo here).


Which one do you prefer?

Integrating Sharepoint with Team Foundation Server 2010

Getting MOSS configured properly to work with TFS 2010 is not easy.  Even after a few times, I still forget some of the steps you need to take(and there are a lot!).

To simplify this task, Microsoft built a tool that can be used to configure MOSS for use with TFS.  It doesn’t work in all situations, but it’s a really good starting point.

The tool configures the following features in Office SharePoint Server 2007:

  • Shared Service Provider (SSP)
  • Excel Services
  • Single Sign-on Service

The tool configures the following features in SharePoint Server 2010:

  • Excel Services
  • Secure Store Service

You’ll find an installer for the tool here: http://visualstudiogallery.msdn.microsoft.com/en-us/db469790-5e3e-42f3-906e-411a73795a1b

Designer for NHibernate

You love NHibernate but you have a hard time to set up correct mappings and find your in the sea of options.? With the Mindscape NHibernate Designer, a visual design and configuration tool for NHibernate models, using and managing your NHibernate code becomes a lot easier.

It’s really the best designer I have seen for NHibernate. I think it’s worth the money. Go check it out!

Sunday, August 15, 2010

Could not load file or assembly 'System.Core, Version=2.0.5.0

Last week I had a lot of trouble to get a Silverlight project working on our build server. I kept getting the following error

Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.


All the correct tools, SDK and so on were installed on the build server. I double checked if all the version were correct and everything seemed fine. As a last resort I started adding the following DLL’s from the Silverlight directory to the Global Assembly Cache manually:

  • System.Windows.dll
  • System.Core.dll

After doing this, the problem was solved. Strange…

Simulating the SVN Externals feature in TFS

In a previous post, I talked about some differences between SVN and TFS. One of the missing features of TFS are Externals.

First, what are externals? From the SVN documentation:

Sometimes it is useful to construct a working copy that is made out of a number of different checkouts. For example, you may want different subdirectories to come from different locations in a repository, or perhaps from different repositories altogether. Subversion provides support for this through externals definitions. An externals definition is a mapping of a local directory to the URL—and possibly a particular revision—of a versioned resource.

If you read it well, you can compare it with the sharing feature of SourceSafe on steroids. But all the people who used Visual SourceSafe and the sharing feature probably remember that it came with a great deal of pain. That’s also the reason why the TFS decided to completely remove this kind of feature in favour of branching. But if you really want this functionality, you can simulate it. Not on the source control level, but on the solution level. By using the project linker synchronization tool, you can link to external resources in your projects.

Team Foundation Server source control versus Subversion

There is a lot of discussion going on if TFS Source Control is good or bad. In my experience it’s just a matter of getting used to it. Once you understand how TFS Source Control works, it’s a painless process.

For a client I had to summarize some differences between Subversion(their current source control system) and TFS.

 

Subversion TFS Source Control
Branching in Subversion has a constant cost Branching in TFS has a variable cost based on the number of items in the subtree being branched. (content does not get branched, just the file metadata).
Subversion doesn't force you to check out an item before you start editing it. TFS needs to check out an item before you can start editing it.
Subversion does not support undeleting deleted items(after a rename). TFS supports easily undeleting deleted items. This includes being able to undelete something after a parent has been renamed.
Subversion only shows an item history. It does not show non-history related branches of an item. TFS can show you full branch topologies.
Subversion doesn't have shelve support. TFS includes shelves.
Subversion has rich offline support. TFS offline support is limited.
Subversion has server side hook scripts TFS has client-side checkin policies.
Subversion doesn't have a real rename implementation. TFS supports cyclic and dependant renames. (pending, shelving, merging, undoing, and checking in)
Subversion supports symbolic links inside of the repository that don't create symbolic links on the file system, sync just downloads items from the destination instead. (See the documentation on svn:externals) TFS has no sharing functionality.
Subversion does not track the client status. TFS has the concept of a workspace. It knows what version of the file the client has.

Saturday, August 14, 2010

New Team Foundation Server media

A few weeks ago, I wrote a post about problem I was having wen upgrading from TFS 2008 to TFS 20010.  Microsoft released a hotfix a few days later. Last week, Microsoft released new TFS media including the hotfix. 

To assure yourself that you have the updated media, you can check for the following files on the media:

  • <dvd>\tfs-x86\wcu\kb2135068
  • <dvd>\tfs-x64\wcu\kb2135068

If they are there, then you have the new media.

TFS Integration Tools v1.0 released

The TFS Integration Tools got it first fully supported release. It’s a project developed by the Team Foundation Server (TFS) product group and the Visual Studio ALM Rangers to integrate with third party systems for migration and synchronization of data. 

What’s in the package?
  • TFSMigrationShell … This is the primary tool in the Integration Tools, and provides the ability to create, edit and run migrations from a GUI
  • MigrationConsole … Provides a command line tool for running migrations
  • ServerDiff … Compares version control files or work items on two servers that are participating in a migration or synchronization session
  • CQMigrationConfigGenerator … Extracts the CQ record type schema information, and generates a default matching TFS WITD, a field mapping, and a list of CQ users
  • TFSIntegrationAdmin … Command line utility for various management and administrative tasks such as import/export of configurations, deleting sessions and configuring service accounts
  • SyncMonitorConsole … The SyncMonitorConsole determines the number of backlogged items and time of any backlog in the processing of a continuous sync session and stores the data in the LATENCY_POLL table of the TFSIntegrationPlatform database. You can use the "TFS Integration - Latency.rdl" located at "Microsoft Team Foundation Server Integration Tools\Reports\"to report on this data.

It also contains a big list of adapters out of the box and it’s very easy to create your own:

  • ClearCase Detailed History … Provides the ability to migrate source control items between an IBM ClearCase and TFS system using the native ClearCase API. This adapter migrates all history.
  • ClearCase Selected History … Provides the ability to migrate source control items between an IBM ClearCase and TFS system using the native ClearCase API. This adapter migrates a subset of the history based on a specified label or view.
  • ClearQuest … Provides the ability to migrate work items between an IBM ClearQuest and a TFS system using the native ClearQuest API.
  • File System for TFS 2008 … Provides the ability to migrate files from a file system hierarchy into TFS 2008 version control.  This adapter can be used when there is not a direct adapter available, by exporting revisions from the source system into the file system.
  • File System for TFS 2010 … Provides the ability to migrate files from a file system hierarchy into TFS 2010 version control.  This adapter can be used when there is not a direct adapter available, by exporting revisions from the source system into the file system.
  • Proof of Concept … Provides a sample project for creating an adapter for the Integration tools.
  • SharePoint VC … This is a sample adapter that is used to migrate documents between SharePoint and TFS version control.
  • SharePoint WIT … This is a sample adapter that is used to migrate tasks between SharePoint and TFS work item tracking.
  • TFS 2008 VC … Provides a native integration point with TFS 2008 version control, using the public TFS 2008 API.
  • TFS 2008 WIT … Provides a native integration point with TFS 2008 work item tracking, using the public TFS 2008 API.
  • TFS 2010 VC … Provides a native integration point with TFS 2008 version control, using the public TFS 2010 API.
  • TFS 2010 WIT … Provides a native integration point with TFS 2008 work item tracking, using the public TFS 2008 API

Upload large files to Sharepoint

If you need to increase the maximum file upload size on your SharePoint site the first place you'll probably check is Central Administration. There's a Maximum Upload Size setting right there. The problem is that it doesn't seem to do anything. You still get an error whenever any file over 28MB's is uploaded even if you changed this setting in the web app settings all the way up to 2GB's.  The security built into Windows Server 2008 is at fault here.  When you make the changes in the web app settings they do not get transferred to the web.config file automatically.  So you must manually update the web.config file for all web apps needing this change and update the web.config file in the 12 hive as well. You have to increase the file size limit as well as the time out settings to accommodate for the larger file sizes.

To solve the time out issue open up the web.config and change the executionTimeout of the httpRuntime. Do this for all web apps that need the larger file size.

   1:  <system.web>
   2:     <httpRuntime executionTimeout="999999" maxRequestLength="2000000" />
   3:  </system.web>

Now for the file size:

On a Windows Server 2008 computer with IIS 7.0, you’ll have to add the maxAllowedContentLength value to the web.config.


   1:  <system.webServer>
   2:     <security>
   3:        <requestFiltering>
   4:           <requestLimits maxAllowedContentLength="2000000000"/>
   5:        </requestFiltering>
   6:     </security>
   7:  </system.webServer>

Integrate JAVA development in your Team Foundation Environment

At our company, we are integrating JAVA development on our Team Foundation Server 2010 environment. Thanks to Team Explorer Everywhere and the nice Eclipse integration, this is very easy to do. So our JAVA developers can benefit from all the rich features offered by TFS.

There was only one step left to configure, integrating the JAVA build environment with TFS. Turns out, that this is very easy to achieve thanks to the Team Foundation Build Extensions. It provides the ability to execute Ant or Maven 2 builds from Team Foundation Server and publish the results of the build along with any associated JUnit test results back to Team Foundation Server.  This not only works for Team Foundation Server 2010, but also for Team Foundation Server 2005 and Team Foundation Server 2008.

How to get this done?

First install the JAVA JDK, Ant (if Ant support is required) or Maven 2 (if Maven support is required) on your build server. Afterwards install the build extensions on the build machine. In addition, you should configure the appropriate environment variables (i.e. JAVA_HOME, ANT_HOME, M2_HOME) as per the relevant install guidance for Ant and Maven. These environment variables should point to the correct install locations.

As a last step, you must create a build definition which makes use of them.  The easiest way to do this is to use a Microsoft Visual Studio Team Explorer Everywhere client to create the build definition.

That’s all!

Sunday, August 8, 2010

Installing the Visual Studio Scrum Process Template

I blogged before about the Visual Studio Scrum 1.0 Process Template. But how do you get it installed?

Step 1 – Download the template

The process template is hosted at the Visual Studio Gallery. The easiest way to download the template is using the Extension Manager in Visual Studio 2010. Open Visual Studio 2010, and from the main menu, select Tools | Extension Manager. Select the Online Gallery tab on the left side of the window, and search for ‘Scrum’. Select the Microsoft Visual Studio Scrum 1.0 Process Template from the list and click the Download button. Once the file has finished downloading, click Close on the Extension Manager window to close it.

Step 2 – Install the template
You have to install the process template on your local machine before you can import it into Team Foundation Server 2010. To do that, doubleclick on the MSI and follow the installation procedure. If you left all the default settings, the Process Template is installed in the C:\Program Files (x86)\Microsoft\Microsoft Visual Studio Scrum 1.0 folder.

Step 3 - Importing the template

Importing the process template into Team Foundation Server 2010 is the same as for all other templates. Open the Process Template Manager in Visual Studio 2010 by selecting Team | Team Project Collection Settings | Process Template Manager. Click the Upload button and navigate to c:\Program Files (x86)\Microsoft\Microsoft Visual Studio Scrum 1.0\Process Template.

Step 4 - Installing the Scrum Dashboard Feature
As a last step you have to install the Scrum dashboard feature. Therefore you have to copy the Microsoft.TeamFoundation.Sharepoint.Scrum.wsp file found in the Project Portal folder to your Sharepoint server. Afterwards follow the procedure as described here to upload and install the wsp to your Sharepoint server.

Windows Azure Platform Training kit

If you are getting started with developing applications on Windows Azure, this Training kit can be of great help. It contains presentations, videos,hands on labs, demos and sample applications that cover all aspects of Azure development.

A must see for every Azure developer.

 

Building Silverlight applications on a 64bit build server

If you created a Silverlight project and tried to build on a 64bit build server, you might face one of the following errors:

The "ValidateXaml" task failed unexpectedly.
System.BadImageFormatException: Could not load file or assembly 'obj\x64\Debug\SilverlightApplication1.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.

or if you are building using 64-bit MSBuild:

"SilverlightApplication1.csproj" (GetXapOutputFile target) (2:2) ->
  C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v3.0\Microsoft.Silverlight.Common.targets(101,9): error : The Silverlight 3 SDK is not installed. [SilverlightApplication1.csproj]

As Silverlight DOES NOT support x64 platforms, you always have to build it as x86 process. Configuring this is Team Build is easy. Open up your build definition and explicitly select x86 for the MSBuild platform setting. That’s all!

Building a custom configuration on your build server

By default you only get the standard configuration options when creating a build definition. You can select a Debug or Release configuration and X86, X64 or Any CPU platform. But what if you used the configuration manager to create a custom solution configuration? If you create a new build definition, you only get the default “Debug” and “Release” configurations. The custom configuration can not be selected from the Build definition menu.

builddefinition

The reason you don’t see the custom configuration in the build definition wizard  is because the solution file is not parsed by the wizard. However, using your custom configuration is still possible,  just type it in and it will work just fine without manually editing the TFSBuild.proj file. You are not limited to the values in the dropdowns.

Error while installing the Scrum for Team System Template

Last week I was installing the Scrum for Team System template on a TFS 2008 server, when I got the following error:

“Failed to read IIsWebs table. (-2147023728)”

I tried a lot of things to get it working, and in the end the following did the trick:

  • Open Internet Information Services Manager (inetmgr)
  • Right click on the Default website and select Properties.
  • Change (temporarily) the IP Address from a static IP address to All unassigned

Run the installation again.

Delete work items in Team Foundation Server 2010

Out of the box there is no way to delete work items inside TFS 2010. Does this mean that it is not possible? No, you still have the Team Foundation Server Power tools which add some commands that allow you to delete work items and work item types.

After installing them, you have two new two commands in your toolbox:

  • DestroyWI: Use this to destroy one or more work items.
  • DestroyWITD: Use this to destroy an entire work item type — this means, you are destroying every work item of that type and the type itself.

Calling these commands needs to be done throught the witadmin command which can be found in the Visual Studio directory(Program Files\Microsoft Visual Studio 10.0\Common7\IDE)

Usage: witadmin destroywi /collection:collectionurl /id:id [/noprompt]

/collection Specifies the Team Foundation project collection. Use a fully specified URL such as http://servername:8080/tfs/Collection.

/id Specifies the ID of the work item to destroy. Supports multiple IDs delimited by commas such as 12,15,23 (with no whitespace).

/noprompt Turns off the confirmation message

Impressive software sample: An IDE in the browser

As a software developer, I don’t see much software that I think is impressive. But sometimes I see some little gems that really amazes me. One of this great examples is CodeRun, a free browser based IDE.

It’s unbelievable how many features it offers, and all this inside your browser. The people who created this must be web development experts. Wow!

Some features:
  • Create projects in multiple languages
  • Manage your code solutions, projects and files online
  • Edit code with syntax coloring and code-completion
  • Compile code and review build errors
  • Run and debug code in multiple platforms

CodeRun

 

Integrate Sharepoint 2010 with TFS 2010

So you have installed Team Foundation Server 2010, but now you want to integrate with your existing Sharepoint 2010 infrastructure. You can start reading the correct section in the TFS Installation guide, or if you want to make your life a little bit easier, just read this great post by Martin Hinshelwood where he helps you with a lot of screenshots and short steps to get everything configured.

Installing a WSP for Sharepoint noobs

With little knowledge of Sharepoint I always have to look up the exact STSADM command I need to get the job done.

So here are the required steps to install a Sharepoint solution(.wsp) on a server:

  • Copy the template you want to install to the server.
  • Open a command prompt in Administrator mode(!).
  • At the command prompt, type stsadm -o addsolution -filename <file_path>\<template_name>.wsp, where <file_path> is the location you extracted the template files to and <template_name>.wsp is the .wsp file for your template, and then press ENTER.
  • Type stsadm -o deploysolution -name <template_name>.wsp -allowgacdeployment, and then press ENTER.

To check the deployment status, open the Central Administration site for the server. Click the Operations tab, and then, in the Global Configuration section, click Solution management, and then check the status of your solutions.

After all the solutions are marked Globally Deployed, from the command line, run iisreset.

Wednesday, August 4, 2010

Newsflash: Visual Studio Lab Management Announcement

Microsoft announced today that the final release of the Lab Management functionality in Visual Studio 2010 will be available at the end of August. Important to notice is that Lab Management no longer requires a separate license. Instead Lab Management will be available for existing or new Visual Studio 2010 Ultimate with MSDN and Visual Studio Test Professional 2010 with MSDN customers. Because of this change, Lab Management will no longer require a per-processor license. These two subscriptions include all pre-requisite software for Lab Management – including Team Foundation Server 2010 (purchase of a separate Windows Server license is required), System Center Virtual Machine Manager (SCVMM) 2008 R2, and Visual Studio Agents 2010 and Microsoft Test Manager 2010. Of these products, Agents and Test Manager can be installed from either 2010 Ultimate or Test Professional 2010.

I hope that this big change in licensing will help customers adopting this product. If you want to try it, just have a look at all information here and download a trial of Lab Management here.