Skip to content

Commit 13b2084

Browse files
radicalakoeplinger
andauthored
[release/9.0] Backport archives.targets: Fix creating tar.gz on Windows (#15931)
Co-authored-by: Alexander Köplinger <[email protected]>
1 parent 533b40e commit 13b2084

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/Microsoft.DotNet.Build.Tasks.Archives/build/archives.targets

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,12 @@
8080
<Target Name="_CreateArchive"
8181
Condition="'$(SkipArchivesBuild)' != 'true'">
8282
<PropertyGroup>
83-
<_OutputPathRoot>$(IntermediateOutputPath)output/</_OutputPathRoot>
83+
<_OutputPathRoot>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'output'))</_OutputPathRoot>
8484
<_ArchiveFileName>$(ArchiveName)-$(Version)</_ArchiveFileName>
8585
<_ArchiveFileName Condition="'$(RuntimeIdentifier)' != ''">$(ArchiveName)-$(Version)-$(RuntimeIdentifier)</_ArchiveFileName>
86-
<_DestinationFileName>$(PackageOutputPath)/$(_ArchiveFileName).$(ArchiveFormat)</_DestinationFileName>
86+
<_DestinationFileName>$([MSBuild]::NormalizePath($(PackageOutputPath), '$(_ArchiveFileName).$(ArchiveFormat)'))</_DestinationFileName>
8787
</PropertyGroup>
88+
<MakeDir Directories="$(_OutputPathRoot)" />
8889
<MSBuild Projects="$(MSBuildProjectFullPath)"
8990
Targets="PublishToDisk"
9091
Properties="OutputPath=$(_OutputPathRoot)" />
@@ -94,9 +95,10 @@
9495
Overwrite="true"
9596
DestinationFile="$(_DestinationFileName)"
9697
Condition="'$(ArchiveFormat)' == 'zip'"/>
97-
<Exec Command="tar -C '$(_OutputPathRoot)' -czf $(_DestinationFileName) ."
98+
<Exec Command="tar -czf $(_DestinationFileName) ."
9899
IgnoreExitCode="true"
99100
IgnoreStandardErrorWarningFormat="true"
101+
WorkingDirectory="$(_OutputPathRoot)"
100102
Condition="'$(ArchiveFormat)' == 'tar.gz'"/>
101103

102104
<Message Text="$(_OutputPathRoot) -> $(_DestinationFileName)" Importance="high" />
@@ -105,11 +107,12 @@
105107
<Target Name="_CreateSymbolsArchive"
106108
Condition="'$(CreateSymbolsArchive)' == 'true' and '$(SkipArchivesBuild)' != 'true'">
107109
<PropertyGroup>
108-
<_SymbolsOutputPathRoot>$(IntermediateOutputPath)symbols/</_SymbolsOutputPathRoot>
110+
<_SymbolsOutputPathRoot>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'symbols'))</_SymbolsOutputPathRoot>
109111
<_ArchiveFileName>$(SymbolsArchiveName)-$(Version)</_ArchiveFileName>
110112
<_ArchiveFileName Condition="'$(RuntimeIdentifier)' != ''">$(SymbolsArchiveName)-$(RuntimeIdentifier)-$(Version)</_ArchiveFileName>
111-
<_DestinationFileName>$(PackageOutputPath)/$(_ArchiveFileName).$(ArchiveFormat)</_DestinationFileName>
113+
<_DestinationFileName>$([MSBuild]::NormalizePath($(PackageOutputPath), '$(_ArchiveFileName).$(ArchiveFormat)'))</_DestinationFileName>
112114
</PropertyGroup>
115+
<MakeDir Directories="$(_SymbolsOutputPathRoot)" />
113116
<MSBuild Projects="$(MSBuildProjectFullPath)"
114117
Targets="PublishSymbolsToDisk"
115118
Properties="SymbolsOutputPath=$(_SymbolsOutputPathRoot)" />
@@ -119,9 +122,10 @@
119122
Overwrite="true"
120123
DestinationFile="$(_DestinationFileName)"
121124
Condition="'$(ArchiveFormat)' == 'zip'"/>
122-
<Exec Command="tar -C '$(_SymbolsOutputPathRoot)' -czf $(_DestinationFileName) ."
125+
<Exec Command="tar -czf $(_DestinationFileName) ."
123126
IgnoreExitCode="true"
124127
IgnoreStandardErrorWarningFormat="true"
128+
WorkingDirectory="$(_SymbolsOutputPathRoot)"
125129
Condition="'$(ArchiveFormat)' == 'tar.gz'"/>
126130

127131
<Message Text="$(_SymbolsOutputPathRoot) -> $(_DestinationFileName)" Importance="high" />

0 commit comments

Comments
 (0)