John Lam 1997 — 2026

Unit testing .EXE's

I was hoping that VS.NET 2003 would let me reference code in an .EXE assembly. Unfortunately, the IDE still prevents me from doing this, which makes writing unit tests for EXE-based code more painful (your .EXE project becomes a shell for a library project that contains the real code). This is a limitation that’s imposed by the IDE GUI, and is not a limitation of the compilers; the C# compiler happily lets me reference types in an .EXE assembly.

If anyone from the VS.NET team reads this, can you remove this arbitrary limitation from the Whidbey release of VS.NET? Pretty-please? :)

5 archived reader comments

Brad Wilson, The .NET Guy (2003-07-10)

This might sound trite but… stop using the build system in the IDE? Use NAnt instead! :)

John Lam (2003-07-10)

But Brad, I *do* use NAnt. But I also edit my code in VS.NET. When I write my unit tests, I’d like to have Intellisense against my target code.

Andy McMullan (2003-07-10)

With VS 2003, bypassing the GUI by manually adding the reference to the .csproj xml file (for C# projects) seems to work.

Andy Mc

Jamie Cansdale (2003-07-12)

See this [1] article where I do exactly that. I wanted to compile some code against Reflector. I first found out you could just rename an EXE and it would work (kind of obvious but I didn’t think of it for a while). I then found out you could edit the .csproj file by hand (this works for adding links to files outside the project directory too). It was a bummer when I found out this doesn’t work in VS.NET 2002 (when I ported the project back).

[1] http://www.managedaddins.net/addins/reflector/ReflectorAddIn.htm

Richard Poole (2004-07-14)

You’ve got my vote! I’ve only recently started unit testing my assemblies, and until now haven’t had to unit test an .exe. Needless to say, I’ve come up against the exact same problem.

I guess I’ll just have to settle for the wrapper approach in the mean time.