문제

I'm looking at MSBuild.Extensionpack.Compression.Zip to add a custom build step where I'd like to add some files to an existing .zip archive.

<ItemGroup>
  <Files Include="$(MSBuildProjectDirectory)\SomeFolder\AnotherFolder\*.xml">
  </Files>
</ItemGroup>

<Message Text="@(Files)"></Message>

<MSBuild.ExtensionPack.Compression.Zip TaskAction="AddFiles" 
                        CompressFiles="@(Files)" ZipFileName="$(MyZipArchive)"/>

When running this, the files are indeed added to the zip archive, but not into the root. Instead it creates a file hierarchy that corresponds to the path of my project

Projects/MyProject/SomeFolder/AnotherFolder/myfile.xml

Any thoughts on how I can get the myfile.xml inside the root of the .zip archive?

도움이 되었습니까?

해결책

Sorry, I was getting to hasty. Just found the solution in the answer of this question.

The AddFiles action has an optional property RemoveRoot. Here you have to specify the string of the root you want to remove.

Final solution looks like this.

<ItemGroup>
  <Files Include="$(MSBuildProjectDirectory)\SomeFolder\AnotherFolder\*.xml">
  </Files>
</ItemGroup>

<MSBuild.ExtensionPack.Compression.Zip TaskAction="AddFiles" 
                        CompressFiles="@(Files)" ZipFileName="$(MyZipArchive)"
                        RemoveRoot=$(MSBuildProjectDirectory)\SomeFolder\AnotherFolder />
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top