How to continue using NAnt with ASP.NET 2.0 – level 300

First, if you aren’t using NAnt for team builds in ASP.NET 1.1, shame on you.  Do that first.  When converting to Whidbey, you’ll notice that your website no longer compiles to a single assembly and that multiple assemblies are created at JIT time.  This poses a small problem to the way we are used to scripting web application builds.


You DO NOT want to copy everything in  your website to your production server.  There is no need for your code files to be out there.  Instead, you will want your NAnt script to build the whole website and deploy the binaries.  The solution task won’t work for  you with a VS 8 solution.  You’ll need to use an <exec /> target and kick of aspnet_compiler to precompile your web app to a stage folder and them use a <copy /> target to kick the files out to your server. 


MsBuild does provide an AspNetCompiler task to do this, but it just kicks off aspnet_compiler.  MsBuild is still just a subset of NAnt, so I think it’ll be a while before it can compete effectively (unless we find some proprietary stuff that we _really_ need).

XHtml DocType or DTD – level 200

Especially as we move to ASP.NET 2.0, it’s important to use an XHtml DocType or DTD.  ASP.NET 2.0 server controls will render valid XHtml transitional markup, so that’s the most compelling Doctype, and that’s the one I prefer, but pick one of the following:



  • XHtml 1.0 Transitional


    • <!DOCTYPE html
      PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
      “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

  • XHtml 1.0 Frameset (if you need to use <iframe />


    • <!DOCTYPE html
      PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN”
      “http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd”>

  • XHtml 1.0 Strict


    • <!DOCTYPE html
      PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
      “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>

The DocType needs to be the first line in the page; however, since XHtml is valid Xml, you can optionally add an Xml declaration at the top:


<?xml version=”1.0″?>


And if you do this, the Xml declaration has to first, and then the DocType would come directly after.

How to ensure your web sites are valid Html (or XHtml) – level 300

I originally was going to label this post level 200, but given how few people know about Html standards, I’ve labeled it 300, but I don’t think this _should_ be an advanced topic.


The first easy step is to try to validate your site with a validator.  The one I use is from the W3C: http://validator.w3.org/.  Type in the site, and it will tell you what is wrong with it.  A series of events brought my focus back to this.  I’ve posted on this topics previously here, here, here, here, and here


I was setting some CSS overrides for my Community Server blog, and I wasn’t getting the results I wanted.  Then I inspected the page to find that the default skin of Community Server doesn’t set a DocType.  I was very surprised by this since Telligent has been on the ball on so many things.  Telligent’s own web site uses the XHtml 1.1 DocType, but it doesn’t validate.


Not including a DocType at all leaves the browser guessing as to what kind of markup your page is.  IE will assume Html 3.2 or (quirks mode).  FireFox wants to render it as Html 4.01 transitional.  In fact, if you use the default DocType in VS.Net 2003, you’ll be using an incomplete one that omits the location of the .dtd document.  You can write valid Html 4.0 this way (and I commend Microsoft for having a main page that correctly validates), but IE will still operate in quirks mode.  This may cause you some grief when laying out your pages because you will have unpredictable browser behavior.


Adhering to web standards greatly simplifies web application development when you need an attractive user interface.  There are some simple steps that even a beginning programmer can employ to ensure the web application is valid markup:



  • Add a DocType to the top of every page (or your master page in ASP.NET).  I recommend using:
    <!DOCTYPE html
    PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
    “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

  • Validate your app with the W3C validator.

  • Fix every error it finds.

These simple steps can lead anyone to standards-compliant web application.

Living in the most unwired city in the world (ok, Texas) – level 000

Intel has name Austin, TX the 3rd most unwired city in the U.S.  Whenever I am out and about and have a few hours to kill, I pop open my laptop and do some .Net work.  I always have projects going.  A new project that’s about to start up is a distributed open-source project for the Austin .Net User Group at Adnug.org.   I have a Subversion repository for source code, and we’ll accept code patches from anyone who wants to submit them.  We haven’t defined the project yet, so we’ll see how it goes.  I have no problem finding a location that offers free wireless internet.  Many businesses have added it to their signs, so it’s easy to spot.  And Schlotzky’s is the old stand-by with free wifi at every location.


Some different surveys have slightly different results.  Here are some:



Being a developer, I’m glad that it’s easy to get connected.  I take my laptop with me wherever I go now.  I can take advantage of development time even when I’m waiting my Firestone to change the oil in my truck, and when I just can’t find the Wifi, I use the FutureDial USB cable for my Sprint phone to get on the Net through my mobile phone.

Objections to Agile development – level 300

Whether you love or hate Agile development methodologies, you need to read a whitepaper by Jim Highsmith entitled “Objections to Agile Development”. 


Jim addresses objections that stakeholders make to Agile development.  The categories are:



  • Buyer reality

  • Bad or no design

  • Doesn’t work with our business partners

  • No documentation

For each of the objections above, Jim does a fine job of explaining why these objections are unfounded.  I’ll address the “no documentation” bullet from my own experience, but please read the whitepaper as well.  I’ve battled many objections to Agile at a previous job.


If you’ve ever created design documentation (UML diagram, etc), you know that it is out of date as soon as it’s printed.  Developers make design decisions throughout the coding process (Coding is design, and Jack Reeves take).  It takes a lot of time to keep a design document current, and it just never happens.  Design documents get created; they are shown to management; they look pretty, and they are plain wrong.  They never describe the actual structure of the system.  A manager may like them, but they are looking at a picture, not the actual system.  The actual system ends up structured in a different way, but the manager doesn’t know.  The manager isn’t reading the code.  The manager goes on in ignorant bliss with a picture of something that doesn’t exist.  Arguements can be made about how the process is “supposed” to work, but there’s also reality.


The time for documentation is when the project is finished, and it’s time for it to be mothballed.  This is when documentation should be created for maintainers who may come later.  The system has stopped changing and is actually in a state where it can be documented.  This is maintenance documentation.


Throughout the project, the code and tests should be the documentation for the code.  This is the only thing that is guaranteed to remain current.  Developers should be able to look at the structure of the system in the IDE and understand it.  The whole solution layout also has documentation qualities.


I’d be interested in finding out if anyone has created a design document before the system was created where the document actually stayed current and meaningful.

How to develop an ASP.NET web project without IIS binding – level 200

If you’ve every shared an ASP.NET project or worked on one on multiple computer, you know what a pain it is to ensure that all computers have the same IIS virtual directory configured.  If you don’t, the project won’t open.


For ASP.NET 1.1, it’s easier to use a class library project instead of a web project.  You lose a bit of designer support, but you gain project portability.  If you are like me, you don’t use the designer at all, and it’s all gain and no loss.


The trick is to delete the *.csproj.webinfo file,  take your web project and open the .csproj file in notepad.  Then find the following at the top of the file:


<VisualStudioProject>
    <CSHARP
        ProjectType = “Web”
        ProductVersion = “7.10.3077”
        SchemaVersion = “2.0”
        ProjectGuid = “{09E1A7E2-B51D-42EA-A2BE-4A5991BDF2A7}”
    >. . . . . . .


And just change “Web” to “Local”


<VisualStudioProject>
    <CSHARP
        ProjectType = “Local”
        ProductVersion = “7.10.3077”
        SchemaVersion = “2.0”
        ProjectGuid = “{09E1A7E2-B51D-42EA-A2BE-4A5991BDF2A7}”
    >. . . . . <snip/>


Literally, that’s all it takes.  Now your poject opens as a class library, and you just set up IIS to wherever the project is.  You can debug just like before, and you can use pages and user controls just like before.


One note:  Change the project type back to “Web” before upgrading to .Net 2.0 or the project conversion wizard won’t properly create a website.


 

Steven Smith as RD – level 000

Congrats to Steven Smith, who has recently become a Microsoft Regional Director.  Steve is the second (that I know about) .Net community leader to have been deployed to Iraq.  He was deployed shortly after I returned from being in Iraq for a year.  I was able to give him some tips, and I had the opportunity to meet him in person at Tech Ed.


For those who don’t know, a MS Regional Director is a volunteer who assists the MS developer community in a specific area.  If you have a question or issue, call them up.  Shoot them an email.  They are there to help.  If you live in Texas, there are several:  Go to this page, http://www.microsoftregionaldirectors.com/Public/rdFindNC.aspx, and search for US – Texas.  I’m disappointed that the website is designed so poorly.  You can only get to information through form posts, so I was unable to get a link directly to a filtered list.

AgileATX lunch meeting tomorrow (Austin, TX) – level 000

Food and agile development talk at the Central Market Cafe at Lamar
and 38th (http://tinyurl.com/brxsz). Upstairs in the gallery.

Tursday, July 21st, 11:30 AM


This is a group local to Austin, TX, and while we happen to be more .Net focused, we’re more concerned with common-sense development, and that leads us to Agile.  This group is made up of many members of the Austin .Net User Group as well as some Java folks who are interested in Agile development methodologies and design.  I’d also like to Welcome Jeremy Miller, an AgileATX practitioner who has recently joined CodeBetter.


Check out the Yahoo group at


http://groups.yahoo.com/group/AgileATX/

How to tag with Shadows.com – ASP.NET showcase

As I mentioned before, I’m at a new company, and I’m one of the .Net developers working on Shadows.com.  This is all ASP.NET with C#, and we’re doing a lot of cool things inside the site.  Shadows.com is centered around community tagging, rating, and commenting.  It then faciliates searching on the community’s tags.  With the commenting feature, any page on the Net could be the start of a discussion thread.  Tagging allows similar sites to be grouped together. 


If you look at my blog: http://www.jeffreypalermo.com, you’ll see that I’ve added an image link on the left and a text link on the right.  The image link will take you to my profile page on Shadows.com, and the text link on the right will take you to a shadow page for the current post you are reading.  Every page on the Internet can have a “shadow” page, which is a page about that page.  The shadow page contains tags, ratings, and comments about the source page, so the shadow page is an extension of my blog post, or any other page.


Most developers don’t get the chance to work on an application that gets very high usage, like those on the public Internet, so I feel fortunate that I have this experience.


I’ll surely be posting any ASP.NET lessons learned throughout the life of this project.  I’ve already posted some:



Be sure to download the toolbar for IE or Firefox.  It’ll allow you to tag sites on the fly.