The following allows you to package up your build output into a SFX file with custom properties that appear when someone right clicks the SFX and chooses properties.
Useful if you need to create a zip that can be signed but want your company/product information to appear on the SFX.EXE.
<Target Name="AfterCompileSolution" Condition="'$(Solution)'=='$(examplesol_Root)\examplesol.sln' And'$(BuildBreak'!='true'">
<PropertyGroup>
<rcfile>7za.rc</rcfile>
<resfile>resource.res</resfile>
<rccontent>
1 VERSIONINFO
FILEVERSION 4,65,0,0
PRODUCTVERSION 4,65,0,0
FILEOS 0x40004
FILETYPE 0x1
{
BLOCK "StringFileInfo"
{
BLOCK "040904B0"
{
VALUE "CompanyName", "Example Company"
VALUE "FileDescription", "Example Update"
VALUE "FileVersion", "1.0"
VALUE "InternalName", "Example.exe"
VALUE "LegalCopyright", "Copyright (c) 2013 Example Company"
VALUE "OriginalFilename", "Example.exe"
VALUE "ProductName", "Example Update"
VALUE "ProductVersion", "$(ExampleVersion)"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x0409 0x04B0
}
}
</rccontent>
<installerexepath>$(examplesol_Root)\Example\Product Configuration 1\Release\DiskImages\DISK1</installerexepath>
<installerexe>Example.exe</installerexe>
</PropertyGroup>
<Message Text="Generating RC Script" />
<WriteLinesToFile File="$(examplesol_Root)\$(rcfile)" Lines="$(rccontent)" Overwrite="true" />
<Message Text="Compile Resource file from Resource Script" />
<Exec ContinueOnError="false" WorkingDirectory="$(examplesol_Root)"
Command=""$(winSDKPath)\bin\rc.exe" /fo ".\$(resfile)" ".\$(rcfile)"" />
<Message Text="Move update file" />
<Move SourceFiles="$(installerexepath)\$(installerexe)" DestinationFolder="$(examplesol_Root)\Example\" />
<Message Text="Zipping installer for Update" />
<!-- Use full paths for files so dir struct is not preserved-->
<Exec ContinueOnError="false" WorkingDirectory="$(examplesol_Root)"
Command=""$(Root)\BuildTools\7zip\7za.exe" a -sfx ".\$(installerexe)" ".\Manifest.xml" ".\Example\$(installerexe)"" />
<Message Text="Applying Resource changes to sfx file" />
<Exec ContinueOnError="false" WorkingDirectory="$(examplesol_Root)"
Command="$(Root)\BuildTools\reshacker\ResHacker.exe -delete $(installerexe),$(installerexe),versioninfo,1," />
<Exec ContinueOnError="false" WorkingDirectory="$(examplesol_Root)"
Command="$(Root)\BuildTools\reshacker\ResHacker.exe -add $(installerexe),$(installerexe),$(resfile),,," />
<Message Text="Move log file to dir" />
<Move SourceFiles="$(Root)\BuildTools\reshacker\reshacker.log" DestinationFolder="$(examplesol_Root)\" />
<OnError ExecuteTargets="UndoCheckout"/>
</Target>