Skip to content

Commit 6be0904

Browse files
committed
Add support for .NET 9
1 parent 51743df commit 6be0904

File tree

5 files changed

+96
-3
lines changed

5 files changed

+96
-3
lines changed

‎.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
**/.*.swp
33
**/.DS_Store
44
**/auto/
5+
**/bin/
6+
**/obj/
57
docs/
68
/tdlib/
79
vcpkg/
810
.clang-tidy
11+
.vs
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
4+
<TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
5+
<Nullable>enable</Nullable>
6+
<UseUwp>true</UseUwp>
7+
<Platforms>AnyCPU</Platforms>
8+
<EnableXamlCompilerTargetsForUwpApps>false</EnableXamlCompilerTargetsForUwpApps>
9+
<EnableDefaultItems>false</EnableDefaultItems>
10+
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
11+
<IsTrimmable>true</IsTrimmable>
12+
<BaseOutputPath>build-uwp\bin\</BaseOutputPath>
13+
<BaseIntermediateOutputPath>build-uwp\obj\</BaseIntermediateOutputPath>
14+
</PropertyGroup>
15+
16+
<PropertyGroup>
17+
<CSWinRTIncludes>
18+
Telegram.Td;
19+
</CSWinRTIncludes>
20+
<CSWinRTWindowsMetadata>local</CSWinRTWindowsMetadata>
21+
<CsWinRTGenerateProjection>true</CsWinRTGenerateProjection>
22+
</PropertyGroup>
23+
24+
<ItemGroup>
25+
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.2.0" />
26+
</ItemGroup>
27+
28+
<ItemGroup>
29+
<Reference Include="Telegram.Td">
30+
<HintPath>$(ProjectDir)build-uwp\nupkg\lib\uap10.0\Telegram.Td.winmd</HintPath>
31+
</Reference>
32+
</ItemGroup>
33+
</Project>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
4+
<!-- Set the platform from the RID, first -->
5+
<PropertyGroup>
6+
<TelegramTdPlatform Condition="$(RuntimeIdentifier.EndsWith('-x64'))">x64</TelegramTdPlatform>
7+
<TelegramTdPlatform Condition="$(RuntimeIdentifier.EndsWith('-x86'))">x86</TelegramTdPlatform>
8+
<TelegramTdPlatform Condition="$(RuntimeIdentifier.EndsWith('-arm64'))">arm64</TelegramTdPlatform>
9+
<TelegramTdPlatform Condition="$(RuntimeIdentifier.EndsWith('-arm'))">arm</TelegramTdPlatform>
10+
<OpenSSLPlatform Condition="$(RuntimeIdentifier.EndsWith('-x64'))">-x64</OpenSSLPlatform>
11+
<OpenSSLPlatform Condition="$(RuntimeIdentifier.EndsWith('-x86'))"></OpenSSLPlatform>
12+
<OpenSSLPlatform Condition="$(RuntimeIdentifier.EndsWith('-arm64'))">-arm64</OpenSSLPlatform>
13+
<OpenSSLPlatform Condition="$(RuntimeIdentifier.EndsWith('-arm'))">-arm</OpenSSLPlatform>
14+
</PropertyGroup>
15+
16+
<!-- If still empty, try to set the platform based on the build platform -->
17+
<PropertyGroup Condition="'$(TelegramTdPlatform)' == ''">
18+
<TelegramTdPlatform Condition="'$(Platform)' == 'Win32'">x86</TelegramTdPlatform>
19+
<TelegramTdPlatform Condition="'$(Platform)' != 'Win32'">$(Platform)</TelegramTdPlatform>
20+
<OpenSSLPlatform Condition="'$(Platform)' == 'Win32'"></OpenSSLPlatform>
21+
<OpenSSLPlatform Condition="'$(Platform)' != 'Win32'">-$(Platform)</OpenSSLPlatform>
22+
</PropertyGroup>
23+
24+
<!-- Register the Telegram.Td .winmd in the APPX manifest (requires the new MSIX tooling) -->
25+
<ItemGroup>
26+
<WindowsMetadataReference Include="$(MSBuildThisFileDirectory)..\..\lib\uap10.0\Telegram.Td.winmd" Implementation="Telegram.Td.dll" />
27+
<ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(TelegramTdPlatform)\native\Telegram.Td.dll" />
28+
<ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(TelegramTdPlatform)\native\libcrypto-3$(OpenSSLPlatform).dll" />
29+
<ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(TelegramTdPlatform)\native\libssl-3$(OpenSSLPlatform).dll" />
30+
<ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(TelegramTdPlatform)\native\zlib1.dll" />
31+
</ItemGroup>
32+
33+
</Project>

