I created a custom Activity that created a Wix Include file.  I had it just 
write the file new each time.  The contents of our file looks like this

<?xml version="1.0" encoding="utf-8"?>
<!-- Note that this file will be overridden by the build server. -->
<Include>
  <?define MajorVersion       = "1" ?>
  <?define MinorVersion       = "62" ?>
  <?define BuildNumber        = "112" ?>
  <?define Revision           = "1083" ?>
  <?define FullVersion        = "1.62.112.1083" ?>
  <!--WiX Installer Versions are Major.Minor.Revision -->
</Include>

Then I just included it in all the wix markup to use it.  Its pretty straight 
forward.  I probably wrote more to the file than I needed, but I didn't want to 
have to revisit getting the custom activity to work.

Once you create the activity, you need to update your build agents to pull the 
assembly from source control, I placed it into 
$/root/BuildProcessTemplates/CustomActivities.

Using the code activity, you can update the build process template to hook up 
the two properties (VersionInfoFileName and VersionNumber).  I actually use the 
same technique to write an assemblyinfo file that has the version information 
in it as well.  In my case, I don't check it in and out each time, because the 
build regenerates it... you could easily do that by adding a invokeprocess 
activity before/after the UpdateWixVersion activity (remember to use the 
**NO_CI** Magic so you don't get caught in a continuous loop building...

The source for the code activity looks like this:

  [BuildActivity(HostEnvironmentOption.All)]
  public sealed class UpdateWixVersion : CodeActivity
  {
    /// <summary>
    /// Defines the file mask of all of the files for which the build number of 
the assembly version must be updated
    /// </summary>
    [RequiredArgument]
    public InArgument<string> VersionInfoFileName { get; set; }

    /// <summary>
    /// Defines (uses) the VersionNumber as initialized in the build process 
template.
    /// </summary>
    [RequiredArgument]
    public InArgument<string> VersionNumber { get; set; }

    /// <summary>
    /// Execute the Update Version Number build step.
    /// </summary>
    /// <param name="context">Contains the workflow context</param>
    protected override void Execute(CodeActivityContext context)
    {
      //-- Get the input parameters
      string strVersionInfoFileName = 
context.GetValue(this.VersionInfoFileName);
      string strVersionNumber = context.GetValue(this.VersionNumber);

      Version verCurrentVersionInfo = new Version(strVersionNumber);

      //-- Generate the text...
      StringBuilder sb = new StringBuilder();
      sb.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
      sb.AppendLine("<!-- Note that this file will be overridden by the build 
server. -->");
      sb.AppendLine("<Include>");
      sb.AppendLine(string.Format("  <?define MajorVersion       = \"{0}\" ?>", 
verCurrentVersionInfo.Major));
      sb.AppendLine(string.Format("  <?define MinorVersion       = \"{0}\" ?>", 
verCurrentVersionInfo.Minor));
      sb.AppendLine(string.Format("  <?define BuildNumber        = \"{0}\" ?>", 
verCurrentVersionInfo.Build));
      sb.AppendLine(string.Format("  <?define Revision           = \"{0}\" ?>", 
verCurrentVersionInfo.Revision));
      sb.AppendLine(string.Format("  <?define FullVersion        = \"{0}\" ?>", 
strVersionNumber));
      sb.AppendLine("  <!--WiX Installer Versions are Major.Minor.Revision 
-->");

      sb.AppendLine("</Include>");

      //-- Save the file text...
      if (File.Exists(strVersionInfoFileName))
      {      //-- ensure that the file is writeable
        FileAttributes fileAttributes = 
File.GetAttributes(strVersionInfoFileName);
        File.SetAttributes(strVersionInfoFileName, fileAttributes & 
~FileAttributes.ReadOnly);

        File.WriteAllText(strVersionInfoFileName, sb.ToString());

        //-- restore the file's original attributes
        File.SetAttributes(strVersionInfoFileName, fileAttributes);
      }
      else
      {
        throw new Exception(string.Format("UpdateWixVersion: {0} does not 
exist.", VersionInfoFileName));
      }
    }
  }

Hope it helps,
John

-----Original Message-----
From: David Rickard (USA) [mailto:davri...@microsoft.com] 
Sent: Thursday, September 22, 2011 4:54 PM
To: chr...@deploymentengineering.com; General discussion for Windows Installer 
XML toolset.
Subject: Re: [WiX-users] Best way to invoke Wix from a TFS build workflow?

Again, thanks for all the tips. 

I'm setting my .wixproj project up now and have gotten to the point where I 
need to pass the version number from the TFS build in. You said it "takes a 
little bit more work": how did you end up doing that?

-----Original Message-----
From: Christopher Painter [mailto:chr...@deploymentengineering.com] 
Sent: Tuesday, September 20, 2011 4:09 PM
To: General discussion for Windows Installer XML toolset.; 
wix-users@lists.sourceforge.net
Subject: Re: [WiX-users] Best way to invoke Wix from a TFS build workflow?




The simplest way is to use Votive to generate a .SLN / .WIXPROJ and then add 
the sln configuration | platform to to the build parameters in the build 
definition.  You shouldn't have to do any customizations in workflow 
as the Default Template will work out of the box.   Passing a 
ProductVersion property takes a little bit more work on the msbuild side  ( 
build parameters and preprocessor definitions in the wixproj and wixs ) but it 
doesn't require any workflow changes.

----------------------------------------

From: "David Rickard (USA)" <davri...@microsoft.com>

Sent: Tuesday, September 20, 2011 5:11 PM

To: "wix-users@lists.sourceforge.net" <wix-users@lists.sourceforge.net>

Subject: [WiX-users] Best way to invoke Wix from a TFS build workflow?


I need to build some MSIs with Wix during our TFS build. Our current TFS build 
is using the Windows Workflow XAML files to declare the build logic. 
What's the best way to invoke Wix from there? Directly invoking the process 
from an activity? Going down to a powershell script and calling it from there? 
Are there any custom Wix activities to use?

----------------------------------------------------------------------------
--

All the data continuously generated in your IT infrastructure contains a

definitive record of customers, application performance, security

threats, fraudulent activity and more. Splunk takes this data and makes

sense of it. Business sense. IT sense. Common sense.

http://p.sf.net/sfu/splunk-d2dcopy1

_______________________________________________

WiX-users mailing list

WiX-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/wix-users


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a 
definitive record of customers, application performance, security threats, 
fraudulent activity and more. Splunk takes this data and makes sense of it. 
Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users





------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to