Rash thoughts about .NET, C#, F# and Dynamics NAV.


"Every solution will only lead to new problems."

Category Visual Studio

In dieser Kategorie geht es um aktuelle Themen zu Microsoft’s Visual Studio 2005.

Thursday, 8. January 2009


How I do Continuous Integration with my C# / F# projects – part III: Running automated UnitTests

Filed under: C#,English posts,F#,Tools,Visual Studio — Steffen Forkmann at 19:13 Uhr

In the last two posts I showed how to set up a Subversion (part I: Setting up Source Control) and a TeamCity server (part II: Setting up a Continuous Integration Server).

This time I will show how we can integrate NUnit to run automated test at each build. TeamCity supports all major Testing Frameworks (including MS Test) but I will concentrate on NUnit here.

"NUnit is a unit-testing framework for all .Net languages. Initially ported from JUnit, the current production release, version 2.4, is the fifth major release of this xUnit based unit testing tool for Microsoft .NET. It is written entirely in C# and has been completely redesigned to take advantage of many .NET language features, for example custom attributes and other reflection related capabilities. NUnit brings xUnit to all .NET languages."

[product homepage]

Creating a TestProject

First of all download and install NUnit 2.4.8 (or higher) from http://www.nunit.org/.

Now we add a small function to our F# source code:

let rec factorial = function  
  | 0 -> 1
  | n when n > 0 -> n * factorial (n-1)
  | _ -> invalid_arg "Argument not valid"

This is the function we want to test. We add a new C# class library to our solution (e.g. “TestCITestLib” 😉 ) and add a reference to nunit.framework. Inside this new TestLibrary we add a TestClass with the following code:

namespace TestCITestLib
{
    using NUnit.Framework;

    [TestFixture]
    public class FactorialTest
    {
        [Test]
        public void TestFactorial()
        {
            Assert.AreEqual(1, Program.factorial(0));
            Assert.AreEqual(1, Program.factorial(1));
            Assert.AreEqual(120, Program.factorial(5));
        }

        [Test]
        public void TestFactorialException()
        {
            Program.factorial(-1);
        }
    }
}

To ensure the build runner is able to compile our solution we put the nunit.framework.dll near to our TestProject and commit our changes.

Adding Nunit.framework.dll

Configure TeamCity for UnitTesting

The next step is to tell TeamCity that the build runner should run our UnitTests:

Configure build runner for NUnit

If we now run the build we should get the following error:

UnitTest error during automated build

Our second test function failed, because we didn’t expect the System.ArgumentException. We can fix this issue by adding the corresponding attribute to the Testfunction:

[Test,
 ExpectedException(typeof(System.ArgumentException))]
public void TestFactorialException()
{
    Program.factorial(-1);
}0

Tests passed

Configure the build output

At this point we have a minimalistic Continuous Integration infrastructure. Every time someone performs a Commit on our repository a automated build will be started and the sources will be tested against the given UnitTests. Now we should concentrate on getting our build output – the artifacts. The term artifact is usually used to refer to files or directories produced during a build. Examples of such artifacts are:

  • Binaries (*.exe, *.dll)
  • Software packages and installers (*.zip, *.msi)
  • Documentation files (e.g. help files)
  • Reports (test reports, coverage reports, …)

At this time we are only interested in the binaries (this means CITestLib.dll). We can add the following artifact definition to our TeamCity project:

Configure artifacts in TeamCity

If we now rebuild our solution the build runner collects the configured artifacts and stores them with all build information:

Collected artifacts

Next time I will show how we can add more artifacts – e.g. an automated documentation.

Tags: , , , , , , , , ,

How I do Continuous Integration with my C# / F# projects – part II: Setting up a Continuous Integration Server

Filed under: C#,English posts,F#,Tools,Visual Studio — Steffen Forkmann at 14:50 Uhr

In the last post I showed how easy it is to install Subversion and how it can be integrated into Visual Studio 2008 via AnkhSVN. This time we will set up a Continuous Integration server and configure a build runner.

As a Continuous Integration Server I recommend JetBrains TeamCity. You can download the free professional edition at http://www.jetbrains.com/teamcity/.

