commit e154b00453583f33113eca2392b2c6ee192cf38b Author: Chris Kaczor Date: Thu May 1 09:40:29 2014 -0400 Initial commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1bc915c --- /dev/null +++ b/.gitignore @@ -0,0 +1,156 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +build/ +[Bb]in/ +[Oo]bj/ + +# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets +!packages/*/build/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.scc + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml + +# NuGet Packages Directory +## TODO: If you have NuGet Package Restore enabled, uncomment the next line +#packages/ + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + + +#LightSwitch generated files +GeneratedArtifacts/ +_Pvt_Extensions/ +ModelManifest.xml + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac desktop service store files +.DS_Store diff --git a/AssemblyInfo.cs b/AssemblyInfo.cs new file mode 100644 index 0000000..0859063 --- /dev/null +++ b/AssemblyInfo.cs @@ -0,0 +1,16 @@ +using System.Reflection; + +using Microsoft.Tools.WindowsInstallerXml; + +[assembly: AssemblyTitle("WixFileVersionExtension")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Chris Kaczor")] +[assembly: AssemblyProduct("WixFileVersionExtension")] +[assembly: AssemblyCopyright("Copyright © Chris Kaczor 2009")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] + +[assembly: AssemblyDefaultWixExtension(typeof(WixFileVersionExtension.WixFileVersionExtension))] \ No newline at end of file diff --git a/WixFileVersionExtension.cs b/WixFileVersionExtension.cs new file mode 100644 index 0000000..e183754 --- /dev/null +++ b/WixFileVersionExtension.cs @@ -0,0 +1,22 @@ +using Microsoft.Tools.WindowsInstallerXml; + +namespace WixFileVersionExtension +{ + public class WixFileVersionExtension : WixExtension + { + private WixFileVersionPreprocessorExtension _versionPreprocessorExtension; + + public override PreprocessorExtension PreprocessorExtension + { + get + { + // If we haven't created the preprocessor then do it now + if (_versionPreprocessorExtension == null) + _versionPreprocessorExtension = new WixFileVersionPreprocessorExtension(); + + // Return the preprocessor + return _versionPreprocessorExtension; + } + } + } +} diff --git a/WixFileVersionExtension.csproj b/WixFileVersionExtension.csproj new file mode 100644 index 0000000..8449b0c --- /dev/null +++ b/WixFileVersionExtension.csproj @@ -0,0 +1,95 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {B08D9E52-612D-4F12-9023-F239D431A06F} + Library + Properties + WixFileVersionExtension + WixFileVersionExtension + v3.5 + 512 + + + + + + + + + + + + + 3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + ..\..\..\..\..\..\Program Files (x86)\WiX Toolset v3.8\bin\wix.dll + + + + + + + + + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + + + \ No newline at end of file diff --git a/WixFileVersionExtension.sln b/WixFileVersionExtension.sln new file mode 100644 index 0000000..fea8499 --- /dev/null +++ b/WixFileVersionExtension.sln @@ -0,0 +1,24 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WixFileVersionExtension", "WixFileVersionExtension.csproj", "{B08D9E52-612D-4F12-9023-F239D431A06F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B08D9E52-612D-4F12-9023-F239D431A06F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B08D9E52-612D-4F12-9023-F239D431A06F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B08D9E52-612D-4F12-9023-F239D431A06F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B08D9E52-612D-4F12-9023-F239D431A06F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(SubversionScc) = preSolution + Svn-Managed = True + Manager = AnkhSVN - Subversion Support for Visual Studio + EndGlobalSection +EndGlobal diff --git a/WixFileVersionPreprocessorExtension.cs b/WixFileVersionPreprocessorExtension.cs new file mode 100644 index 0000000..7d7ee94 --- /dev/null +++ b/WixFileVersionPreprocessorExtension.cs @@ -0,0 +1,49 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Reflection; + +using Microsoft.Tools.WindowsInstallerXml; + +namespace WixFileVersionExtension +{ + public class WixFileVersionPreprocessorExtension : PreprocessorExtension + { + private static readonly string[] prefixes = { "fileVersion" }; + + public override string[] Prefixes + { + get { return prefixes; } + } + + public override string EvaluateFunction(string prefix, string function, string[] args) + { + switch (prefix) + { + case "fileVersion": + // Make sure there actually is a file name + if (args.Length == 0 || args[0].Length == 0) + throw new ArgumentException("File name not specified"); + + // Make sure the file exists + if (!File.Exists(args[0])) + throw new ArgumentException(string.Format("File name {0} does not exist", args[0])); + + // Get the file version information for the given file + FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(args[0]); + + // Get the property that matches the name of the function + PropertyInfo propertyInfo = fileVersionInfo.GetType().GetProperty(function); + + // Make sure the property exists + if (propertyInfo == null) + throw new ArgumentException(string.Format("Unable to find property {0} in FileVersionInfo", function)); + + // Return the value of the property as a string + return propertyInfo.GetValue(fileVersionInfo, null).ToString(); + } + + return null; + } + } +}