我知道使用MSBuild扩展包我可以解压缩Zip文件,但在我的项目中我需要解压缩一个RAR文件。
我该怎么做?
答案 0 :(得分:2)
使用Exec通过winrar.exe / rar.exe解压缩归档。 如果您已经安装了WinRar,则可以从注册表中提取其installdir,否则请指定rar.exe所在的位置。
<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=""$(RarExe)" x "$(archive)" "$(targetDir)"" />
</Target>
</Project>