Repository navigation
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
71 lines (66 loc) · 5.64 KB
/
Copy pathDirectory.Build.targets
File metadata and controls
71 lines (66 loc) · 5.64 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
<Project>
<!--
Avalonia.BuildServices (pulled in by every Avalonia package) runs an AvaloniaStats
target before CoreCompile that records project, framework and OS details into
.avalonia-build-tasks/ for upload. Its only off switch is the AVALONIA_TELEMETRY_OPTOUT
environment variable, which a plain `dotnet build` won't have. Redefining the target
as empty turns it off for every build.
-->
<Target Name="AvaloniaStats" />
<!--
NuGet packages ship native libraries for every platform under runtimes/<rid>/, and a
framework-dependent build or publish copies all of them next to the app. The app ships as a
Linux AppImage per CPU, so keep only the runtimes folder of the one RID this build is for (SmmNativeRid:
the RuntimeIdentifier, else the SDK's portable one) plus the RID-neutral folders such as unix/ or any/,
and drop every other operating system and CPU: win-*, osx-*, the other linux-* CPUs,
linux-musl-*, linux-x86, linux-mips64 and so on. Left in, every test project carries its own
copy of each (libduckdb.so alone is 60 MB per RID) and a full suite run exhausts a 20 GB tmpfs.
Pruning the items keeps output paths as they are; a RuntimeIdentifier would append the RID to them.
This runs on the NuGet item lists themselves rather than on the copy-local list built
from them, because build output, publish and deps.json each read a different one of them.
Games run under Proton/Wine in a separate process and need none of these.
-->
<Import Project="$(MSBuildThisFileDirectory)src/SmmNativeRid.props" Condition="'$(SmmNativeRid)' == ''" />
<PropertyGroup>
<!-- Assumes SmmNativeRid is a linux-* identifier: Substring(6) drops the "linux-". -->
<_ForeignRuntimePattern>^runtimes/(win|osx|browser|android|ios|maccatalyst|tvos|tizen|linux-bionic|linux-(?!$(SmmNativeRid.Substring(6))/))</_ForeignRuntimePattern>
</PropertyGroup>
<Target Name="PruneForeignRuntimeAssets" AfterTargets="ResolveLockFileCopyLocalFiles">
<ItemGroup>
<NativeCopyLocalItems Remove="@(NativeCopyLocalItems)"
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(NativeCopyLocalItems.DestinationSubDirectory)', '$(_ForeignRuntimePattern)'))" />
<RuntimeTargetsCopyLocalItems Remove="@(RuntimeTargetsCopyLocalItems)"
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(RuntimeTargetsCopyLocalItems.DestinationSubDirectory)', '$(_ForeignRuntimePattern)'))" />
<_ResolvedCopyLocalBuildAssets Remove="@(_ResolvedCopyLocalBuildAssets)"
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(_ResolvedCopyLocalBuildAssets.DestinationSubDirectory)', '$(_ForeignRuntimePattern)'))" />
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)"
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(ReferenceCopyLocalPaths.DestinationSubDirectory)', '$(_ForeignRuntimePattern)'))" />
</ItemGroup>
</Target>
<!--
The NuGet lists above don't cover files a referenced project hands over as copy-to-output content.
The RID-agnostic libraries (Wabbajack, the UI projects) build without the app's -r, so SmmNativeRid falls
back to the build machine's CPU there, and a project that bundles natives (Wabbajack.Transforms,
Games.FromSoft) offers runtimes/<that rid>/native/* to the app. In an arm64 package that left x86-64
libooz and libsmmtexenc behind. Drop those from the build output and publish lists, using the same
pattern as above; the paths there use backslashes, hence the Replace.
-->
<Target Name="PruneForeignRuntimeContent" AfterTargets="GetCopyToOutputDirectoryItems">
<ItemGroup>
<AllItemsFullPathWithTargetPath Remove="@(AllItemsFullPathWithTargetPath)"
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($([System.String]::Copy('%(AllItemsFullPathWithTargetPath.TargetPath)').Replace('\', '/')), '$(_ForeignRuntimePattern)'))" />
<_SourceItemsToCopyToOutputDirectoryAlways Remove="@(_SourceItemsToCopyToOutputDirectoryAlways)"
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($([System.String]::Copy('%(_SourceItemsToCopyToOutputDirectoryAlways.TargetPath)').Replace('\', '/')), '$(_ForeignRuntimePattern)'))" />
<_SourceItemsToCopyToOutputDirectory Remove="@(_SourceItemsToCopyToOutputDirectory)"
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($([System.String]::Copy('%(_SourceItemsToCopyToOutputDirectory.TargetPath)').Replace('\', '/')), '$(_ForeignRuntimePattern)'))" />
<_SourceItemsToCopyToOutputDirectoryIfDifferent Remove="@(_SourceItemsToCopyToOutputDirectoryIfDifferent)"
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($([System.String]::Copy('%(_SourceItemsToCopyToOutputDirectoryIfDifferent.TargetPath)').Replace('\', '/')), '$(_ForeignRuntimePattern)'))" />
</ItemGroup>
</Target>
<Target Name="PruneForeignRuntimePublishContent" AfterTargets="ComputeResolvedFilesToPublishList">
<ItemGroup>
<ResolvedFileToPublish Remove="@(ResolvedFileToPublish)"
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($([System.String]::Copy('%(ResolvedFileToPublish.RelativePath)').Replace('\', '/')), '$(_ForeignRuntimePattern)'))" />
</ItemGroup>
</Target>
</Project>