mirror of
https://github.com/ckaczor/WixBalExtensionExt.git
synced 2026-01-14 01:25:43 -05:00
Initial commit
This commit is contained in:
63
wixext/BalPreprocessorExtension.cs
Normal file
63
wixext/BalPreprocessorExtension.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// <copyright file="ValuePreprocessorExtension.cs" company="">
|
||||
// </copyright>
|
||||
//
|
||||
// <summary>
|
||||
// A WiX preprocessor extension.
|
||||
// </summary>
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.Tools.WindowsInstallerXml.Extensions
|
||||
{
|
||||
using System;
|
||||
using Microsoft.Tools.WindowsInstallerXml;
|
||||
|
||||
/// <summary>
|
||||
/// The preprocessor extension.
|
||||
/// </summary>
|
||||
public sealed class BalPreprocessorExtension : PreprocessorExtension
|
||||
{
|
||||
private static readonly string[] prefixes = {"bal"};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the variable prefixes for this extension.
|
||||
/// </summary>
|
||||
/// <value>The variable prefixes for this extension.</value>
|
||||
public override string[] Prefixes
|
||||
{
|
||||
get { return prefixes; }
|
||||
}
|
||||
|
||||
public override string EvaluateFunction(string prefix, string function, string[] args)
|
||||
{
|
||||
string result = null;
|
||||
|
||||
switch (prefix)
|
||||
{
|
||||
case "bal":
|
||||
switch (function)
|
||||
{
|
||||
case "Version":
|
||||
// Make sure the base version is specified
|
||||
if (args.Length == 0 || args[0].Length == 0)
|
||||
{
|
||||
throw new ArgumentException("Version template not specified");
|
||||
}
|
||||
|
||||
// Build = days since 1/1/2000; Revision = seconds since midnight / 2
|
||||
DateTime now = DateTime.Now.ToUniversalTime();
|
||||
double build = (now - new DateTime(2000, 1, 1)).TotalDays;
|
||||
double revision = now.TimeOfDay.TotalSeconds / 2;
|
||||
|
||||
result = String.Format("{0}.{1}.{2}", args[0], (int)build, (int)revision);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user