News



Team Foundation Server Build Properties

I have often attempted to find TFS build properties that can be used in build scripts.  This seems to be difficult to find via Google, so I am documenting this here.
1. Aaron Hallberg has an entry listing the Team Build 2008 properties.
2. MSDN lists a few TFS Build properties, a few of which are not listed in above. Customizable Team Foundation Build Properties

OneNote for Development

One of the things I enjoy about a subscription to MSDN is access to all of the latest versions software.  So when Installing Office 2007 some time ago, I installed OneNote as well.  I did not get the point of this application at first, however I have found OneNote to be a useful tool for keeping track of my To Do items, as well creating a detailed list of Items for a specific project I am working on.  

image

 

What I find especially useful is the ability to create cascading to do items.  Outlook provides a task list, but there is no way to create sub items.

In addition to an overall to do list, I use it to as my notebook for any applications I am working on, server information and passwords, and any general information I want to keep track of. 

Building a MSI/Setup project using MSBuild/Team Build

Update: This can be accomplished with the MsBuild Extension Pack using the MsBuild.ExtensionPack.TFS.DevEnv

Team Build is great for building Projects applications such as Windows or Web apps.  However it is not able to build Install packages.  Because of this you have to use the Visual Studio build command line option, and copy the .msi and setup.exe files out of the local build directory.  My builds usually copy the built files from to a stage or production server, However this is difficult to do, as no TB/MSbuild variables correctly reference the local build location.  To build a visual studio setup project, I did the following:

  1. Enable building in the Solution configuration manager.  Select the configuration manger, checked build next to the Install project name. 
  2. Open the ApplicationSetup.proj file in a text editor. Searching for ProjectOutput, SourcePath, I confirmed the path was relative to the project file (..\\obj\\Release\\HelloWorld.exe) rather then literal (C:\HelloWorld\obj\\Release\\HelloWorld.exe).
  3. Modified the Build project, adding the build target type

    <Target Name="AfterCompile">

        <Exec Command=
        "&quot;$(ProgramFiles)\Microsoft Visual Studio 9.0\Common7\IDE\devenv&quot;
        &quot;$(BuildDirectory)\HelloWorld\HelloWorldInstall\HelloWorldSetup.vdproj&quot;
        /Build
    &quot;Release|Any CPU&quot;"/>
    </Target>

  4. Created a target to copy the files.  Unfortunately, the built executables are not copied to the drop location.  Their is no TFS build variable that represents the build location.  To copy the files, I had to use a literal path to the build location.  The files were referenced as "C:\build\HWBuildLoc\..." instead of $(SolutionRoot). The MSDN documentation suggests using $(SolutionRoot) to get the local build location, however this returns the incorrect directory. 

    <Target Name="AfterDropBuild">

        <Time Format="yyyyMMdd_HHmmss">

            <Output TaskParameter="FormattedTime" PropertyName="BuildDate" />

        </Time>

     

        <!-- Copy files to Stage -->

        <CreateItem Include="\\StageServer\HelloWorld_$(BuildDate)">

            <Output PropertyName="BuiltProjectStagePath"
           
    TaskParameter="Include" />

        </CreateItem>

     

       

     

        <CreateItem Include=
           
    "C:\build\HWBuildLoc\HelloWorld\HelloWorldInstall\Release\**\*.*" >

            <Output ItemName="FilesToCopy" TaskParameter="Include" />

        </CreateItem>

        <!-- Copy installer -->

        <Copy SourceFiles="@(FilesToCopy)"

             DestinationFiles=
             "@(FilesToCopy ->'\\StageServer\StageDirecoty\%(RecursiveDir)%(Filename)%(Extension)')"

             ContinueOnError="true"/>

    </Target>

  5. This does cause the application to be built twice: once through the normal build process, and again by the visual studio command line call. 

I referenced the following:

  1. Team Build target map
  2. Team Build Property Reference by Aaron Hallberg
  3. Walkthrough: Configuring Team Build to Build a Visual Studio Setup Project

Using Beyond Compare in Visual Studio 2008/Team Foundation Server

If you have ever used Beyond Compare from Scooter software, I don't have to tell you this is a great directory/file comparison tool, especially for the price (Single licenses are listed at $30).  If you don't use this tool, I highly recommend you take the time to download a copy and kick the tires for the 30 day trial.  As I recall with version 2, the trial period lasted for 30 usage days, not 30 days from install.  I don't know if the same applies for version 3. 

