【问题标题】:Is there a "ZIP project" in Visual Studio? [closed]Visual Studio 中是否有“ZIP 项目”? [关闭]
【发布时间】:2011-06-15 05:39:33
【问题描述】:
在 Visual Studio 中有几个“设置和部署”项目,其中之一是“CAB 项目”。
但我实际上想要一个简单的“ZIP 项目”,它使我能够从我的解决方案中添加一些文件夹 + dll,并将它们全部打包成一个 zip 文件,以便在网络上轻松分发。
编辑
@芝士
我创建了一个虚拟的“类库”项目,它依赖于所有子项目。
在这个虚拟项目中,我使用构建后事件使用 7-zip 压缩 dll。
但我希望有更好的解决方案。
【问题讨论】:
标签:
visual-studio
msbuild
zip
project
cab
【解决方案1】:
MSBuild Extension Pack 提供了一些您可以使用的compression tasks。
例如,编辑您的项目文件,取消注释“AfterBuild”目标并包括一个适当的压缩任务来打包您想要的内容。
<Project>
...
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
-->
<Target Name="AfterBuild">
<ItemGroup>
<!-- Set the collection of files to Zip-->
<FilesToZip Include="C:\YourContent\*"/>
</ItemGroup>
<MSBuild.ExtensionPack.Compression.DNZip TaskAction="Create" CompressFiles="@(FilesToZip)" ZipFileName="C:\YourZipFile.zip"/>
</Target>
</Project>
【解决方案2】:
如果我了解您的需求,一个快速简便的解决方案可能是编写一个作为构建后事件运行的 powershell 或 Javascript 脚本或批处理文件。
您可能需要一个 zip 库。 DotNetZip 有效。
【解决方案3】:
DPack 有一个(营销不佳的)功能,称为解决方案备份,它将在 Visual Studio 中创建解决方案的 zip 文件。
安装免费且无痛。