Question

I know that using MSBuild Extension Pack I can decompress Zip files, but in my project I need to decompress a RAR file.

How can I do this?

Was it helpful?

Solution

Use Exec to extract archive by winrar.exe/rar.exe. If you have installed WinRar you can extract its installdir from registry otherwise specify where you rar.exe is located.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">

<Target Name="ExtractRar">
    <PropertyGroup>
        <RarExe>$(registry:HKEY_LOCAL_MACHINE\Software\Winrar@exe32)</RarExe>
        <archive>E:\sample.rar</archive>
        <targetDir>E:\ExtratedArchive\</targetDir>
    </PropertyGroup>
    <Exec Command="&quot;$(RarExe)&quot; x &quot;$(archive)&quot; &quot;$(targetDir)&quot;" /> 
</Target>

</Project>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top