Reputation: 18127
I have an MSBuild script as shown below, which grabs the class library Bin\Release\MyLib.dll
and zips it into C:\1.zip
.
When I open the zip file I see MyLib.dll
file in the parent folder.
But I would like to have a directory structure in the ZIP file, so the file would be zipped as lib\MyLib.dll
How can I do that?
<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>
Upvotes: 2
Views: 4149
Reputation: 3836
I would:
Here's the code:
<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>
Upvotes: 4