msbuildtasks
msbuildtasks copied to clipboard
Zip task should not require absolute working directory
Commit https://github.com/loresoft/msbuildtasks/commit/9ea598cdc230e6c1ccd76ea5574bdce01a8bfb9d started to expand the path of the Zip task's Files parameter.
Since the WorkingDirectory parameter is (only) used to strip a common prefix from all input paths, it stands to reason that the WorkingDirectory argument should also be expanded to restore the previous behavior.
Also, since all relative paths in an MSBuild file are relative to the file itself, the WorkingDirectory's default value (if empty, i.e. not specified) could be $(MSBuildProjectDirectory).
That way the user doesn't have to do it, like in this example that packages all source files into a ZIP file with relative file paths:
<Target Name="AfterBuild">
<ItemGroup>
<FilesToZip Include="**\*.cs" Exclude="obj\**\*.*"/>
<FilesToZip Include="**\*.xaml"/>
<FilesToZip Include="**\*.csproj"/>
<FilesToZip Include="**\*.xml"/>
<FilesToZip Include="**\*.md"/>
</ItemGroup>
<Zip ZipFileName="$(OutputPath)\$(AssemblyName)-demo.zip"
Files="@(FilesToZip)"
WorkingDirectory="$(MSBuildProjectDirectory)"/>
</Target>