Repository navigation
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
210 lines (194 loc) · 15.6 KB
/
Copy pathDirectory.Build.targets
File metadata and controls
210 lines (194 loc) · 15.6 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<Project>
<PropertyGroup Condition="'$(WttsNativeAot)' == 'true'">
<DefineConstants>$(DefineConstants);WTTS_NATIVE_AOT</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(WttsUseSimdSkia)' == 'true'">
<DefineConstants>$(DefineConstants);WTTS_SIMD_SKIA</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(WttsStartupTrace)' == 'true'">
<DefineConstants>$(DefineConstants);STARTUP_WATCH_TRACE</DefineConstants>
</PropertyGroup>
<!-- Watt Toolkit uses only the System.Drawing.Color formatters in source Common. -->
<PropertyGroup>
<_WttsCommonProjectPath>$([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', 'ref/Common/src/BD.Common/BD.Common.csproj'))</_WttsCommonProjectPath>
</PropertyGroup>
<PropertyGroup Condition="'$(MSBuildProjectFullPath)' == '$(_WttsCommonProjectPath)'">
<DefineConstants>$(DefineConstants);COMMON_NO_SPLAT_DRAWING</DefineConstants>
</PropertyGroup>
<ItemGroup Condition="'$(MSBuildProjectFullPath)' == '$(_WttsCommonProjectPath)'">
<PackageReference Remove="Splat.Drawing" />
</ItemGroup>
<Target Name="WttsEmbedProjectSatelliteAssemblies" BeforeTargets="_ComputeIlcCompileInputs"
Condition="'$(WttsNativeAot)' == 'true' AND '$(PublishAot)' == 'true'">
<ItemGroup>
<ResolvedFileToPublish Condition="'%(ResolvedFileToPublish.Extension)' == '.dll' AND $([System.String]::Copy('%(ResolvedFileToPublish.Filename)').EndsWith('.resources'))">
<AssetType>resources</AssetType>
</ResolvedFileToPublish>
</ItemGroup>
</Target>
<!-- Use portable threading assets on Windows so they do not pull in WPF. -->
<Target Name="WttsSelectPortableNativeDependencies" AfterTargets="ResolvePackageAssets" BeforeTargets="AddTransitiveFrameworkReferences"
Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
<ItemGroup>
<_WttsPortableCompile Include="@(ResolvedCompileFileDefinitions)" Condition="'%(NuGetPackageId)' == 'Microsoft.VisualStudio.Threading.Only'">
<PortablePath>$(NuGetPackageRoot)microsoft.visualstudio.threading.only\%(NuGetPackageVersion)\lib\net8.0\Microsoft.VisualStudio.Threading.dll</PortablePath>
</_WttsPortableCompile>
<_WttsPortableRuntime Include="@(RuntimeCopyLocalItems)" Condition="'%(NuGetPackageId)' == 'Microsoft.VisualStudio.Threading.Only'">
<PortablePath>$(NuGetPackageRoot)microsoft.visualstudio.threading.only\%(NuGetPackageVersion)\lib\net8.0\Microsoft.VisualStudio.Threading.dll</PortablePath>
</_WttsPortableRuntime>
</ItemGroup>
<Error Condition="'@(_WttsPortableCompile)' != '' AND !Exists('%(_WttsPortableCompile.PortablePath)')"
Text="Desktop publication requires the portable dependency: %(_WttsPortableCompile.PortablePath)" />
<Error Condition="'@(_WttsPortableRuntime)' != '' AND !Exists('%(_WttsPortableRuntime.PortablePath)')"
Text="Desktop publication requires the portable dependency: %(_WttsPortableRuntime.PortablePath)" />
<ItemGroup>
<ResolvedCompileFileDefinitions Remove="@(_WttsPortableCompile)" />
<ResolvedCompileFileDefinitions Include="@(_WttsPortableCompile->'%(PortablePath)')" />
<RuntimeCopyLocalItems Remove="@(_WttsPortableRuntime)" />
<RuntimeCopyLocalItems Include="@(_WttsPortableRuntime->'%(PortablePath)')" />
<TransitiveFrameworkReference Remove="Microsoft.WindowsDesktop.App;Microsoft.WindowsDesktop.App.WPF" />
</ItemGroup>
</Target>
<Target Name="WttsArchiveNativeSymbols" AfterTargets="ComputeFilesToPublish"
Condition="('$(WttsNativeAot)' == 'true' AND '$(PublishAot)' == 'true') OR '$(MSBuildProjectName)' == 'BD.WTTS.Client.Avalonia.App' OR '$(MSBuildProjectName)' == 'BD.WTTS.Client.Plugins.Accelerator.ReverseProxy'">
<PropertyGroup>
<_WttsNativeSymbolsDirectory Condition="'$(ArtifactsPath)' != ''">$(ArtifactsPath)/symbols/$(MSBuildProjectName)/$(RuntimeIdentifier)/</_WttsNativeSymbolsDirectory>
<_WttsNativeSymbolsDirectory Condition="'$(_WttsNativeSymbolsDirectory)' == ''">$(BaseOutputPath)native-symbols/$(Configuration)/$(TargetFramework)/$(RuntimeIdentifier)/</_WttsNativeSymbolsDirectory>
</PropertyGroup>
<ItemGroup>
<_WttsNativeSymbols Include="@(ResolvedFileToPublish)" Condition="'%(Extension)' == '.pdb' OR '%(Extension)' == '.dbg'" />
<ResolvedFileToPublish Remove="@(_WttsNativeSymbols)" />
</ItemGroup>
<Copy SourceFiles="@(_WttsNativeSymbols)" DestinationFiles="@(_WttsNativeSymbols->'$(_WttsNativeSymbolsDirectory)%(RelativePath)')" SkipUnchangedFiles="true" />
</Target>
<!-- These executables host themselves; the CoreCLR IIS in-process loader cannot host Native AOT. -->
<Target Name="WttsExcludeNativeIisHosting" AfterTargets="ComputeFilesToPublish"
Condition="'$(WttsNativeAot)' == 'true' AND '$(PublishAot)' == 'true'">
<ItemGroup>
<ResolvedFileToPublish Remove="@(ResolvedFileToPublish)"
Condition="'%(Filename)%(Extension)' == 'aspnetcorev2_inprocess.dll'" />
</ItemGroup>
</Target>
<!-- Use the Linux DTLS libraries rebuilt against the release runner's glibc for both JIT and AOT. -->
<Target Name="WttsUseLinuxDtlsAssets" AfterTargets="ResolvePackageAssets"
Condition="'$(WttsLinuxDtlsAssets)' != '' AND ('$(RuntimeIdentifier)' == 'linux-x64' OR '$(RuntimeIdentifier)' == 'linux-arm64')">
<ItemGroup>
<_WttsLinuxDtlsAsset Include="@(NativeCopyLocalItems)"
Condition="'%(NativeCopyLocalItems.NuGetPackageId)' == 'DTLS' AND '%(NativeCopyLocalItems.Filename)%(NativeCopyLocalItems.Extension)' == 'libdtls_native.so'" />
</ItemGroup>
<Error Condition="'@(_WttsLinuxDtlsAsset)' != '' AND '%(_WttsLinuxDtlsAsset.NuGetPackageVersion)' != '0.5.1'"
Text="Rebuild the Linux DTLS libraries from the source revision matching the restored DTLS package." />
<Error Condition="'@(_WttsLinuxDtlsAsset)' != '' AND !Exists('$(WttsLinuxDtlsAssets)/native/libdtls_native.so')"
Text="The rebuilt Linux DTLS library was not found in '$(WttsLinuxDtlsAssets)/native'." />
<ItemGroup>
<NativeCopyLocalItems Remove="@(_WttsLinuxDtlsAsset)" />
<NativeCopyLocalItems Include="@(_WttsLinuxDtlsAsset->'$(WttsLinuxDtlsAssets)/native/libdtls_native.so')" />
</ItemGroup>
</Target>
<Target Name="WttsSupplyMacOSX64Dtls" BeforeTargets="_DTLSValidateStaticNativeLibrary"
DependsOnTargets="ResolvePackageAssets"
Condition="'$(WttsNativeAot)' == 'true' AND '$(PublishAot)' == 'true' AND '$(RuntimeIdentifier)' == 'osx-x64' AND '$(WttsMacOSX64DtlsAssets)' != ''">
<ItemGroup>
<_WttsDtlsReference Include="@(ResolvedCompileFileDefinitions)"
Condition="'%(NuGetPackageId)' == 'DTLS' AND '%(NuGetPackageVersion)' == '0.5.1'" />
<_WttsDtlsNativeAsset Include="@(NativeCopyLocalItems)" Condition="'%(NuGetPackageId)' == 'DTLS'" />
</ItemGroup>
<ItemGroup Condition="'@(_WttsDtlsReference)' != '' AND '@(_WttsDtlsNativeAsset)' == ''">
<NativeCopyLocalItems Include="$(WttsMacOSX64DtlsAssets)/native/libdtls_native.dylib">
<NuGetPackageId>DTLS</NuGetPackageId>
<NuGetPackageVersion>0.5.1</NuGetPackageVersion>
</NativeCopyLocalItems>
</ItemGroup>
</Target>
<!-- Precompile startup-heavy assemblies, not every SDK/API surface. Keep independent
IL assemblies and dynamic plugins; composite R2R and global trimming stay off. -->
<Target Name="WttsSelectStartupReadyToRunAssemblies" BeforeTargets="_PrepareForReadyToRunCompilation"
Condition="'$(MSBuildProjectName)' == 'BD.WTTS.Client.Avalonia.App' AND '$(PublishReadyToRun)' == 'true' AND '$(WttsNativeAot)' != 'true'">
<ItemGroup>
<_WttsIlOnlyAssembly Include="@(ResolvedFileToPublish)"
Condition="'%(ResolvedFileToPublish.Extension)' == '.dll' AND '%(ResolvedFileToPublish.Filename)' != 'Steam++' AND '%(ResolvedFileToPublish.Filename)' != 'BD.WTTS.Client' AND '%(ResolvedFileToPublish.Filename)' != 'BD.WTTS.Client.Avalonia' AND '%(ResolvedFileToPublish.Filename)' != 'Avalonia.Base' AND '%(ResolvedFileToPublish.Filename)' != 'Avalonia.Controls' AND '%(ResolvedFileToPublish.Filename)' != 'FluentAvalonia'" />
<PublishReadyToRunExclude Include="@(_WttsIlOnlyAssembly->'%(Filename)%(Extension)')" />
</ItemGroup>
</Target>
<!-- Windows development does not require the Apple workloads. Opt in for cross-platform builds. -->
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('windows')) AND '$(BuildAllTargetFrameworks)' != 'true' AND '$(WttsDesktopTargetFrameworks)' == '' AND $(TargetFrameworks.Contains('-windows')) AND $(TargetFrameworks.Contains('-macos'))">
<TargetFrameworks>$([MSBuild]::Unescape($([System.Text.RegularExpressions.Regex]::Replace('$(TargetFrameworks)', 'net[0-9.]+-(macos|maccatalyst)[0-9.]*;?', '').TrimEnd(';'))))</TargetFrameworks>
</PropertyGroup>
<!-- Limit platform projects when validating one desktop without changing plain .NET/resource projects. -->
<PropertyGroup Condition="'$(WttsDesktopTargetFrameworks)' != '' AND $(TargetFrameworks.Contains('-windows')) AND $(TargetFrameworks.Contains('-macos'))">
<TargetFrameworks>$([System.Text.RegularExpressions.Regex]::Replace('$(WttsDesktopTargetFrameworks)', '-.*', ''));$(WttsDesktopTargetFrameworks)</TargetFrameworks>
</PropertyGroup>
<!-- Restore compatible library targets without mobile workloads for macOS desktop publishing. -->
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(WttsDesktopTargetFrameworks)')) == 'macos' AND $(TargetFrameworks.Contains('-macos'))">
<TargetFrameworks>$([MSBuild]::Unescape($([System.Text.RegularExpressions.Regex]::Replace('$(TargetFrameworks)', 'net[0-9.]+-(?!macos)[^;]+;?', '').TrimEnd(';'))))</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition="'$(MSBuildProjectName)' == 'BD.WTTS.Client.Avalonia' OR ($([System.String]::Copy('$(MSBuildProjectName)').StartsWith('BD.WTTS.Client.Plugins.')) AND '$(MSBuildProjectName)' != 'BD.WTTS.Client.Plugins.Accelerator.ReverseProxy' AND '$(MSBuildProjectName)' != 'BD.WTTS.Client.Plugins.Update')">
<Compile Include="$(MSBuildThisFileDirectory)src\FluentAvaloniaAliases.cs" Link="Properties\FluentAvaloniaAliases.cs" />
</ItemGroup>
<PropertyGroup>
<_WttsSteamClientProjectPath>$([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', 'ref/SteamClient/src/BD.SteamClient/BD.SteamClient.csproj'))</_WttsSteamClientProjectPath>
</PropertyGroup>
<!-- SteamClient and the application must compile against the same formatter types. -->
<ItemGroup Condition="'$(MSBuildProjectFullPath)' == '$(_WttsSteamClientProjectPath)'">
<PackageReference Remove="BD.Common" />
<ProjectReference Include="$(MSBuildThisFileDirectory)ref\Common\src\BD.Common\BD.Common.csproj" />
<!-- App-info writes use Hashing directly. Keep the reference when removing Source Link's transitive copy. -->
<PackageReference Include="System.IO.Hashing"
Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net11.0'))" />
</ItemGroup>
<!-- These projects still consume the binary Common package and its MessagePack 2.x formatters. -->
<ItemGroup Condition="'$(MSBuildProjectName)' == 'BD.WTTS.Primitives' OR
'$(MSBuildProjectName)' == 'BD.WTTS.MicroServices.Primitives' OR
'$(MSBuildProjectName)' == 'BD.SteamClient.Models.Protobuf' OR
'$(MSBuildProjectName)' == 'Avalonia.Gif'">
<PackageReference Include="MessagePack" />
</ItemGroup>
<!-- bundle_green 2.1.11 has no newer release. Update its desktop native library. -->
<ItemGroup Condition="'$(MSBuildProjectName)' == 'BD.Common.Repositories.SQLitePCL'">
<PackageReference Include="SQLitePCLRaw.lib.e_sqlite3" />
</ItemGroup>
<!-- The AppCenter projects use PackageReference versions without central package management. -->
<ItemGroup Condition="'$(MSBuildProjectName)' == 'BD.AppCenter.Any' OR '$(MSBuildProjectName)' == 'BD.AppCenter.WindowsDesktop'">
<PackageReference Include="SQLitePCLRaw.lib.e_sqlite3" Version="2.1.14" />
</ItemGroup>
<!-- Source Link ships with the .NET SDK starting in 8.0. -->
<ItemGroup Condition="'$(EnableSourceLink)' == 'true' AND '$(NETCoreSdkVersion)' != '' AND
$([MSBuild]::VersionGreaterThanOrEquals('$(NETCoreSdkVersion)', '8.0'))">
<PackageReference Remove="Microsoft.SourceLink.GitHub" />
</ItemGroup>
<PropertyGroup>
<_WttsSdkProjectPath>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)ref/WTTS.MicroServices.ClientSDK/src/$(MSBuildProjectName)/$(MSBuildProjectName).csproj'))</_WttsSdkProjectPath>
</PropertyGroup>
<ItemGroup Condition="'$(MSBuildProjectFullPath)' == '$(_WttsSdkProjectPath)' AND '$(MSBuildProjectName)' == 'BD.WTTS.MicroServices.ClientSDK'">
<PackageReference Remove="System.Private.Uri;System.Text.RegularExpressions"
Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net10.0'))" />
</ItemGroup>
<!-- The SDK's native resolver and its DTOs must share the source Common formatter types. -->
<PropertyGroup Condition="'$(WttsNativeAot)' == 'true' AND '$(MSBuildProjectFullPath)' == '$(_WttsSdkProjectPath)' AND
('$(MSBuildProjectName)' == 'BD.WTTS.MicroServices.ClientSDK' OR
'$(MSBuildProjectName)' == 'BD.WTTS.MicroServices.Primitives.Models' OR '$(MSBuildProjectName)' == 'BD.WTTS.MicroServices.Primitives.ViewModels' OR
'$(MSBuildProjectName)' == 'BD.WTTS.Primitives.Models' OR '$(MSBuildProjectName)' == 'BD.WTTS.Primitives.ViewModels')">
<_WttsNativeSdkUsesSourceCommon>true</_WttsNativeSdkUsesSourceCommon>
<TargetFrameworks>net11.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition="'$(_WttsNativeSdkUsesSourceCommon)' == 'true'">
<PackageReference Remove="BD.Common;BD.Common.Primitives;BD.Common.ModelValidator" />
<ProjectReference Include="$(MSBuildThisFileDirectory)ref\Common\src\BD.Common\BD.Common.csproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)ref\Common\src\BD.Common.Primitives\BD.Common.Primitives.csproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)ref\Common\src\BD.Common.ModelValidator\BD.Common.ModelValidator.csproj"
Condition="'$(MSBuildProjectName)' == 'BD.WTTS.MicroServices.ClientSDK'" />
</ItemGroup>
<Import Project="$(MSBuildThisFileDirectory)build/native-graphics/StaticGraphics.targets" Condition="'$(MSBuildProjectName)' == 'BD.WTTS.Client.Avalonia.App'" />
<!-- .NET 11 NativeCompile and LinkNative's static-graphics hook have already run.
Change the final copy metadata before the SDK checks duplicate destinations. -->
<Target Name="WttsPlaceWindowsNativeDependencies" AfterTargets="ComputeFilesToPublish"
BeforeTargets="_HandleFileConflictsForPublish"
Condition="'$(WttsNativeAot)' == 'true' AND '$(PublishAot)' == 'true' AND $(RuntimeIdentifier.StartsWith('win-')) AND ('$(MSBuildProjectName)' == 'BD.WTTS.Client.Avalonia.App' OR '$(MSBuildProjectName)' == 'BD.WTTS.Client.Plugins.Accelerator.ReverseProxy')">
<ItemGroup>
<!-- Steamworks and the optional XunYou SDK arrive as project content, not RID assets. -->
<ResolvedFileToPublish Condition="'%(ResolvedFileToPublish.Extension)' == '.dll' AND '%(ResolvedFileToPublish.PostprocessAssembly)' != 'true' AND ('%(ResolvedFileToPublish.AssetType)' == 'native' OR ('%(ResolvedFileToPublish.AssetType)' == '' AND ('%(ResolvedFileToPublish.RelativePath)' == 'steam_api64.dll' OR '%(ResolvedFileToPublish.RelativePath)' == 'xunyoucall64.dll')))">
<RelativePath>native/$(RuntimeIdentifier)/%(ResolvedFileToPublish.Filename)%(ResolvedFileToPublish.Extension)</RelativePath>
</ResolvedFileToPublish>
</ItemGroup>
</Target>
</Project>