The comparison is far better than the comparison that comes out of the box with Visual Studio 2005/2008 and/or Team Foundation Server.  However to set it up you have to follow a few configuration steps.  These are well documented by Marc Brooks at this entry (Beyond Compare 2), and in more detail by James Manning (Beyond Compare 2 & 3). 

First look at ASP.Net MVC

The other night at our local development group, the Charlotte based Enterprise Developers Guild, Brian Hitney from Microsoft gave and Overview of Microsoft ASP.NET MVC.  This is my first time seeing the MVC pattern from Microsoft.  This is the take away Items from this talk which may be helpful to those that are new to the MVC concept. 

Routing

Before discussing the structure of the MVC pattern, it is important to understand how pages are routed through the MVC.  Using a Routing table, links are directed to pages in the following manner:

  • www.Website.com\home\ - goes to homepage
  • www.Website.com\home\data - routes to data page
  • www.Website.com\home\data\14 - routes to data page with index of 14
  • www.Website.com\home\date\edit\14 - I am not certain about this one, but I believe this (or something similar) could be used to route to the data page, edit method with for item 14.  For this to work, the necessary edit method would have to be implemented in the date controller class. 

The basic concept  of the MVC though is the separation of system logic into three separate pieces:

Model

Represented the Data.  In the example the other night, Brian mapped a set of relationships from a database using LINQ/DBML.  In this simple case no other work was done to create the data objects/object models.  As I understand this could also be done using technologies such as NHibernate. 

Controller

This class is where the coding logic for the page goes.  For lack of a better term, this page handles page events (although let me be clear, there are no events in the traditional sense in MVC).  This class would contain methods such as Edit, View, Index etc.  To display individual items, the Data that is generated is sent to the View page.

View

The actual pages that displays the data sent to it from the Control View.  A number of interesting items stood out to me:

  • There is no concept of Page postback in the MVC pattern.  For that reason no page events are handled and processed on the View page. 
  • No ViewState on the page, as the page never posts back to itself.  Because of this the pages are very lightweight.  This also means there is no event processing, and no ability to retrieve Control Data as you would a typical page. 
  • No code behind: The display of items on the Page itself was bound using some classic ASP type syntax.  Rather than using code behind to bind (for example) GridView Items, Items were bound using inline syntax such as <%=Html.TextBox("ProductName")%) or even <%# Eval("ProductName") %>.  This feels like a step backward, but In the end this produces simpler and more lightweight code.  

In the end this model is very different from the traditional ASP.Net model, produces very lightweight HTML, and because of the separation of logic lends itself very well to testing.  On the other hand Brian mention that 90% of Asp.Net web applications in the future are not likely to use this approach. 

Obviously I am only scratching the surface of MVC.  I hope I have accurately described what I have described though.  Of course many more examples can be found as Scott Guthrie's Blog

CustomValidator in a GridView with a ValidationSummary control

Recently I needed to create a CustomValidator inside a GridView.  In the end this was relatively straight forward, however I had some problems in my main application.  As I could not find any examples of this on the Internet, I am documenting this here. 

As a proof of concept I created a web page with an UpdatePanel containing a ValidationSummary, a simple GridView and a button.  The GridView was populated by an XMLDataSource (for simplicity), and a column template containing two text boxes and a custom validator.  The Custom validator was validated via code on the server side.  The validation summary correctly displayed all error messages.  I found the following:

  • I did have to set the CustomValidators ValidateEmptyText=True, However ControlToValidate did not have to be set.  This was important as control visibility changed based on the data items.
  • In the CustomValidator_ServerValidate function, I was able to use CustomValidator.NamingContainer to get the Containing GridView Row.  From there I was able to get all of the controls on that row.
  • I did not have to do any binding in the GridView databound event to make this work. For example I did not have to bind the Custom Validator to the ControlToValidate using the Contols ClientID.  I saw talk on some forums about binding the custom validator when building the GridView.
  • The UpdatePanel did not make a difference.

Here is the Code:

 

 

<asp:ScriptManager ID="ScriptManager1" runat="server" />

