Scott Hanselman

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

March 31, 2004 Comment on this post [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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Intellisense and NAnt .build files in VS.NET

March 30, 2004 Comment on this post [9] Posted in Nant | XML
Sponsored By

This has been blogged about before here and there, but I wanted to share it as I had to mess with it yesterday. 

Getting Intellisquish to work with NAnt .build files in VS.NET:

  1. Copy this file: nant-current.xsd (101.06 KB) to 'C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Packages\schemas\xml' on your system.
  2. In your NAnt build file (I make my with the extension .build) include this xmlns attribute:

    <project default="all" basedir="." xmlns="http://nant.sf.net/schemas/nant-0.84.win32.net-1.0.xsd">

  3. When you File|Open your .build file, notice the TINY down arrow on the Open button.  Click it, go to Open With...

  4. In Open With, select HTML/XML Editor.  There you go, NAnt Build files with Intellisense. 

If anyone knows how to tell VS.NET to ALWAYS open .build files with the XML Editor (without messing up any other file types) tell me, and then we can skip steps 3 and 4.

There is also some nice stuff on MSDN about Authoring Custom XML Schemas for use in VS.NET.

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

作者:Scott Hanselman 首席工程師

March 30, 2004 Comment on this post [2] Posted in ASP.NET | TechEd | Speaking
Sponsored By

Wow, I noticed something in my referrer log and it was a link to my site from Taiwan.  Someone (MSDN Taiwan presumably) translated my ASP.NET Scripting article into Chinese.  Very cool, and thanks!. 

More importantly, stolen from the bottom of the article, I now have my bio translated into Chinese!

Scott Hanselman 是 Corillian Corporation,一家提供電子金融服務的公司的首席設計師。他在以 C、C++、Visual Basic、COM 及目前的 Visual Basic .NET 和 C# 開發軟體方面擁有超過十年的相關經驗。Scott 非常榮幸在過去三年來受任 MSDN 俄勒岡州的波特蘭地區主管一職,並同時在波特蘭和西雅圖兩地發展 Developer Days 及 Visual Studio .NET 產品推出活動的內容並發表演說。Scott 另外還在四個城市的 Microsoft®Windows Server®2003 和 Visual Studio .NET 2003 產品推出活動中演講。他在國際間陸續發表跟 Microsoft 技術有關的演講,並與其他作者合著了兩本 Wrox Press 的書。在 2001 年,Scott 於全國 15 個城市巡迴演講有關 Microsoft、Compaq 和 Intel 採用 Microsoft 技術並傳佈良好的設計實例。今年 Scott 在太平洋西岸 4 個城市的 Windows Server 2003 產品推出活動、美國及馬來西亞的 TechED,以及奧蘭多的 ASPLive 中發表演說。有關他對於 .NET, 程式設計和 Web 服務的各項領悟,請參閱 http://www.computerzen.com/

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

.NET in the Real World - the Regional Director Column launches

March 29, 2004 Comment on this post [0] Posted in Musings
Sponsored By

Yay!  The new Regional Director column called '.NET in the Real World' has launched on MSDN.  The inaugural column is by Billy Hollis.  I believe next month will be an update of my thoughts around the Myth of .NET Purity.  Check the column out for new content from a new Microsoft Regional Director every month!

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

VSLive SFO Rocked...

March 29, 2004 Comment on this post [3] Posted in ASP.NET | Internationalization | Web Services
Sponsored By

What a blast at VSLive! this last week. 

Some highlights:

  • Gave three talks, one on Internationalization in ASP.NET, and 2 sessions of a 3 part series with Bill Evjen on 'Zen and the Art of Web Services.'  I will post slides and code later. 
  • Hanging out with Peter Blum (from PeterBlum.com - Validation and More and Peter's Date Package)
  • Introduced Peter to David Platt only to find out they both live in the same TINY Massachusetts town and have for the last 15 years.  And they run into each other with me in SFO.  Madness.
  • Saw my buddy and former Malaysian RD Loke Uei Tan.  Saw my friend Terk Sean :), but didn't get to hookup with her partner in crime Ramin Perumal. :( 
  • Had a guy come up to me, and the conversation went like this: Him: "You know Rory Blyth?" Me: "Ya" Him: "I'm dickhead!"  Me: "You're dickhead!" Him: "Yep."  Interestng conversation...here's a picture.
  • Saw Jon Box, Rocky LhotkaBilly Hollis, Chris Kinsman.
  • Hung out with Ron Jacobs the King of ShadowFax.  He took me to the airport on the way out using the Train, rather than using my brilliant 'taxi' idea. 
  • Had the best haute cuisine, as I always do when I'm in 'The City'

     

 

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

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