Skip to content

Commit dd98058

Browse files
committed
Transform paths when using git's tar on Windows
- also narrow `tar` workaround to Microsoft.AspNetCore.App.Ref project - not needed in Microsoft.AspNetCore.App.Runtime project
1 parent 89cdb51 commit dd98058

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

src/Framework/Directory.Build.props

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66
<!-- Shared between targeting pack and runtime build. -->
77
<PlatformManifestFileName>PlatformManifest.txt</PlatformManifestFileName>
88
<PlatformManifestOutputPath>$(ArtifactsObjDir)$(PlatformManifestFileName)</PlatformManifestOutputPath>
9-
10-
<!-- Work around issues finding the `tar` command on CI machines. -->
11-
<TarCommand>tar</TarCommand>
12-
<TarCommand Condition="'$(OS)' == 'Windows_NT'">C:\Windows\System32\tar.exe</TarCommand>
13-
<TarCommand Condition="'$(OS)' == 'Windows_NT' AND !Exists('$(TarCommand)')">C:\Program Files\Git\usr\bin\tar.exe</TarCommand>
14-
<TarCommand Condition="'$(OS)' == 'Windows_NT' AND !Exists('$(TarCommand)')">C:\Program Files (x86)\Git\usr\bin\tar.exe</TarCommand>
15-
<TarCommand Condition="'$(OS)' == 'Windows_NT'">&quot;$(TarCommand)&quot;</TarCommand>
169
</PropertyGroup>
1710

1811
<ItemGroup>

src/Framework/ref/Microsoft.AspNetCore.App.Ref.csproj

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,30 @@ This package is an internal implementation of the .NET Core SDK and is not meant
169169
Inputs="@(RefPackContent)"
170170
Outputs="$(ZipArchiveOutputPath);$(TarArchiveOutputPath)"
171171
Condition="'$(IsPackable)' == 'true'">
172+
<PropertyGroup>
173+
<!-- Work around issues finding the `tar` command on CI machines. -->
174+
<TarCommand>tar</TarCommand>
175+
<TarCommand
176+
Condition="'$(OS)' == 'Windows_NT' AND Exists('$(SystemRoot)\System32\tar.exe')">"$(SystemRoot)\System32\tar.exe"</TarCommand>
177+
<TarCommand
178+
Condition="'$(OS)' == 'Windows_NT' AND Exists('$(ProgramFiles)\Git\usr\bin\tar.exe')">"$(ProgramFiles)\Git\usr\bin\tar.exe"</TarCommand>
179+
<TarCommand
180+
Condition="'$(OS)' == 'Windows_NT' AND Exists('$(MSBuildProgramFiles32)\Git\usr\bin\tar.exe')">"$(MSBuildProgramFiles32)\Git\usr\bin\tar.exe"</TarCommand>
181+
182+
<!-- For the tar packed with git, transform e.g. "C:\root\AspNetCore\File.tar.gz" to "/C/root/AspNetCore/File.tar.gz". -->
183+
<_TarArchiveOutputPath>$(TarArchiveOutputPath)</_TarArchiveOutputPath>
184+
<_TarArchiveOutputPath
185+
Condition="$(TarCommand.Contains('\Git\'))">/$(TarArchiveOutputPath.Replace('\','/').Replace(':',''))</_TarArchiveOutputPath>
186+
</PropertyGroup>
187+
172188
<ZipDirectory
173189
SourceDirectory="$(TargetingPackLayoutRoot)"
174190
DestinationFile="$(ZipArchiveOutputPath)"
175191
Overwrite="true" />
192+
176193
<!-- Requires Windows 10 version 1803 or newer -->
177194
<Exec
178-
Command="$(TarCommand) -czf $(TarArchiveOutputPath) ."
195+
Command="$(TarCommand) -czf $(_TarArchiveOutputPath) ."
179196
WorkingDirectory="$(TargetingPackLayoutRoot)" />
180197
<Message Importance="High" Text="$(MSBuildProjectName) -> $(TarArchiveOutputPath)" />
181198
</Target>

src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
371371

372372
<!-- Extract the dotnet-runtime archive -->
373373
<Exec Condition="'$(ArchiveExtension)' == '.tar.gz'"
374-
Command="$(TarCommand) -xzf $(DotNetRuntimeArchive) -C $(RedistSharedFrameworkLayoutRoot)" />
374+
Command="tar -xzf $(DotNetRuntimeArchive) -C $(RedistSharedFrameworkLayoutRoot)" />
375375

376376
<Unzip Condition="'$(ArchiveExtension)' == '.zip'"
377377
SourceFiles="$(DotNetRuntimeArchive)"
@@ -436,7 +436,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
436436
Overwrite="true"
437437
Condition="'$(ArchiveExtension)' == '.zip'" />
438438
<Exec
439-
Command="$(TarCommand) -czf $(InternalArchiveOutputPath) ."
439+
Command="tar -czf $(InternalArchiveOutputPath) ."
440440
WorkingDirectory="$(SharedFrameworkLayoutRoot)"
441441
Condition="'$(ArchiveExtension)' == '.tar.gz'" />
442442
</Target>
@@ -453,7 +453,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
453453
Overwrite="true"
454454
Condition="'$(ArchiveExtension)' == '.zip'" />
455455
<Exec
456-
Command="$(TarCommand) -czf $(RedistArchiveOutputPath) ."
456+
Command="tar -czf $(RedistArchiveOutputPath) ."
457457
WorkingDirectory="$(RedistSharedFrameworkLayoutRoot)"
458458
Condition="'$(ArchiveExtension)' == '.tar.gz'" />
459459
</Target>

0 commit comments

Comments
 (0)