<asp:UpdatePanel ID="UpdatePanel1" runat="server">

    <ContentTemplate>

        <div>

            <asp:ValidationSummary ID="ValidationSummary1" runat="server" />

        </div>

        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"

                DataSourceID="XmlDataSource1">

            <Columns>

                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />

                <asp:TemplateField HeaderText="Validation Test">

                    <ItemTemplate>

                        1:<asp:TextBox ID="TextBox1" runat="server"

                           Visible='<%# Eval("Enter1") %>'></asp:TextBox>

                        &nbsp;2:<asp:TextBox ID="TextBox2" runat="server"

                            Visible='<%# Eval("Enter2") %>' ></asp:TextBox>

                        <asp:CustomValidator ID="CustomValidator1" runat="server"

                            ErrorMessage="CustomValidator" Text="*"

                            onservervalidate="CustomValidator1_ServerValidate"

                            ValidateEmptyText="True"></asp:CustomValidator>

                    </ItemTemplate>

                </asp:TemplateField>

            </Columns>

        </asp:GridView>

        <asp:Button ID="Button1" runat="server" Text="Submit" />

    </ContentTemplate>

</asp:UpdatePanel>

<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/XMLFile1.xml">

</asp:XmlDataSource>

 

Partial Public Class _Default : Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

 

    Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, _

             ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)

        Dim cv As CustomValidator = CType(source, CustomValidator)

        Dim gvr As GridViewRow = cv.NamingContainer

        Dim txt1 As TextBox = gvr.FindControl("TextBox1")

        Dim txt2 As TextBox = gvr.FindControl("TextBox2")

 

        'If String.IsNullOrEmpty(txt1.Text) Or String.IsNullOrEmpty(txt2.Text) Then

        If (txt1.Visible And String.IsNullOrEmpty(txt1.Text)) Or _

                (txt2.Visible And String.IsNullOrEmpty(txt2.Text)) Then

            cv.ErrorMessage = String.Format("Please enter text on row {0}", gvr.RowIndex)

            args.IsValid = False

        End If

    End Sub

End Class

 

<?xml version="1.0" encoding="utf-8" ?>

<customers>

    <customer Id="1" Enter1="true" Enter2="true"/>

    <customer Id="2" Enter1="true" Enter2="false"/>

    <customer Id="3" Enter1="false" Enter2="true"/>

    <customer Id="4" Enter1="false" Enter2="false"/>

</customers>

 

 

 

Visual Studio Bookmarks - Enabling Bookmark highlighting

One thing about the Visual Studio interface has often bothered me:  There is not a very good way to bookmark code - by that I mean the "bookmark" feature does not work very well.  Although I am able to set and clear bookmarks using the bookmarks toolbar in code, it does not highlight code in editor like Breakpoints do.  For that reason, I usually use breakpoints when working my way through code, and I wonder how many developers do the same.

Visual Studio Bookmarks

The VS Options Interface gives you the option to change the Fonts/Colors of the bookmarks by changing the background color of the custom text.  However in order to get this to work you have to remove disable the Indicator margin as explained in How to change a bookmark color?.  Although this is better this results in not being able to add and remove break points as easily. 

image 

By default (at least as my keyboard is setup) to set a breakpoint in this mode you have to use a function key (F9).  Setting and clearing bookmarks using the control keys seem a little awkward as well.  A bookmark is toggled by selecting ctrl-K, but you have to select it twice.  Scrolling between Bookmarks is done by selecting Ctrl-K, Ctrl-P and Ctrl-K, Ctrl-N.

In the big scheme of thing this is minor, but this is one of those items I wish was implemented better. 

Trouble Installing Windows Live Writer

Recently I attempted to setup an editor to connect to GWB.  Until this post I used MS Word 2007 to post to GWB, as I was unable to get Windows Live Writer to install.  WLW consistently gave the following error when installing:

There was a problem with this installation. Windows Live Suite was not installed. Code: 0x800070643.

clip_image002