Installing TeamCity

During the installation process TeamCity wants to get a port number. Be sure that there will be no conflict with other web applications on your server. I chose port 8085 – and my first build agent got this default settings:

Configure a Build Agent

In the next step you have to sign the License Agreement and to create an administrator account:

Set up administrator account

Creating a Project

Now you can create your project and set up the build configuration:

Create project on your TeamCity Server

Create CITest project

Create Build Configuration

Set up version control root

Setting up a build runner

For setting up specific build runners see the TeamCity documentation. For now I will use the “sln2008”-Build runner (the Runner for Microsoft Visual Studio 2008 solution files).

Runner for Microsoft Visual Studio 2008 solution files

Now add a build trigger. Whenever someone performs a Commit on the Subversion repository the server has to start a build.

Build trigger

Testing the build runner

After this step we have two options to start a build. The first one is by clicking the “Run”-button on the project website and the second is doing a checkin:

Triggering the build running with a checkin

After performing the Commit the pending build appears on the project website:

Pending build 

After 60 seconds (see my configuration above) the build is starting. After the build is complete one can see the results in different ways. The simplest is via the project website:

View build results

Of cause TeamCity gives you a lot of different notification and monitoring possibilities including mail, RSS feeds or System Tray Notifications.

Next time I will show how we can integrate UnitTesting in our automated build scenario.

Tags: , , , , ,

How I do Continuous Integration with my C# / F# projects – part I: Setting up Source Control

Filed under: C#,English posts,F#,Tools,Visual Studio — Steffen Forkmann at 14:31 Uhr

In this post series I will show how one can easily set up a Continuous Integration scenario for F# or C# projects with completely free products.

“Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily – leading to multiple integrations per day. Each integration is verified by an automated build (including test) to detect integration errors as quickly as possible.”

[Martin Fowler]

The first step for Continuous Integration is to set up a Source Control environment. For many good reasons I choose Subversion – some of them are:

  • Atomic commits
  • Rename/Move/Copy actions preserve the revision history
  • Directories are versioned
  • Multiple repository access protocols including HTTP and HTTPS
  • There is a nice Visual Studio integration (see below)
  • Last but not least: it is completely free 🙂
Source code version control with Subversion

All you need for setting up a complete Subversion environment is to download and install VisualSVN Server from http://www.visualsvn.com/.

“VisualSVN Server is a package that contains everything you need to install, configure and manage Subversion server for your team on Windows platform. It includes Subversion, Apache and a management console.”

[product homepage]

Now you can create user accounts and a repository ”CITest” in the VisualSVN Server management console.

Create a repository

VisualSVN Server management console

Subversion integration in Visual Studio 2008

Download and install AnkhSVN 2.0.x from http://ankhsvn.open.collab.net/.

“AnkhSVN is a Subversion SourceControl Provider for Visual Studio. The software allows you to perform the most common version control operations directly from inside the Microsoft Visual Studio IDE. With AnkhSVN you no longer need to leave your IDE to perform tasks like viewing the status of your source code, updating your Subversion working copy and committing changes. You can even browse your repository and you can plug-in your favorite diff tool.”

[product homepage]

