April 2003 - Posts

Jonathan Goodyear blogs about problems he had when trying to create build scripts for VB.NET solutions.

He writes: "VB .NET projects have two seemingly innocuous features built in that make enterprise development a bit of a challenge. The first of these features is called the root namespace, and is specified in the General section of the project properties dialog. The second feature is the project imports section, which can be found in the Imports section of the project properties dialog."

I must admit, when I tried to create my first build script for a VB.NET solution, I ran into the same problems. But it's quite easy to overcome these problems. I guess VB.NET hides a little complexity in Visual Studio.NET, once you get used to it, you pay the penalty when doing al the work manually... In this discussion James pointed out that the VB.NET compiler (VBC) has a /rootnamespace switch and a /imports switch, which you can use to imitate the properties mentioned above. Alternativly you can get rid of the Root Namespace property and Project Imports, and work like in C#!

A time ago, I read Duncan's post about macros in Visual Studio.NET. I altered a bit his macro to suit my needs. The macro lets you rapidly generate code for the properties of a class. For example when you type the following code for a class (Remark: The generated code has xml comments, but the formatting on this page does not show them.):

Public Class Customer
Private _name As String
Private _telephone As String
End Class


Then you select the internal declarations:
_name and _telephone, and run the macro.
The result is:

Public Class Customer
Private _name As String
Private _telephone As String

'
'This is the Name property.
'

Public Property Name() As String
Get
Return _name
End Get
Set(ByVal Value As String)
_name = Value
End Set
End Property

'
'This is the Telephone property.
'

Public Property Telephone() As String
Get
Return _telephone
End Get
Set(ByVal Value As String)
_telephone = Value
End Set
End Property

End Class


The complete code for the macro is:

Imports EnvDTE
Imports System.Diagnostics

Public Module ClassMacros
Sub ConvertProperties()
DTE.UndoContext.Open("ConvertProperties")
Try
Dim txt As TextSelection
txt = DTE.ActiveDocument.Selection

Dim line, originalCode As String
originalCode = txt.Text

Dim lines() As String
lines = Split(originalCode, vbLf)

Dim variableName, publicName, dataType, propertyProcedure As String

Dim r As System.Text.RegularExpressions.Regex
r = New System.Text.RegularExpressions.Regex( _
"(Dim|Private)\s*(?\S*)\s*As\s*(?\S*)", _
System.Text.RegularExpressions.RegexOptions.IgnoreCase _
Or System.Text.RegularExpressions.RegexOptions.IgnoreCase.ExplicitCapture)

For Each line In lines
line = line.Trim
If Not line = "" Then
Dim mtch As System.Text.RegularExpressions.Match
mtch = r.Match(line)

If mtch.Success Then
variableName = mtch.Groups("varname").Value.Trim
dataType = mtch.Groups("typename").Value.Trim
publicName = variableName.Substring(1, 1).ToUpper & variableName.Substring(2)

propertyProcedure = _
String.Format( _
"{0}'{0}" _
& "'This is the {1} property.{0}" _
& "'
{0}" _
& "Public Property {1} As {2}{0}" _
& " Get{0}" _
& " Return {3}{0}" _
& " End Get{0}" _
& " Set(ByVal Value As {2}){0}" _
& " {3} = Value{0}" _
& " End Set{0}" _
& "End Property", vbCrLf, publicName, _
dataType, variableName)

txt.Insert(vbCrLf & propertyProcedure, _
vsInsertFlags.vsInsertFlagsInsertAtEnd)
End If

End If
Next
txt.SmartFormat()
Catch ex As System.Exception
MsgBox("There was an error while constructing Property code: " & _
ex.ToString & ".", MsgBoxStyle.Critical, "ConvertProperties")
End Try
DTE.UndoContext.Close()
End Sub

End Module




Thanks again to Duncan for the original code!

Hippo.NET is a tool for streamlining the build process of .NET projects in a team envirionment. It provides continuous integration by monitoring the shared Visual SourceSafe database and starting the build process when changes are detected. An important design goal is to provide a nice and easy-to-use user interface, to monitor builds and trigger the build process when needed.

Now you can download a stable version of this tool, with full source code.

Current features are:

  • Client/server model
  • Trigger build from remote clients
  • Implements the build process proposed by Microsoft
  • Automatic build number updates in AssemblyInfo files
  • Build history information
  • Current activity information
  • Fully configurable
  • Rich Windows Forms UI
  • Screenshot 1 - Screenshot 2

    If you try this tool, please give some feeback! Thanks!

    Working with XML is very cool in .NET! With only one line of code, you can get the contents of a RSS feed into a DataSet:

    myDataSet.ReadXml(New IO.StreamReader(System.Net.WebRequest.Create("http://msdn.microsoft.com/rss.xml").GetResponse.GetResponseStream))

    If you don't like the condensed way of writing you can do it like this too:

    Dim wr As System.Net.WebRequest = System.Net.WebRequest.Create("http://msdn.microsoft.com/rss.xml")
    Dim sr As New System.IO.StreamReader(wr.GetResponse.GetResponseStream)
    myDataSet.ReadXml(sr)

    This is great for having all the cool posts on DotNetWebLogs or the new articles on MSDN on your own site.

    Due to some requests, I've compiled a Sneak Preview version of Hippo.NET. Hippo.NET is a tool for streamlining the build process of .NET projects in a team envirionment. It provides continuous integration by monitoring the shared Visual SourceSafe database and starting the build process when changes are detected. An important design goal is to provide a nice and easy-to-use user interface, to monitor builds and trigger the build process when needed.

    Warning: This is only a sneak preview, so don't expect a perfect user experience... The project is fully functional, but for example there is no decent error handling (yet). If you have any problems, please contact me.

    You can download the preview by visiting the home page, or directly visit the download page on SourceForge.

    I've got some positive reactions about my announcement of a new build tool (Paul, I haven't told my manager yet about the tool we are using ;-).

    The tool is not yet available for download, but by request I am planning early next week a 'Sneak Preview' version. Check my Bloggings or the home page for more information!

    Hippo.NET is an open source project for streamlining the build process of .NET projects in a team envirionment. It provides continuous integration by monitoring the shared Visual SourceSafe database and starting the build process when changes are detected. An important design goal is to provide a nice and easy-to-use user interface, to monitor builds and trigger the build process when needed. It can be compared by tools suchs as Draco.NET and Microsoft BuildIt.

    If you are intrested in this project, take a look at the Hippo.NET homepage.

    Current features are:

    • Client/server model
    • Trigger build from remote clients
    • Implements the build process proposed by Microsoft
    • Automatic build number updates in AssemblyInfo files
    • Build history information
    • Current activity information
    • Fully configurable
    • Rich Windows Forms UI

    Hippo.NET Client screenshots:



    More Posts