I tried a number of steps to resolve this with MS's Help:

  1. Ran the installation outside my firewall, while downloading the executable to disk first. I also stopped my OfficeScan Debugger (as best as I can tell), as well as Windows defender while installing.
  2. Unregistered(("%windir%\system32\msiexec /unregserver") and re-registered(%windir%\system32\msiexec /regserver") Windows Installer.
  3. Ran the Windows Installer Cleanup from here (although now Windows Live components were found).
  4. Installed Windows Live Imaging Component and SQL Server 2005 Compact - (Actually MS recommended those two steps, I am not certain why)
  5. Finally the step that I suspect worked was to remove some left over registry keys:
    reg query "hklm\software\microsoft\windows live" 
    reg query "hkcu\software\microsoft\windows live" << Listed some entries
    I deleted the entries from the registry using:
    reg delete "hkcu\software\microsoft\windows live"
  6. MS did also provide a link to the actual MSI file but this was not run until step 5 was run.

In the end it took a lot of work to get this installed.  I suspect the culprit was the leftover registry entries.  In any case I am using it now, and I do like it better than MS Word.

Testing blog posting through Microsoft Word

It has been I have posted to this blog, and I am hoping a blogging writer (such as Word 2007 or Windows Live Writer) will help me to post more often. Unfortunately although I have seen recommendations for Windows Live writer, I have not been able to install it successfully. Hence this test post through MS Word 2007.

MS Ajax 1.0 (ATLAS) release first impressions

My post is a little late in coming, but I wanted to note that MS AJAX was recently released.  Thanks to Scott Guthrie and the entire ASP.Net team for getting this out.  I am certain I will be writing much about AJAX in the near future.  I see they are releasing the ASP.NET AJAX 1.0 as a library itself, and a seperate AJAX Control Toolkit download is available from CodePlex.   The Control Toolkit is a "shared source collaborative project."  My first thought is this seems like a good way to make a supported version of the core AJAX library available quickly, while providing the necessary controls that could not make it to the library this go round.  Good work Scott and team!!

Windows Vista is here (or is it?)

    Window Vista will finally be released officially tomorrow, and there is a lot of buzz on some blogs about the good, the bad and the ugly of Vista.  Suffice it to say Vista looks great but has some frustrating usability issues related to security.  What interests right now (as I am in the market for a computer) is the general lack of readiness by many software and hardware vendors (read drivers) to support Vista.  Currently Computers on Dell.com come with the Vista OS on them, you can not select Window XP.  However, you are out of luck if you are interested in adding a tuner card to take advantage of the new Vista Media Center functionality.  Apparently no Vista driver exists for the card Dell used with XP Media center, so they don't offer one for the time being. 
    Granted these type of driver issues are to be expected when a major OS is rolled out.  More interesting to me is the software that does not appear to work or to be supported in Vista.  My wife is an Architect, and she uses Autodesk's "AutoCAD," which apparently has some issues running in Windows Vista.  What is AutoCAD's solution?  Wait until the next version comes out!   Apparently they do not feel the need to plan for a SP, or even to prepare a whitepaper informing users how to best use AutoCAD in Vista.  Adobe recently released the latest version Adobe Premier Elements.  However a quick look at their online forum shows that users are having trouble getting it to run run in Window Vista, and that Adobe promises a Vista SP, but does not specify a date.  And of course there are the issues with MS Visual Studio in Windows Vista related to (among other things) debugging.  At least with Visual Studio a SP is on the way.  This is just a first pass by me before the release date.
    What is interesting to me is that so many software companies (Microsoft especially) are not further along in supporting Windows Vista.  I think up until this point, the attitude at many organizations (I know at Autodesk) was "test it on XP, and test it on Vista if can get a copy or get around to it."  Now that Vista systems are shipping, this will change overnight.  To some extent I expect a period of adjustment when a major new OS is released, however it seems unusual to me that this issue is so pervasive and industry wide.  I do not recall, was the issue so wide when XP was released?  Regardless, I expect Vista compatibility issues to be a big issue over the next 3-6 months.   

Using SqlConnectionStringBuilder to Parse a Connection String.

We need to access a Business Objects/Crystal Enterprise Server from our Web application, and are storing connection information in our webconfig file.  Rather than several different settings in Web.Config, I created a New Connection string property using standard the standard SQL Server connection string syntax, and used SQLConnectionStringBuild to parse the Crystal connection string.  When the username/password is first needed, Initialize is called, and the connection sting is pulled from the config file:
 
    Public Sub Initialize()
        Dim CeConnectionString As String
        CeConnectionString = ConfigurationManager.ConnectionStrings("CE").ConnectionString
        Dim connBuilder As New SqlConnectionStringBuilder(g_ceConnString)
 
        g_strDataSource = connBuilder.DataSource
        g_ceUsername = connBuilder.UserID
        g_cePassword = connBuilder.Password
    End Sub
 
 

First Post

Great, I just set up this blog. Hopefully over the next few months I can blog about my Microsoft .Net development experience.  Topics may include: Microsoft best (and worst) practices (i.e. evaluating the latest version of the Microsoft Data Access Block), ASP.Net (i.e. how I implemented the ObjectDataSource/Gridview/FormView), VB/C# comparisons, CSS Formatting, MS AJAX/ATLAS, ADO.Net, and anything else I find interesting related to the latest technology. Glad to see this forum is powered by Asp.net.'