2012-01-31 40 views
1

我有一个如下所示的MSBuild脚本,它抓取类库Bin\Release\MyLib.dll并将其压缩到C:\1.zipMSBuild.Community.Tasks和Zip,设置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> 

回答

3

我想:

  1. 打造的 “LIB” 文件夹
  2. 有问题的DLL复制到 “LIB” 文件夹
  3. 拉上了 “LIB” 文件夹现在包含了DLL。

下面的代码:

<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>