Scott Hanselman

XML sucks less than Regular Expressions, ya think?

April 5, '04 Comments [1] Posted in XML | Tools
Sponsored By

Rock on.  And it's well timed, as I was just feeling ill about my previous MSI building solution.

On Monday, April 5, 2004, as part of the Shared Source Initiative, Microsoft releases the source code for the Windows Installer XML (WiX) developer tool to SourceForge under the IBM Common Public License or CPL.

Background Details:

  • The Windows Installer XML (WiX - pronounced "wicks") is a toolset for advanced Windows developers that builds Windows installation packages from XML source code. Overall, WiX can improve the process of how software developers release software.
  • Many Microsoft product development teams use WiX to deliver their installation packages. Utilizing the 1.0 Common Language Runtime, WiX builds with Visual Studio.Net 2003 on Windows 2000, Windows XP, and will be of use with future Windows offerings.
    [FrankArr - MSDN]

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Celebrity Sighting

April 5, '04 Comments [0] Posted in
Sponsored By

Actor, Director, Producer Forest Whitaker (Ghost Dog) is sitting here at the W bar.
Scott Hanselman - Corillian Corp
scott@corillian.com
--------------------------
Sent from my BlackBerry Wireless Handheld

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

MVP Summit - Seattle Day 1

April 4, '04 Comments [1] Posted in
Sponsored By

Made it to Seattle for the MVP Summit.  Microsoft again spares to expense.  I'm at the W - unspeakably spendy, but as always the W is a fabulous hotel.  All the Starwood Hotels are.

Had an early meeting then bumped into Sam Gentile on the Elevator ride up.  Saw Bill Evjen and Jeff Julian, as well as Robert McLaws and Anand from dotnetindia.com.  I passed on a boat ride that sounded like fun (not a big fan of a moving horizon) and I'm down at the Pike Place Fish Market with Scoble. 

Registration opens at 4pm...apparently the number of MVPs attending had doubled from last year.  The big question is, what happens when it doubles again?
Scott Hanselman - Corillian Corp
scott@corillian.com
--------------------------
Sent from my BlackBerry Wireless Handheld

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

IE's Content Advisor, PICS Ratings and the ASP.NET Flakey of the Day

April 1, '04 Comments [3] Posted in ASP.NET | Javascript | Bugs
Sponsored By

GOTCHA #1: Here's a crazy thing.  Let me try to paint a word picture for you of the thing I debugged today with the info I was given in the order it was given:

Symptom: "So, Scott, it appears that users using the Content Advisor feature of IE (the one that's there to prevent kids from seeing naughty things) occasionaly and apparently randomly get logged out of our website"

Me: "That sucks."

Additional Information #1: "Turns out the get logged out when we open a new Window with target='_blank' or javascript:window.open."

Me: "That IS weird.  Good luck with that."

Additional Information #2: "With IEHttpHeaders we see that the Forms Authentication Cookie 'disappears' when this new window opens."

Me: "Well that's just kooky talk.  Cookies don't disappear, they are either tossed with the HTTP Header set-cookie directive, or they are not passed in the Http Request."

Additional Information #3: "Well, turns out that when Content Advisor is OFF, the interaction looks like this:

HTTP GET /somefile.aspx
RESPONSE 200
HTTP GET /somethingelse.aspx (we did a javascript.open)
RESPONSE 302 getthisfile.aspx
HTTP GET getthisfile.aspx
RESPONSE 200

But when Content Advisor is ON, we see this:

HTTP GET /somefile.aspx
RESPONSE 200
HTTP GET /somethingelse.aspx (we did a javascript.open)
HTTP GET /
RESPONSE 200
RESPONSE 302 getthisfile.aspx
HTTP GET getthisfile.aspx
RESPONSE 200

Me: "Well, crap. Who or what is asking for '/' in the middle there?  What's the Headers look like?"

Additional Information #4: "Let's see...when the Response to the GET of / comes back...oh...doh, look at that: 

Set-Cookie:AUTHCOOKIE=; expires=Wednesday, 09-Nov-99 10:34:56 GMT;path=/

Me: "Hm...so clearly SOMEONE is tossing that cookie.  Well, the only place we erase that cookie is the login.aspx page.  Say, what's the DEFAULT page for this site?  It's login.aspx you say?  Oy.

