我有一个MSBuild脚本,如下所示,它抓取类库Bin\Release\MyLib.dll
并将其拉入C:\1.zip
。
当我打开zip文件时,我在父文件夹中看到MyLib.dll
文件。
但我想在ZIP文件中有一个目录结构,因此该文件将被压缩为lib\MyLib.dll
我该怎么做?
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<Target Name="AfterBuild">
<PropertyGroup>
<ReleasePath>bin\Release\</ReleasePath>
</PropertyGroup>
<ItemGroup>
<ReleaseApplicationFiles
Include="$(ReleasePath)\**\*.*"
Exclude="$(ReleasePath)\*vshost.exe*;$(ReleasePath)\*.pdb*" />
</ItemGroup>
<Zip Files="@(ReleaseApplicationFiles)"
WorkingDirectory="$(ReleasePath)"
ZipFileName="c:\1.zip"
ZipLevel="9" />
</Target>
答案 0 :(得分:4)
我会:
以下是代码:
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<Target Name="AfterBuild">
<PropertyGroup>
<ReleasePath>bin\Release\</ReleasePath>
<Zipup>c:\archive\bin</Zipup>
</PropertyGroup>
<ItemGroup>
<ReleaseApplicationFiles Include="$(ReleasePath)\**\*.*" Exclude="$(ReleasePath)\*vshost.exe*;$(ReleasePath)\*.pdb*" />
</ItemGroup>
<Exec Command="mkdir $(Zipup)" IgnoreExitCode="False"/>
<Copy DestinationFolder="$(Zipup)" OverwriteReadOnlyFiles="True" SkipUnchangedFiles="False" SourceFiles="@(ReleaseApplicationFiles)" />
<Zip Files="$(Zipup)"
WorkingDirectory="$(ReleasePath)"
ZipFileName="c:\1.zip"
ZipLevel="9" />
</Target>