Friday, February 10, 2006

Building FitNesse and FitLibrary for .Net 2.0

Here's how I built both FitNesse and FitLibrary for .Net 2.0. (If you don't have fifteen minutes for this, help yourself to my .Net FitNesse replacement bundle.)

UPDATE 25OCT2006: These instructions for building FitNesse may not work. Around May 2006, the developers of FitNesse merged their .Net FitServer with FitLibrary.NET into a new SourceForge project. (See the .Net page at FitNesse for more information.) I will try to investigate this, but I make no promise of updating these instructions.

First, let's tackle FitNesse:

  1. Download the latest source bundle for FitNesse. As of today, the latest version is 20060209.
  2. Create a directory in your "Visual Studio 2005\Projects" directory called "FitNesse".
  3. From the FitNesse source bundle, extract the contents of the "dotnet" directory (but not the directory itself) into the folder you just created.
  4. Open the "fitnesse.sln" solution file. This will start VS 2005 and invoke the Conversion Wizard.
  5. Click the "Finish" button, and the wizard converts the solution into one compatible with VS 2005.
  6. Click the "Close" button. If VS displays the conversion summary, then it encountered errors. Scan for the errors and resolve them. If the conversion had no errors, then VS will not display this summary.
  7. If you're using the same FitNesse version as I did, then you will see two errors in the summary regarding "TableFixture.cs" and "TableFixtureTest.cs". The errors occurred because, for some reason, the two files did not make it into the source bundle. Grab them from the latest release source bundle, and put them into the "fitnesse" folder in the "fit" project.
  8. In each of those files, add a using fit; line and change the namespace from fit to fitnesse.fixtures.
  9. For each project:
    1. Right click the project, and choose "Properties" from the context menu.
    2. In the properties page that appears, click the "Build Events" tab.
    3. Delete the pre-build event command line.
    4. Change the post-build event command line to
      copy "$(TargetPath)" "$(SolutionDir)"
      copy "$(TargetPath)" "full path to FitNesse 'dotnet' directory"
      including the double quotes.
  10. Build the solution. (Press F6.) You should see no errors, but you may get warnings. I addressed one of the two that appeared for me. I changed a method call from GetByHostName to GetHostEntry.

And now for FitLibrary:

  1. Download the latest bundle of the .Net version of FitLibrary. As of today, the latest version is 20060117.
  2. Extract the contents of the bundle to your "Visual Studio 2005\Projects" directory. This will add a "FitLibrary.NET" project folder.
  3. Open the "fitlibrary.sln" solution file, and VS 2005 will start its Conversion Wizard.
  4. Click "Finish", and click "Close" when the wizard finishes. If you get errors, address them now. (I did not get any errors.)
  5. For the "FitLibrary" project:
    1. Right click the project, and choose "Properties" from the context menu.
    2. In the properties page that appears, click the "Build Events" tab.
    3. Delete the pre-build event command line. No longer necessary (25OCT2006)
    4. Change the post-build event command line to
      copy "$(TargetPath)" "full path to FitNesse 'dotnet' directory"
      including the double quotes. (Updated 25OCT2006)
  6. In the "FitLibrary" project, remove the reference to "fit", and add a reference to the "fit.dll" in your FitNesse installation's "dotnet" directory.
  7. Build the solution. (Press F6.) It should succeed.

Now you have a .Net 2.0 compatible version of FitNesse and FitLibrary ready for you in your FitNesse installation. Happy Testing!

10 comments:

  1. Wow! Thank you, Paul, for your great effort porting those examples. Very helpful, indeed.

    ReplyDelete
  2. I'm getting "WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN" when it tries to find the fit.dll. I've tried your bundle as well as build my own. Anyone else have this issue?

    ReplyDelete
  3. Jeff, thanks a lot. You made my day ... was stuck with finding a compatible version of FitNesse with .Net 2.0

    ReplyDelete
  4. You're welcome, Sameer. I'm glad I could help.

    ReplyDelete
  5. I am having trouble the TestRunner. I am getting a socket exception. Anyone else?

    ReplyDelete
  6. Andy O. Try to recreate a strong name with some like this: sn.exe -k c:\fitnesse.key, and replace the wrong key.

    ReplyDelete
  7. I download from subversion the last version of fitnesse for dotnet. I want to recompile for .net 2.0. On the FitServer project i don't find PathParser.cs.

    Please, do you know where i can find it?

    thanks in advance.

    ReplyDelete
  8. I tried following your steps. I was not able to find "fitnesse.sln" so I downloaded your version of Fitnesse.net. Then I worked on the FitLibrary, the conversion worked fine. I created a Fitnesse directory and put the "dotnet" folder files there and have a FitLibrary.Net folder under Fitnesse.

    In post build the link of dotnet is to fitnesse installation in "My Documents" where I have my Fitnesse running.

    I get following errors.
    [1] "fit.FlowFixtureBase.LoadFixture(fit.Parse)': no suitable method found to override". File is "FlowFixtureBase.cs"

    [2] "Metadata file 'C:\Program Files\Microsoft Visual Studio 8\Projects\Fitnesse\FitLibrary.NET\FitLibrary\bin\Debug\FitLibrary.dll' could not be found"

    Any help is appreciated.

    Thanks

    ReplyDelete
  9. Anonymous,

    Make sure that you've extracted the contents of my dotnet.zip file into the dotnet directory of your Fitnesse installation. I have no problem building FitLibrary with the fit.dll from that zip file.

    Everyone,

    In response to the previous anonymous comment, I reviewed my instructions, and I found two interesting changes. First, during the last several months, the developers of FitNesse merged their .Net FitServer with FitLibrary.NET into a new project on SourceForge. Second, perhaps Rick Mugridge read this post because FitLibrary now builds without changing the project properties; however, you still must add that second post-build command line to copy the build output to your Fitnesse installation.

    ReplyDelete
  10. For fit.dll and runFile.exe without FitNesse or FitLibrary: in order to run fixtures compiled for .NET 3.5, which do use Linq, I had to recompile fit.dll and runFile.exe for the 3.5 platform.

    ReplyDelete

Note: Only a member of this blog may post a comment.