Throwing Development Muses

Thursday, August 31, 2006

Cancel a failed build in VS.NET!

How annoying is it when a referenced project fails to build and VS.NET continues to try to compile everything underneath, ending up with screens of irrelevant errors?

Well, here is a very useful little nugget. This macro will stop the build if a project fails to compile, and it will work in vs2003, vs2005, vs2008 and vs2010.

In your macro explorer just add it to the module under MyMacros that contains the EnvironmentEvents module. On my machine this was in the default module named Module1.

'Cancels the build of a solution if a project build fails.
Private Sub BuildEvents_OnBuildProjConfigDone( _

ByVal Project As String, ByVal ProjectConfig As String, _
ByVal Platform As String, ByVal SolutionConfig As String, _
ByVal Success As Boolean) Handles BuildEvents.OnBuildProjConfigDone

If Success = False Then
'The build failed...cancel any further builds.
DTE.ExecuteCommand("Build.cancel")
End If
End Sub

Monday, June 27, 2005

Converting NUnit tests to Visual Studio 2005 Tests

I've been looking at this recently, and there is no easy way at the moment (yet, James Newkirk is developing one here).

But I have discovered the following:

Once you have converted your project to VS2005 you will have to add a reference to the Microsoft.VisualStudio.QualityTools.UnitTestFramework assembly to your project containing the nunit tests.

Having done this you might expect VS2005 to recognise the project as a test project, but it doesn't, and your tests don't appear in the test manager.
To get VS to do so you have to edit the .csproj file manually and in the top section add the following:

<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

These GUIDs identify the project as a c# test project.

Then its generally a Find|Replace procedure to replace the attributes etc. in your test classes.

Here are the ones that I have had to change:

Declarations:

  • using NUnit.Framework becomes using Microsoft.VisualStudio.QualityTools.UnitTestFramework


  • Attributes:

  • [TestFixture] becomes [TestClass]

  • [TestFixtureSetUp] becomes [ClassInitialize]

  • [TestFixtureTeardown] becomes [ClassCleanup]

  • [Test] becomes [TestMethod]

  • [Test (Description="text here")] becomes [Test] and [Description("text here")]

  • [Ignore("some text here")] becomes [Ignore]


  • Other:

  • ExpectedException attribute stays the same.

  • Descriptions can't be placed at class level.

  • Test defined in abstract classes cannot be run.

  • Unit Testing support should be included with all versions of Visual Studio 2005 and not just with Team System.

    Peter Provost has started a blog petition to get the Unit Testing features included in all versions of VS2005. I wholeheartedly agree.
    See the blog petition here: Unit Testing support should be included with all versions of Visual Studio 2005 and not just with Team System.

    Monday, May 09, 2005

    Cross .NET Framework referencing

    I found this interesting thread on Mike Taulty's web log - thought I'd quote it here as could be useful to a lot of people considering to move to the .NET Framework 2.0



    This question

    http://blogs.msdn.com/junfeng/archive/2004/07/14/181938.aspx
    about whether a
    .NET Framework 1.1 application can host a .NET Framework V2.0 assembly (and vice
    versa) is going to get asked a lot as we head towards the .NET Framework 2.0
    release.


     

    [Mike Taulty's Weblog]

    Wednesday, March 02, 2005

    New Dataset features In Visual Studio 2005

    I found this article about ADO.NET datasets in the next version of Visual Studio. It also points to an earlier article that covers the performance improvements for large datasets. Something that was desperately needed.

    Learn about the new features in the typed DataSet class and the new TableAdapter class that are generated by Microsoft Visual Studio 2005, as well as the tools for designing these classes.

    [Via MSDN Just Published]