如何在MSBuild中压缩文件夹? [英] How do I zip a folder in MSBuild?

查看:116
本文介绍了如何在MSBuild中压缩文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在MSBuild中压缩输出文件夹?对于文件名,我需要使用在其他位置设置的变量.

How do I zip an output folder in MSBuild? For the filename I need to use a variable that gets set elsewhere.

推荐答案

"MSBuild.Community.Tasks.Zip"是一种方法. 未定义WorkingCheckout和OutputDirectory.

"MSBuild.Community.Tasks.Zip" is one way. WorkingCheckout and OutputDirectory are not defined.

但是您可以从下面得到漂移.

But you can get the drift below.

下面将获得不是我的zip的.config文件的所有文件.

The below will get all files that are not .config files for my zip.

请注意,主机"是我自定义的csproj文件夹名称,您的名称将有所不同.

Note "Host" is my custom csproj folder name, yours will be different.

<ItemGroup>
    <ZipFilesHostNonConfigExcludeFiles Include="$(WorkingCheckout)\Host\bin\$(Configuration)\**\*.config" />
</ItemGroup>
<!-- -->
<ItemGroup>
    <ZipFilesHostNonConfigIncludeFiles Include="$(WorkingCheckout)\Host\bin\$(Configuration)\**\*.*" Exclude="@(ZipFilesHostNonConfigExcludeFiles)" />
</ItemGroup>
<MSBuild.Community.Tasks.Zip Files="@(ZipFilesHostNonConfigIncludeFiles)" ZipFileName="$(OutputDirectory)\MyZipFileNameHere_$(Configuration).zip" WorkingDirectory="$(WorkingCheckout)\Host\bin\$(Configuration)\" />
<!-- -->

这是另一个主流选项:

http://msbuildextensionpack.codeplex.com/discussions/398966

这篇关于如何在MSBuild中压缩文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