The Artima Developer Community
Sponsored Link

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

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Scott Hanselman

Posts: 1031
Nickname: glucopilot
Registered: Aug, 2003

Scott Hanselman is the Chief Architect at Corillian Corporation and the Microsoft RD for Oregon.
Building MSI files from NAnt and Updating the VDProj's version information and other sins on Tuesday Posted: Mar 30, 2004 6:57 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Scott Hanselman.
Original Post: Building MSI files from NAnt and Updating the VDProj's version information and other sins on Tuesday
Feed Title: Scott Hanselman's ComputerZen.com
Feed URL: http://radio-weblogs.com/0106747/rss.xml
Feed Description: Scott Hanselman's ComputerZen.com is a .NET/WebServices/XML Weblog. I offer details of obscurities (internals of ASP.NET, WebServices, XML, etc) and best practices from real world scenarios.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Scott Hanselman
Latest Posts From Scott Hanselman's ComputerZen.com

Advertisement

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 <exec>

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 

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

Topic: A Biztalk 2004 riddle - Catching an exception from a web service Previous Topic   Next Topic Topic: FxCop 1.30

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use