How do I create an automated build file for VB.Net in NAnt?

By : mmattax

I have taken over the development of a web application that is targeted at the .net 1.0 framework and is written in C# and Visual Basic.

I decided that the first thing we need to do is refine the build process, I wrote build files for the C# projects, but am having tons of problems creating a build file for Visual Basic.

Admittedly, I do not personally know VB, but it seems like I have to hardcode all the imports and references in my build file to get anything to work...certainly not the best way to be doing things...

For any example: if I do not include the namespace System in the build file I will get several errors of common Unkown Types e.g: Guid

does NAnt typically require this for VB code or is does the VB code need a possible NAnt-freindly refactoring?

Does anybody have VB NAnt tips?

By : mmattax


I have had a similar experience with NAnt and the vbc compiler for VB.NET projects that are developed with Visual Studio. My solution has been to avoid importing namespaces at the project level in Visual Studio (which occurs by default), and use explicit Imports statements at the class/file level. C# projects work this way by default (no project level namespace imports), and I like the extra information provided by explicit namespace directives when looking at a file.

Interesting that VB.NET and C# VS projects are so different in that respect.

By : Peaeater

I would recommend that you take the language specific compilers out of the equation for this one. And you can still use NAnt to do this:

First start off with a target that uses MSBuild because that will compile your project regardless of language used and take care of the dependencies for you. That means you don't need to hard code them in.


<target name="WinBuild">
  <exec program="msbuild.exe"
                     /nologo /verbosity:normal /noconsolelogger 
                     /p:Configuration=Debug /target:Rebuild" />

I think once you've got that nailed - you can spend plenty of time trying to get NAnt to compile natively, but in my opinion, this is what I would use for this project since it seems to be a once off?

Hope that helps,


Rob G

Are you calling msbuild to build? Or are you calling the VS.NET IDE exe to build. We've had no problems with our c#/VB.NET mix using CC.NET and NAnt and do not have to specify referenced assemblies inside of the build files.

What we do is using the IDE exe to build solutions that contain the projects we want to build.

By : slolife

This video can help you solving your question :)
By: admin