views:

768

answers:

5

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?

+1  A: 

I'm not sure, if you talk about VB or VB.Net.
Either way, have a look at Nant Contrib. Maybe they have a solution.

John Smithers
+1  A: 

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.

slolife
+1  A: 

@slolife

I am using the straight vbc command in namt to compile the source files, likewise I uses the csc command to compile all the C# code.

The C# code compiles great, the vb code acts like it needs to be spoonfed all the imports / references...

My goal is to not install and IDE on the server...we want to simplify the build process without being constrained by an IDE.

mmattax
+1  A: 

Hi mmattax,

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.

Example:

<target name="WinBuild">
  <exec program="msbuild.exe"
        basedir="${DotNetPath}"
        workingdir="${SolutionPath}"
        commandline="MySolution.sln 
                     /nologo /verbosity:normal /noconsolelogger 
                     /p:Configuration=Debug /target:Rebuild" />
</target>

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,

Cheers,

Rob G

RobertTheGrey
+1  A: 

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.

Peaeater
I did not know this, thanks!
mmattax