‎example/uwp/Telegram.Td.UWP.nuspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<description>TDLib for Universal Windows Platform</description>
1414
<copyright>© Telegram FZ-LLC. All rights reserved.</copyright>
1515
<dependencies>
16+
<group targetFramework="net9.0-windows10.0.26100.0" />
1617
<group targetFramework="UAP10.0" />
1718
</dependencies>
1819
</metadata>

‎example/uwp/build.ps1

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ param (
55
[string]$mode = "all",
66
[string]$compress = "7z",
77
[switch]$release_only = $false,
8-
[switch]$nupkg = $false
8+
[switch]$nupkg = $false,
9+
[switch]$net9 = $false
910
)
1011
$ErrorActionPreference = "Stop"
1112

@@ -14,7 +15,7 @@ $vcpkg_root = Resolve-Path $vcpkg_root
1415
$vcpkg_cmake="${vcpkg_root}\scripts\buildsystems\vcpkg.cmake"
1516
$arch_list = $arch
1617
$config_list = @( "Debug", "Release" )
17-
if ($release_only -or $nupkg) {
18+
if ($release_only -or $nupkg -or $net9) {
1819
$config_list = @(, "RelWithDebInfo")
1920
}
2021
$targets = @{ Debug = "Debug"; Release = "Retail"; RelWithDebInfo = "CommonConfiguration"}
@@ -119,13 +120,35 @@ function export-vsix {
119120
cd ..
120121
}
121122

123+
function build-projection {
124+
dotnet build ../Telegram.Td.Interop.csproj -c Release
125+
if ($LASTEXITCODE -ne 0) {
126+
throw "Build for projection failed with exit code $LASTEXITCODE"
127+
}
128+
129+
New-Item -ItemType Directory -Force -Path nupkg/build/net9.0-windows10.0.26100.0
130+
New-Item -ItemType Directory -Force -Path nupkg/buildTransitive/net9.0-windows10.0.26100.0
131+
cp ../Telegram.Td.UWP.net9.targets nupkg/build/net9.0-windows10.0.26100.0/Telegram.Td.UWP.targets
132+
cp ../Telegram.Td.UWP.net9.targets nupkg/buildTransitive/net9.0-windows10.0.26100.0/Telegram.Td.UWP.targets
133+
134+
New-Item -ItemType Directory -Force -Path nupkg/lib/net9.0-windows10.0.26100.0
135+
cp ../build-uwp/bin/Release/net9.0-windows10.0.26100.0/* -include "Telegram.Td.Interop.dll","Telegram.Td.Interop.pdb" nupkg/lib/net9.0-windows10.0.26100.0
136+
}
137+
122138
function export-nupkg {
123139
cd build-uwp
124140
Remove-Item nupkg -Force -Recurse -ErrorAction SilentlyContinue
141+
142+
if ($net9) {
143+
build-projection
144+
}
145+
125146
New-Item -ItemType Directory -Force -Path nupkg/build/native
147+
New-Item -ItemType Directory -Force -Path nupkg/build/uap10.0
126148
cp ../LICENSE_1_0.txt nupkg
127149
cp ../Telegram.Td.UWP.nuspec nupkg
128150
cp ../Telegram.Td.UWP.targets nupkg/build/native
151+
cp ../Telegram.Td.UWP.targets nupkg/build/uap10.0
129152

130153
ForEach ($arch in $arch_list) {
131154
$fixed_arch = $arch.ToLower();
@@ -159,7 +182,7 @@ function run {
159182
build
160183
}
161184
if (($mode -eq "export") -or ($mode -eq "all")) {
162-
if ($nupkg) {
185+
if ($nupkg -or $net9) {
163186
export-nupkg
164187
} else {
165188
export-vsix

0 commit comments

Comments
 (0)