Now you can add your C#/F#-solution to your CITest-repository:

  • Open the solution in Visual Studio 2008
  • Open “View/Repository Explorer” and add your repository to AnkhSVN
    • You can copy the URL from the VisualSVN Server management console (In my case this is https://omega:8443/svn/CITest/)
    • You also have to give AnkhSVN your Subversion login
  • Now click the right mouse button on your solution in the Solution Explorer and choose “Add Solution to Subversion”

Add Solution to Subversion

Don't forget to specify a Log Message

Now we can modify our solution and commit our changes via “Commit solution changes” in the Solution Explorer:

Commit Solution Changes

We can easily control our changes via AnkhSVN’s “Repository Explorer” and “History Viewer” in Visual Studio 2008:

Repository Explorer and History Viewer

If we do any changes in the Program.fs file, we can see a diff via the “Show changes” functionality:

Diff with AnkhSVN

If you don’t like the default Diff tool you might try WinMerge.

Next time I will show how to set up a Continuous Integration server.

Tags: , , , , , , ,

Thursday, 16. October 2008


Debugging in Dynamics NAV 2009

Filed under: .NET 3.0,C#,Dynamics NAV 2009,msu solutions GmbH,Visual Studio — Steffen Forkmann at 13:41 Uhr

Claus Lundstrøm zeigt in einem schönen Blogpost wie man in NAV2009 den Code auf Seite der ServiceTier (also auch remote) debuggen kann – und zwar über Visual Studio 2008 direkt im generierten C#-Code. Mit dieser Variante ist man nicht mehr gezwungen das Debugging über den Classic-Client zu tun, sondern kann direkt aus dem Dynamics NAV RoleTailored-Client debuggen.

Dummerweise ist der generierte C#-Code, wie das bei generiertem Code eigentlich immer der Fall ist, nicht gerade “optisch schöner” C#-Style und hat auch nur noch wenig mit dem Original-C/AL-Code zu tun – ist aber immerhin lesbar.

Das ist ein wirklich interessanter Ansatz und erlaubt mit etwas Geschick auch UnitTesting für NAV 2009. Dafür werde ich demnächst mal versuchen ein kleines Beispiel zu bloggen.

Tags: , , , , ,

Tuesday, 30. September 2008


Agenda 2010 – oder was kann ich von der nächsten Visual Studio Version erwarten?

Filed under: .NET,Tools,Visual Studio — Steffen Forkmann at 11:49 Uhr

Microsoft hat gestern eine Pressemitteilung zum Visual Studio 2010 (Codename: Rosario) und dem .NET Framework 4.0 heraus gegeben. Einer der wesentlichen Punkte ist demnach den “Application development life cycle” (ALM) noch besser zu unterstützen. Es werden dabei wohl einige neue Modeling Tools zur Verfügung stehen, die sowohl Unified Modeling Language (UML) als auch Domain Specific Languages (DSL) unterstützen werden. Außerdem hat Microsoft stark in das oft kritisierte MSTest-Framework investiert und neue Collaboration-Features in den Team Foundation Server eingebaut.

Ein weiterer zahlreich geforderter Punkt ist, dass die Database Edition nun endlich mit der Developer Edition zusammengelegt wird.

In der Pressemitteilung wurde übrigens auch kurz eine Unterstützung für Cloud Computing angekündigt. 😉

Weitere Informationen und erste Screenshots gibt es auf der Webseite zu VS 2010. Zusätzlich werden diese Woche ständig neue “Visual Studio 2010”-Videos auf Channel 9 veröffentlicht.

https://pillenonline247.nl
Tags: , , , , , ,

Tuesday, 15. April 2008


Usability-Thementag am 18. April in Leipzig

Filed under: .NET,Veranstaltungen,Visual Studio,WPF — Steffen Forkmann at 15:58 Uhr

Am 18. April 2008 findet von 9 bis 17 Uhr ein “Usability-Thementag” an der Universität Leipzig statt.

“Neben technologieorientierten Lösungsansätzen, wird im ersten von drei Vorträgen im Allgemeinen auf Benutzerfreundlichkeit im alltäglichen Leben eingegangen. Weiter geht es mit Usability-Aspekten im Bereich des Webs, gefolgt von einem Vortrag zu den technischen Möglichkeiten mit der Windows Presentation Foundation (WPF) und Silverlight. Abgerundet wird der Tag mit einem 90-minütigen Workshop, in dem die erlernten WPF-Kenntnisse in einer Demo-Anwendung direkt am Rechner umgesetzt werden.”

Aus dem Newsletter der .NET-Usergroup Leipzig

Wer sich für dieses Event anmelden möchte, kann eine E-Mail an anmeldung@dotnet-leipzig.de schreiben. Die Mail bitte unbedingt mit Vorname, Nachname und dem Betreff “Usability” versenden. Da die Teilnehmerzahl begrenzt ist, sollte man sich mit der Anmeldung beeilen.

Tags: , , , , ,

Friday, 14. March 2008


Mitschnitte vom Microsoft Launch 2008

Filed under: .NET 3.0,Firmen,Veranstaltungen,Visual Studio — Steffen Forkmann at 12:33 Uhr

Vor kurzem fand in Frankfurt der Produktlaunch von Visual Studio 2008, SQL Server 2008 & Windows Server 2008 mit über 7500 Teilnehmern statt. Nun stehen Mitschnitte der Vorträge des Launch Events 2008 exklusiv auf den Webseiten einiger CLIP-Mitglieder zur Verfügung.

Der benötigte Silverlight Player kann über nachfolgenden Link heruntergeladen werden:

http://www.microsoft.com/silverlight/resources/InstallationFiles.aspx

Folgende Sessions werden auf Navision-Blog.de als Stream angeboten:

Das Motto war dieses Jahr übrigens “Heroes happen {here}” bzw. im deutschen “Bereit für Helden” 😉

Auf dem Blog von Torsten Weber gibt es übrigens auch noch ein paar Bilder von diesem Event.

Tags: , , , , ,

Friday, 7. March 2008


Aufbruch zur CEBIT und zum CLIP-GetTogehter

Filed under: Veranstaltungen,Visual Studio — Steffen Forkmann at 16:44 Uhr

Morgen geht es zur CEBIT und speziell zum Community GetTogether von Microsoft. Dort werde ich mir u.a. Vorträge zu Neuerungen in Visual Studio 2008 und zum neuen Internet Explorer 8 anhören. Shola Aluko, seines Zeichens “Internet Explorer Product Manager” wird extra aus Redmond anreisen, um den vor kurzem als Beta-Version erschienenen Browser vorzustellen und Antwort auf technische Fragen zu geben.
Davon wird es aufgrund der bisher veröffentlichten IE8-Probleme (ACID2-Test (Stichwort: “Cross-Domain-Sicherheitsfunktion”) und ACID3-Test (nur 14 von 100 Punkte) [siehe z.B. PC-Welt]) sicher auch einige geben. 😉

Also ich bin schon mal gespannt und freue mich auf das Community-Event.

Tags: , , ,

Saturday, 1. March 2008


Integration einer Quellcodeverwaltung in Dynamics NAV

Filed under: .NET 3.0,C#,Dynamics NAV 2009,Navision,Tools,Visual Studio — Steffen Forkmann at 12:45 Uhr

Wie bereits vor einiger Zeit im Blog berichtet, habe ich für unseren internen Produktionsablauf ein Tool geschrieben, das es ermöglicht eine Quellcodeversionsverwaltung (z.B. VSS, SVN oder Team Foundation Server) direkt in Dynamics NAV zu integrieren. Jetzt habe ich mir mal die Mühe gemacht, die wichtigsten Funktionen in einem kleinen Screencast zu dokumentieren. (Dies ist jedoch erstmal nur eine Vorabversion des Videos.) 

Das Schöne an diesem Tool ist, dass man aus beiden Blickrichtungen alle nötigen Informationen zu einer Version bekommt. Ich sehe also an der Datei die Änderungshistorie mit den entsprechenden ChangeRequests oder Ticketnummern und kann auch rückwärts an einer Aufgabe sehen, welche Änderungen dafür konkret am Quellcode gemacht wurden und von wem.

Für Visual Studio-Nutzer ist das natürlich nichts neues, aber gerade im ERP-Bereich wird oft (mangels fehlender Tools) auf eine Quellcodeverwaltung verzichtet.

Tags: , , , , , , ,

Sunday, 10. February 2008


Workshop zu SCRUM und Team Foundation Server

Filed under: .NET 3.0,Informatik,Tools,Veranstaltungen,Visual Studio — Steffen Forkmann at 11:28 Uhr

Am 15.02.2008 findet von 13 – 17 Uhr in der Universität Leipzig ein kostenloser Workshop von Jens Korte zum Vorgehensmodell SCRUM in Verbindung mit dem Team Foundation Server statt.

Weitere Informationen im Blog von Torsten Weber.

Tags: , , , ,