CONCLUSION: When the Content Advisor is ON, Internet Explorer will request '/' from a site anytime a new window is opened.  It does this to request and cache the PICS data from either the page or the headers.  Turned out that on our site, when we opened a new window, IE would go and request the default page '/' which is set in IIS as login.aspx...and we had if(!IsPostBack) FormsAuthentication.SignOut() automatically logging folks out to be tidy.  The Content Advisor's overzealous retrieval of our default page logged the user out.  Damned interesting.


GOTCHA #2: One other thing to remember, if you DON'T have a PICS (Platform for Internet Content Selection) header in your Http Headers or as a META tag in your HTML then folks using Content Advisor in IE may not be able to view your site at all.

So, I just added a standard "I'm harmless" PICS header to the project-wide base page (in the OnLoad).

Response.AddHeader("pics-label","(pics-1.1 \"http://www.icra.org/ratingsv02.html\" comment \"ICRAonline EN v2.0\" l r (nz 1 vz 1 lz 1 oz 1 cz 1) \"http://www.rsac.org/ratingsv01.html\" l r (n 0 s 0 v 0 l 0))"

Also, there's a great PICS Rating Generator online as well.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Building MSI files from NAnt and Updating the VDProj's version information and other sins on Tuesday

March 30, '04 Comments [5] Posted in NUnit | Nant
Sponsored By

So, I commited a series of mortal sins today, but hey, it works, right? :)  Other people have felt my pain, so I thought I'd share.

We have a glorious automated build process with NAnt and NUnit and CruiseControl.  We also update all the AssemblyInfo files (we actually create 'AssemblyVersion.cs' files).  We zip up all the binaries and NDoc generated CHM files.

Additionally I want to create an MSI file at the end of it all. 

Given:

  • I don't want to mess with Installshield yet as the VS.NET stuff does what I need for now. 
  • I don't want to mess with the msitask because it's too freaky.

Therefore:

  • I update the versions inside of the setup.vdproj myself with some of the worse regex's and crappiest code I've done in the last month.

    <target name="updatemsisetupversion" depends="setup">
    <property name="short.project.version" value="0.0.0" />
    <script language="C#">
    <code>CDATA[
    public static void ScriptMain
    (Project project) {
    //Shorten the project string
    (like 1.3.4.5, to 1.3.4)
    string projectVersion = project.Properties["project.version"];
    projectVersion = projectVersion.Substring(0,projectVersion.LastIndexOf("."));
    project.Properties["short.project.version"] = projectVersion;
    string setupFileName = Path.Combine(project.BaseDirectory, "setup\\MySetup.vdproj");
    StreamReader reader = File.OpenText(setupFileName);
    string file = String.Empty;
    try {
    Regex expression1 = new Regex(@"(?:\""ProductName\"" = \""8.My Project  )(\d.\d.\d+)");
    Regex expression2 = new Regex(@"(?:\""ProductCode\"" = \""8.){([\d\w-]+)}");
    Regex expression3 = new Regex(@"(?:\""PackageCode\"" = \""8.){([\d\w-]+)}");
    Regex expression4 = new Regex(@"(?:\""ProductVersion\"" = \""8.)(\d.\d.\d+)");
    file = reader.ReadToEnd();
    file = expression1.Replace(file,"\"ProductName\" = \"8:My Project " + projectVersion);
    file = expression2.Replace(file,"\"ProductCode\" = \"8:{" + Guid.NewGuid().ToString().ToUpper() + "}");
    file = expression3.Replace(file,"\"PackageCode\" = \"8:{" + Guid.NewGuid().ToString().ToUpper() + "}");
    file = expression4.Replace(file,"\"ProductVersion\" = \"8:" + projectVersion);
    }
    finally {
    //
    must remember to close the file or the compile may not work
    reader.Close();
    }
    //
    create a writer and open the file
    TextWriter tw = new StreamWriter(setupFileName);
    try {
    // write a line of text to the file
    tw.WriteLine(file);
    }
    finally {
    //
    close the stream
    tw.Close();
    }
    }
    ]]>code>

  • Then, I shell out devenv.exe and run my new vdproj with

Note: YES, I know the RegEx's suck, and I'm loading the file into a single string, and blah blah blah, micro perf, optimizations, etc.  But, it's a build file. so Nyah! :P 

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.