forked from dotnet/dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
108 lines (88 loc) · 6.07 KB
/
Directory.Build.targets
File metadata and controls
108 lines (88 loc) · 6.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<Project>
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" Condition="'$(SkipArcadeSdkImport)' != 'true'" />
<UsingTask TaskName="Microsoft.DotNet.UnifiedBuild.Tasks.GetKnownArtifactsFromAssetManifests" AssemblyFile="$(MicrosoftDotNetUnifiedBuildTasksAssembly)" TaskFactory="TaskHostFactory" />
<!-- The SkipPrepareSdkArchive switch exists so that outside components like the license scan test pipeline
can run a subset of tests that don't need the SDK archive without building the VMR.
The switch is also useful for the local dev innerloop to build the test projects without needing to run them. -->
<Target Name="DetermineSourceBuiltSdkVersion" Condition="'$(SkipPrepareSdkArchive)' != 'true'">
<PropertyGroup>
<SdkFilenamePrefix>dotnet-sdk-</SdkFilenamePrefix>
</PropertyGroup>
<ItemGroup>
<SdkTarballItem Condition="'$(SdkTarballPath)' != ''" Include="$(SdkTarballPath)" />
<SdkTarballItem Condition="'$(SdkTarballPath)' == ''" Include="$(ArtifactsAssetsDir)Sdk/**/$(SdkFilenamePrefix)*$(ArchiveExtension)"
Exclude="$(ArtifactsAssetsDir)Sdk/**/$(SdkFilenamePrefix)*.wixpack.zip" />
</ItemGroup>
<Error Text="Didn't find an SDK archive." Condition="'@(SdkTarballItem)' == ''" />
<Error Text="Found more than one SDK archive." Condition="@(SdkTarballItem->Count()) > 1" />
<!--
Extract SDK version from SDK tarball filename.
Keep in sync with dotnet-sdk's archive location and filename.
Example:
artifacts\assets\<config>\Sdk\9.0.100-alpha.1.24057.1\dotnet-sdk-9.0.100-alpha.1.24057.1-fedora.38-x64.tar.gz
artifacts\assets\<config>\Sdk\<SdkVersion>\dotnet-sdk-<SdkVersion>-<TargetRid><ArchiveExtension>
-->
<PropertyGroup>
<SdkFilename>%(SdkTarballItem.Filename)%(SdkTarballItem.Extension)</SdkFilename>
<SdkTarballPath Condition="'$(SdkTarballPath)' == ''">%(SdkTarballItem.Identity)</SdkTarballPath>
<SourceBuiltSdkVersion>$(SdkFilename.Replace('$(SdkFilenamePrefix)','').Replace('-$(TargetRid)$(ArchiveExtension)',''))</SourceBuiltSdkVersion>
</PropertyGroup>
</Target>
<Target Name="DetermineSourceBuiltRuntimeVersion">
<PropertyGroup>
<RuntimeFilenamePrefix>dotnet-runtime-</RuntimeFilenamePrefix>
</PropertyGroup>
<ItemGroup>
<RuntimeArchiveItem Include="$(ArtifactsAssetsDir)Runtime/**/$(RuntimeFilenamePrefix)*$(ArchiveExtension)"
Exclude="$(ArtifactsAssetsDir)Runtime/**/$(RuntimeFilenamePrefix)*.wixpack.zip" />
</ItemGroup>
<Error Text="Didn't find a runtime archive." Condition="'@(RuntimeArchiveItem)' == ''" />
<Error Text="Found more than one runtime archive." Condition="@(RuntimeArchiveItem->Count()) > 1" />
<!--
Extract runtime version from the dotnet-runtime archive filename.
Keep in sync with dotnet-runtime's archive location and filename.
Example:
artifacts\assets\<config>\Runtime\9.0.100-alpha.1.24057.1\dotnet-runtime-9.0.100-alpha.1.24057.1-fedora.38-x64.tar.gz
artifacts\assets\<config>\Runtime\<RuntimeVersion>\dotnet-runtime-<RuntimeVersion>-<TargetRid><ArchiveExtension>
-->
<PropertyGroup>
<RuntimeFilename>%(RuntimeArchiveItem.Filename)%(RuntimeArchiveItem.Extension)</RuntimeFilename>
<RuntimeArchivePath>%(RuntimeArchiveItem.Identity)</RuntimeArchivePath>
<SourceBuiltRuntimeVersion>$(RuntimeFilename.Replace('$(RuntimeFilenamePrefix)','').Replace('-$(TargetRid)$(ArchiveExtension)',''))</SourceBuiltRuntimeVersion>
</PropertyGroup>
</Target>
<Target Name="GetFilteredSharedComponentPackages"
Outputs="@(_SharedComponentFilteredPackages)">
<PropertyGroup>
<_PreviouslySourceBuiltSharedComponentAssetManifests>$(SharedComponentsArtifactsPath)VerticalManifest.xml</_PreviouslySourceBuiltSharedComponentAssetManifests>
<SharedRepositoryReferenceString>;@(SharedRepositoryReference);</SharedRepositoryReferenceString>
<!-- Property to control filtering mode: true = include only tooling components, false = exclude tooling components (default) -->
<IncludeOnlyToolingComponents Condition="'$(IncludeOnlyToolingComponents)' == ''">false</IncludeOnlyToolingComponents>
</PropertyGroup>
<GetKnownArtifactsFromAssetManifests AssetManifests="$(_PreviouslySourceBuiltSharedComponentAssetManifests)"
Condition="Exists($(_PreviouslySourceBuiltSharedComponentAssetManifests))">
<Output TaskParameter="KnownPackages" ItemName="_SharedComponentFilteredPackages" />
</GetKnownArtifactsFromAssetManifests>
<!-- Filter tooling components based on the mode -->
<ItemGroup Condition="'$(IncludeOnlyToolingComponents)' == 'false'">
<!-- Default mode: Remove tooling components from the shared packages -->
<_ItemsToRemove Include="@(_SharedComponentFilteredPackages)"
Condition="!$(SharedRepositoryReferenceString.Contains(';%(RepoOrigin);')) or $([System.String]::new(';$(BootstrapArcadeRepos);').Contains(';%(RepoOrigin);'))" />
</ItemGroup>
<ItemGroup Condition="'$(IncludeOnlyToolingComponents)' == 'true'">
<!-- Alternate mode: Keep only tooling components, remove everything else -->
<_ItemsToRemove Include="@(_SharedComponentFilteredPackages)"
Condition="$(SharedRepositoryReferenceString.Contains(';%(RepoOrigin);')) and !$([System.String]::new(';$(BootstrapArcadeRepos);').Contains(';%(RepoOrigin);'))" />
</ItemGroup>
<!-- Create a lookup string of items to remove -->
<PropertyGroup>
<_ItemsToRemoveString>@(_ItemsToRemove->'%(Identity)::%(Version)', ';')</_ItemsToRemoveString>
</PropertyGroup>
<ItemGroup>
<_SharedComponentFilteredPackages Remove="@(_SharedComponentFilteredPackages)"
Condition="'@(_ItemsToRemove)' != '' and
'$(_ItemsToRemoveString)' != '' and
$(_ItemsToRemoveString.Contains($([System.String]::Concat('%(Identity)', '::', '%(Version)'))))" />
</ItemGroup>
</Target>
</Project>