-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathinit-source-only.proj
116 lines (96 loc) · 5.42 KB
/
init-source-only.proj
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
109
110
111
112
113
114
115
116
<Project>
<!-- This project must not use any prebuilts -->
<PropertyGroup>
<SkipArcadeSdkImport>true</SkipArcadeSdkImport>
<!-- Fake, to satisfy the SDK. -->
<TargetFramework>netstandard2.0</TargetFramework>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
<EnableDefaultItems>false</EnableDefaultItems>
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<ExternalTarballsDir>$([MSBuild]::NormalizeDirectory('$(PrereqsPackagesDir)', 'archive'))</ExternalTarballsDir>
</PropertyGroup>
<Target Name="Build"
DependsOnTargets="
UnpackTarballs;
BuildMSBuildSdkResolver;
ExtractToolsetPackages" />
<!-- Unpacks the Private.SourceBuilt.Artifacts archive -->
<Target Name="UnpackSourceBuiltArtifactsArchive"
Condition="'$(CustomPrebuiltSourceBuiltPackagesPath)' == ''"
Inputs="$(ExternalTarballsDir)"
Outputs="$(PrebuiltSourceBuiltPackagesPath)">
<MakeDir Directories="$(PrebuiltSourceBuiltPackagesPath)" />
<Exec Command="tar -xzf $(ExternalTarballsDir)$(SourceBuiltArtifactsTarballName).*$(ArchiveExtension)"
WorkingDirectory="$(PrebuiltSourceBuiltPackagesPath)" />
</Target>
<!-- Check for a prebuilt dependency tarball and extract if exists. If there isn't one, we expect
the build to be working without prebuilts. -->
<Target Name="UnpackSourceBuiltPrebuiltsArchive"
Inputs="$(ExternalTarballsDir)"
Outputs="$(PrebuiltPackagesPath)">
<ItemGroup>
<SourceBuiltPrebuiltsTarballFile Include="$(ExternalTarballsDir)$(SourceBuiltPrebuiltsTarballName).*$(ArchiveExtension)" />
</ItemGroup>
<Exec Command="tar -xzf %(SourceBuiltPrebuiltsTarballFile.FullPath)"
WorkingDirectory="$(PrebuiltPackagesPath)"
Condition="'@(SourceBuiltPrebuiltsTarballFile)' != ''" />
</Target>
<!-- Copy SBRP packages to reference packages location. -->
<Target Name="CopySourceBuiltReferencePackages"
DependsOnTargets="UnpackSourceBuiltArtifactsArchive"
Inputs="$(PrebuiltSourceBuiltPackagesPath)SourceBuildReferencePackages"
Outputs="$(ReferencePackagesDir)">
<ItemGroup>
<UnpackedSourceBuildReferencePackage Include="$(PrebuiltSourceBuiltPackagesPath)SourceBuildReferencePackages/*" />
</ItemGroup>
<!-- When building iteratively (e.g. making infra changes), the directory may already exist and needs to be cleaned up. -->
<RemoveDir Directories="$(ReferencePackagesDir)" />
<!-- Either move or copy the unpacked SBRP packages.
Don't move when the packages directory is externally provided. -->
<Move SourceFiles="@(UnpackedSourceBuildReferencePackage)"
DestinationFolder="$(ReferencePackagesDir)"
Condition="'$(CustomPrebuiltSourceBuiltPackagesPath)' == ''" />
<Copy SourceFiles="@(UnpackedSourceBuildReferencePackage)"
DestinationFolder="$(ReferencePackagesDir)"
Condition="'$(CustomPrebuiltSourceBuiltPackagesPath)' != ''" />
</Target>
<Target Name="UnpackTarballs"
DependsOnTargets="UnpackSourceBuiltArtifactsArchive;
UnpackSourceBuiltPrebuiltsArchive;
CopySourceBuiltReferencePackages" />
<!-- Build the custom msbuild sdk resolver. -->
<Target Name="BuildMSBuildSdkResolver"
DependsOnTargets="UnpackTarballs"
Inputs="$(MSBuildProjectFullPath)"
Outputs="$(BaseIntermediateOutputPath)BuildMSBuildSdkResolver.complete">
<MSBuild Projects="$(TasksDir)Microsoft.DotNet.UnifiedBuild.MSBuildSdkResolver\Microsoft.DotNet.UnifiedBuild.MSBuildSdkResolver.csproj"
Targets="Restore"
Properties="MSBuildRestoreSessionId=$([System.Guid]::NewGuid())" />
<MSBuild Projects="$(TasksDir)Microsoft.DotNet.UnifiedBuild.MSBuildSdkResolver\Microsoft.DotNet.UnifiedBuild.MSBuildSdkResolver.csproj"
Targets="Build" />
<MakeDir Directories="$(BaseIntermediateOutputPath)" />
<Touch Files="$(BaseIntermediateOutputPath)BuildMSBuildSdkResolver.complete" AlwaysCreate="true">
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
</Touch>
</Target>
<!-- Extract toolset packages into the bootstrap folder -->
<Target Name="ExtractToolsetPackages" DependsOnTargets="UnpackTarballs">
<ItemGroup>
<ToolsetPackage Include="Microsoft.DotNet.Arcade.Sdk" SourceFolder="$(PrebuiltSourceBuiltPackagesPath)" Version="$(ARCADE_BOOTSTRAP_VERSION)" />
<ToolsetPackage Include="Microsoft.Build.NoTargets" SourceFolder="$(ReferencePackagesDir)" Version="$(NOTARGETS_BOOTSTRAP_VERSION)" />
<ToolsetPackage Include="Microsoft.Build.Traversal" SourceFolder="$(ReferencePackagesDir)" Version="$(TRAVERSAL_BOOTSTRAP_VERSION)" />
</ItemGroup>
<ItemGroup>
<ToolsetPackage Destination="$(BootstrapPackagesDir)$([System.String]::Copy('%(ToolsetPackage.Identity)').ToLowerInvariant())/%(ToolsetPackage.Version)" />
</ItemGroup>
<Unzip SourceFiles="%(ToolsetPackage.SourceFolder)%(ToolsetPackage.Identity).%(ToolsetPackage.Version).nupkg"
DestinationFolder="%(ToolsetPackage.Destination)"
SkipUnchangedFiles="true" />
<WriteLinesToFile File="$(ArtifactsDir)/toolset/bootstrap-sdks.txt"
Lines="@(ToolsetPackage->Metadata('Destination'))"
Overwrite="true" />
</Target>
</Project>