Skip to content

Instantly share code, notes, and snippets.

@zippy1981
Created January 5, 2013 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zippy1981/4463936 to your computer and use it in GitHub Desktop.
Save zippy1981/4463936 to your computer and use it in GitHub Desktop.
Here is some working code to make a 7zip of a bin folder
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TargetSevenZip>$(TargetDir)\$(TargetName).7z</TargetSevenZip>
<!-- See http://msdn.microsoft.com/en-us/magazine/dd419659.aspx#id0090093 -->
<CleanDependsOn>
CleanArt;
CleanSevenZip
$(CleanDependsOn);
</CleanDependsOn>
<SevenZipDependsOn>Build;</SevenZipDependsOn>
</PropertyGroup>
<Target Name="CleanSevenZip">
<Delete Files="$(TargetSevenZip)"/>
</Target>
<Target Name="7zip" DependsOnTargets="$(SevenZipDependsOn)">
<PropertyGroup>
<SevenZipExePath>$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip', 'Path', null, RegistryView.Registry64))7z.exe</SevenZipExePath>
</PropertyGroup>
<Message Importance="Low" Text="7Zip executable: $(SevenZipExePath)"/>
<Error Condition="'$(SevenZipExePath)' == '' Or !Exists($(SevenZipExePath))" Text="7zip does not appear to be installed." />
<Exec Command="&quot;$(SevenZipExePath)&quot; a -t7z -mx9 -x &quot;poshrunner.vshost.exe&quot; &quot;$(TargetSevenZip)&quot; &quot;$(TargetDir)*&quot;"/>
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment