Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/7.0] Add override option to force using tar on Windows. #12174

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Microsoft.DotNet.Build.Tasks.Archives/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ This SDK also supports automatically skipping builds on unsupported platforms or

Additionally, if a `ProjectServicingConfiguration` item is provided with the identity of the project name and the `PatchVersion` metadata on the item is not equal to the current `PatchVersion`, the build will be skipped. This support enables a repository to disable building targeting packs in servicing releases if that is desired.

# Creating tar.gz archives on Windows

There is an override that you can use to opt into generating tar.gz archives instead of zip archives on Windows to get an consistent experience as with linux and macos.
That opt-in is setting ``ArchiveFormat`` to ``tar.gz`` on a project that uses this package when building for Windows.
This can also be used on Linux and MacOS to force creating ``zip`` archives as well.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>

<PropertyGroup>
<ArchiveFormat Condition="$([MSBuild]::IsOSPlatform(Windows)) AND '$(ArchiveFormat)' == ''">zip</ArchiveFormat>
<ArchiveFormat Condition="!$([MSBuild]::IsOSPlatform(Windows)) AND '$(ArchiveFormat)' == ''">tar.gz</ArchiveFormat>
</PropertyGroup>

</Project>
14 changes: 6 additions & 8 deletions src/Microsoft.DotNet.Build.Tasks.Archives/build/archives.targets
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@
<_OutputPathRoot>$(IntermediateOutputPath)output/</_OutputPathRoot>
<_ArchiveFileName>$(ArchiveName)-$(Version)</_ArchiveFileName>
<_ArchiveFileName Condition="'$(RuntimeIdentifier)' != ''">$(ArchiveName)-$(Version)-$(RuntimeIdentifier)</_ArchiveFileName>
<_DestinationFileName Condition="$([MSBuild]::IsOSPlatform(Windows))">$(PackageOutputPath)/$(_ArchiveFileName).zip</_DestinationFileName>
<_DestinationFileName Condition="!$([MSBuild]::IsOSPlatform(Windows))">$(PackageOutputPath)/$(_ArchiveFileName).tar.gz</_DestinationFileName>
<_DestinationFileName>$(PackageOutputPath)/$(_ArchiveFileName).$(ArchiveFormat)</_DestinationFileName>
</PropertyGroup>
<MSBuild Projects="$(MSBuildProjectFullPath)"
Targets="PublishToDisk"
Expand All @@ -83,11 +82,11 @@
<ZipDirectory SourceDirectory="$(_OutputPathRoot)"
Overwrite="true"
DestinationFile="$(_DestinationFileName)"
Condition="$([MSBuild]::IsOSPlatform(Windows))"/>
Condition="'$(ArchiveFormat)' == 'zip'"/>
<Exec Command="tar -C '$(_OutputPathRoot)' -czf $(_DestinationFileName) ."
IgnoreExitCode="true"
IgnoreStandardErrorWarningFormat="true"
Condition="!$([MSBuild]::IsOSPlatform(Windows))"/>
Condition="'$(ArchiveFormat)' == 'tar.gz'"/>

<Message Text="$(_OutputPathRoot) -> $(_DestinationFileName)" Importance="high" />
</Target>
Expand All @@ -98,8 +97,7 @@
<_SymbolsOutputPathRoot>$(IntermediateOutputPath)symbols/</_SymbolsOutputPathRoot>
<_ArchiveFileName>$(SymbolsArchiveName)-$(Version)</_ArchiveFileName>
<_ArchiveFileName Condition="'$(RuntimeIdentifier)' != ''">$(SymbolsArchiveName)-$(RuntimeIdentifier)-$(Version)</_ArchiveFileName>
<_DestinationFileName Condition="$([MSBuild]::IsOSPlatform(Windows))">$(PackageOutputPath)/$(_ArchiveFileName).zip</_DestinationFileName>
<_DestinationFileName Condition="!$([MSBuild]::IsOSPlatform(Windows))">$(PackageOutputPath)/$(_ArchiveFileName).tar.gz</_DestinationFileName>
<_DestinationFileName>$(PackageOutputPath)/$(_ArchiveFileName).$(ArchiveFormat)</_DestinationFileName>
</PropertyGroup>
<MSBuild Projects="$(MSBuildProjectFullPath)"
Targets="PublishSymbolsToDisk"
Expand All @@ -109,11 +107,11 @@
<ZipDirectory SourceDirectory="$(_SymbolsOutputPathRoot)"
Overwrite="true"
DestinationFile="$(_DestinationFileName)"
Condition="$([MSBuild]::IsOSPlatform(Windows))"/>
Condition="'$(ArchiveFormat)' == 'zip'"/>
<Exec Command="tar -C '$(_SymbolsOutputPathRoot)' -czf $(_DestinationFileName) ."
IgnoreExitCode="true"
IgnoreStandardErrorWarningFormat="true"
Condition="!$([MSBuild]::IsOSPlatform(Windows))"/>
Condition="'$(ArchiveFormat)' == 'tar.gz'"/>

<Message Text="$(_SymbolsOutputPathRoot) -> $(_DestinationFileName)" Importance="high" />
</Target>
Expand Down