It should first be noted that I am trying to avoid rewriting all my scripts to use msbuild.
I have noticed that there are several problems when using NAnt with the VBC task and compiling a WinForms application. The main problem seems to be that VBC can't find Sub Main. This is odd, since from within VS, there is no indication that there is any sort of difference between my call to vbc and msbuild's call to vbc.
Does anyone have any insight into a solution to this problem or a way to force the creation of the rest of the partial classes that might/might not be being produced by MSBuild/VS?
Sample Build Script:
<?xml version="1.0" encoding="utf-8" ?>
<project xmlns="http://nant.sf.net/release/0.85/nant.xsd" name="Test" default="build">
<target name="build">
<vbc target="winexe" output="C:\Test.exe" main="WindowAppNantTest.My.MyApplication" verbose="true" rootnamespace="WindowAppNantTest">
<imports>
<import namespace="Microsoft.VisualBasic"/>
<import namespace="System.Windows.Forms"/>
</imports>
<sources>
<include name="**/**/*.vb"/>
</sources>
</vbc>
</target>
</project>
Error(s):
[vbc] vbc : error BC30420: 'Sub Main' was not found in 'WindowAppNantTest.My.MyApplication'.
It appears like the problem is coming from the main and rootnamespace attributes. What happens when you switch them to be something like the following:
<vbc target="winexe" output="C:\Test.exe" main="MyApplication" verbose="true" rootnamespace="WindowAppNantTest.My">
<imports>
<import namespace="Microsoft.VisualBasic"/>
<import namespace="System.Windows.Forms"/>
</imports>
<sources>
<include name="**/**/*.vb"/>
</sources>
</vbc>
or something like the following:
<vbc target="winexe" output="C:\Test.exe" main="My.MyApplication" verbose="true" rootnamespace="WindowAppNantTest">
<imports>
<import namespace="Microsoft.VisualBasic"/>
<import namespace="System.Windows.Forms"/>
</imports>
<sources>
<include name="**/**/*.vb"/>
</sources>
</vbc>
I'm not sure if you mean you don't want to use msbuild within NAnt or if you don't want to switch to msbuild scripting wholesale.
If it is the latter, then my reply on your other post on the same topic is valid here as well.
You can use NAnt contrib (http://nantcontrib.sourceforge.net/) and use msbuild within your NAnt script.
The reference on the msbuild task is:
http://nantcontrib.sourceforge.net/release/latest/help/tasks/msbuild.html
And the pertinent snippet:
<target name="build" depends="clean">
<msbuild project="ProjectName.vbproj" />
</target>
What you need to do is set the following into your VBC command:
<references>
<include name="System.Windows.Forms.dll"/>
<indlude name="Microsoft.VisualBasic.dll"/>
</references>
This should fix your problem. (I guessed on the second dll as I'm a CS guy) however the syntax for compiling is pretty much the same.
In all the projects I've worked on you always need to set the references to include any DLL's whether they are from .Net, 3rd party or your own (ie Project references) otherwise they won't link in properly.
Give that a go and see what happens.