Skip to content

Commit 8a59652

Browse files
authored
[release/3.1] Clear layout directories before copies (#37208)
- backport of #36719 Clear layout directories before copies (#36719) - `<Copy />` task (well, most tasks though not `tar` commands) will create directories - avoid leftover files from a previous build - avoid confusing SDK with an empty targeting pack directory - prevented ASP.NET targeting pack download when not building it (see #36718)
1 parent 54c406a commit 8a59652

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,21 +184,19 @@ This package is an internal implementation of the .NET Core SDK and is not meant
184184
DependsOnTargets="_ResolveTargetingPackContent"
185185
Inputs="@(RefPackContent)"
186186
Outputs="@(RefPackContent->'$(LayoutTargetDir)%(PackagePath)%(FileName)%(Extension)')">
187+
<RemoveDir Directories="$(TargetingPackLayoutRoot)" />
187188
<Copy SourceFiles="@(RefPackContent)"
188189
DestinationFiles="@(RefPackContent->'$(LayoutTargetDir)%(PackagePath)%(FileName)%(Extension)')"
189190
UseHardlinksIfPossible="true" />
190191
<Message Importance="High" Text="$(MSBuildProjectName) -> $(LayoutTargetDir)" />
191192
</Target>
192193

193-
<ItemGroup>
194-
<CreateDirectory Include="$(LocalInstallationOutputPath)" />
195-
</ItemGroup>
196-
197194
<!-- Workaround https://github.com/dotnet/sdk/issues/2910 by copying targeting pack into local installation. -->
198195
<Target Name="_InstallTargetingPackIntoLocalDotNet"
199196
DependsOnTargets="_ResolveTargetingPackContent"
200197
Inputs="@(RefPackContent)"
201198
Outputs="@(RefPackContent->'$(LocalInstallationOutputPath)%(PackagePath)%(FileName)%(Extension)')">
199+
<RemoveDir Directories="$(LocalInstallationOutputPath)" />
202200
<Copy SourceFiles="@(RefPackContent)"
203201
DestinationFiles="@(RefPackContent->'$(LocalInstallationOutputPath)%(PackagePath)%(FileName)%(Extension)')"
204202
UseHardlinksIfPossible="true" />

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -313,18 +313,11 @@ This package is an internal implementation of the .NET Core SDK and is not meant
313313
<CoreCLRJitPath>$(CrossgenToolDir)$(LibPrefix)clrjit$(LibExtension)</CoreCLRJitPath>
314314
</PropertyGroup>
315315

316-
<ItemGroup>
317-
<CreateDirectory Include="$(CrossgenToolDir)" />
318-
<CreateDirectory Include="$(CrossgenPlatformAssembliesDir)" />
319-
<CreateDirectory Include="$(SharedFxLayoutTargetDir)" />
320-
<CreateDirectory Include="$(RedistLayoutTargetDir)" />
321-
<CreateDirectory Include="$(LocalInstallationOutputPath)" />
322-
</ItemGroup>
323-
324316
<Target Name="Crossgen" DependsOnTargets="$(CrossgenDependsOn)" />
325317

326318
<Target Name="PrepareForCrossGen" Condition="'$(CrossgenOutput)' == 'true'">
327319
<!-- The output directories of assemblies built in this repo contain a mix of ref and impl assemblies. Copy impl assemblies to a separate directory. -->
320+
<RemoveDir Directories="$(CrossgenPlatformAssembliesDir)" />
328321
<Copy SourceFiles="@(ReferenceCopyLocalPaths)" DestinationFolder="$(CrossgenPlatformAssembliesDir)" Condition="'%(ReferenceCopyLocalPaths.ProjectPath)' != ''"/>
329322

330323
<!-- Resolve list of assemblies to crossgen -->
@@ -350,6 +343,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
350343
<CrossgenPlatformAssemblyPaths Condition="HasTrailingSlash($(CrossgenPlatformAssemblyPaths)) AND '$(OS)' == 'Windows_NT'">$(CrossgenPlatformAssemblyPaths)\</CrossgenPlatformAssemblyPaths>
351344
</PropertyGroup>
352345

346+
<RemoveDir Directories="$(CrossgenToolDir)" />
353347
<WriteLinesToFile
354348
Lines="-platform_assemblies_paths &quot;$(CrossgenPlatformAssemblyPaths)&quot;"
355349
File="$(CrossgenToolDir)PlatformAssembliesPaths.rsp"
@@ -393,6 +387,8 @@ This package is an internal implementation of the .NET Core SDK and is not meant
393387
PrivateUri="$(DotNetRuntimePrivateDownloadUrl)"
394388
PrivateUriSuffix="$(DotNetAssetRootAccessTokenSuffix)"
395389
DestinationPath="$(DotNetRuntimeArchive)" />
390+
<RemoveDir Directories="$(RedistSharedFrameworkLayoutRoot)" />
391+
<MakeDir Directories="$(RedistSharedFrameworkLayoutRoot)" />
396392

397393
<!-- Extract the dotnet-runtime archive -->
398394
<Exec Condition="'$(ArchiveExtension)' == '.tar.gz'"
@@ -419,7 +415,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
419415
DependsOnTargets="_ResolveSharedFrameworkContent"
420416
Inputs="@(SharedFxContent)"
421417
Outputs="@(SharedFxContent->'$(SharedFxLayoutTargetDir)%(FileName)%(Extension)')">
422-
418+
<RemoveDir Directories="$(SharedFrameworkLayoutRoot)" />
423419
<Copy SourceFiles="@(SharedFxContent)"
424420
DestinationFiles="@(SharedFxContent->'$(SharedFxLayoutTargetDir)%(FileName)%(Extension)')"
425421
UseHardlinksIfPossible="true" />
@@ -431,7 +427,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
431427
DependsOnTargets="_ResolveSharedFrameworkContent"
432428
Inputs="@(SharedFxContent)"
433429
Outputs="@(SharedFxContent->'$(RedistLayoutTargetDir)%(FileName)%(Extension)')">
434-
430+
<RemoveDir Directories="$(RedistLayoutTargetDir)" />
435431
<Copy SourceFiles="@(SharedFxContent)"
436432
DestinationFiles="@(SharedFxContent->'$(RedistLayoutTargetDir)%(FileName)%(Extension)')"
437433
UseHardlinksIfPossible="true" />
@@ -444,7 +440,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
444440
Name="_InstallFrameworkIntoLocalDotNet"
445441
Inputs="@(SharedFxContent)"
446442
Outputs="@(SharedFxContent->'$(LocalInstallationOutputPath)%(FileName)%(Extension)')">
447-
443+
<RemoveDir Directories="$(LocalInstallationOutputPath)" />
448444
<Copy SourceFiles="@(SharedFxContent)"
449445
DestinationFiles="@(SharedFxContent->'$(LocalInstallationOutputPath)%(FileName)%(Extension)')"
450446
UseHardlinksIfPossible="true" />

0 commit comments

Comments
 (0)