Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
**/.*.swp
**/.DS_Store
**/auto/
**/bin/
**/obj/
docs/
/tdlib/
vcpkg/
.clang-tidy
.vs
29 changes: 29 additions & 0 deletions example/uwp/Telegram.Td.Interop.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
<TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
<Nullable>enable</Nullable>
<Platforms>AnyCPU</Platforms>
<EnableDefaultItems>false</EnableDefaultItems>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>

<PropertyGroup>
<CSWinRTIncludes>
Telegram.Td;
</CSWinRTIncludes>
<CSWinRTWindowsMetadata>local</CSWinRTWindowsMetadata>
<CsWinRTGenerateProjection>true</CsWinRTGenerateProjection>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.2.0" />
</ItemGroup>

<ItemGroup>
<Reference Include="Telegram.Td">
<HintPath>$(MSBuildThisFileDirectory)build-uwp\nupkg\lib\uap10.0\Telegram.Td.winmd</HintPath>
</Reference>
</ItemGroup>
</Project>
35 changes: 35 additions & 0 deletions example/uwp/Telegram.Td.UWP.net9.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- Set the platform from the RID, first -->
<PropertyGroup>
<TelegramTdPlatform Condition="$(RuntimeIdentifier.EndsWith('-x64'))">x64</TelegramTdPlatform>
<TelegramTdPlatform Condition="$(RuntimeIdentifier.EndsWith('-x86'))">x86</TelegramTdPlatform>
<TelegramTdPlatform Condition="$(RuntimeIdentifier.EndsWith('-arm64'))">arm64</TelegramTdPlatform>
<TelegramTdPlatform Condition="$(RuntimeIdentifier.EndsWith('-arm'))">arm</TelegramTdPlatform>
<OpenSSLPlatform Condition="$(RuntimeIdentifier.EndsWith('-x64'))">-x64</OpenSSLPlatform>
<OpenSSLPlatform Condition="$(RuntimeIdentifier.EndsWith('-x86'))"></OpenSSLPlatform>
<OpenSSLPlatform Condition="$(RuntimeIdentifier.EndsWith('-arm64'))">-arm64</OpenSSLPlatform>
<OpenSSLPlatform Condition="$(RuntimeIdentifier.EndsWith('-arm'))">-arm</OpenSSLPlatform>
</PropertyGroup>

<!-- If still empty, try to set the platform based on the build platform -->
<PropertyGroup Condition="'$(TelegramTdPlatform)' == ''">
<TelegramTdPlatform Condition="'$(Platform)' == 'Win32'">x86</TelegramTdPlatform>
<TelegramTdPlatform Condition="'$(Platform)' != 'Win32'">$(Platform)</TelegramTdPlatform>
<OpenSSLPlatform Condition="'$(Platform)' == 'Win32'"></OpenSSLPlatform>
<OpenSSLPlatform Condition="'$(Platform)' != 'Win32'">-$(Platform)</OpenSSLPlatform>
</PropertyGroup>

<!-- Register the Telegram.Td .winmd in the APPX manifest (requires the new MSIX tooling) -->
<ItemGroup>
<WindowsMetadataReference Include="$(MSBuildThisFileDirectory)..\..\lib\uap10.0\Telegram.Td.winmd" Implementation="Telegram.Td.dll" />
<ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(TelegramTdPlatform)\native\Telegram.Td.dll" />
<ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(TelegramTdPlatform)\native\libcrypto-3$(OpenSSLPlatform).dll" />
<ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(TelegramTdPlatform)\native\libssl-3$(OpenSSLPlatform).dll" />
<ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(TelegramTdPlatform)\native\zlib1.dll" />

<CsWinRTInputs Include="$(MSBuildThisFileDirectory)..\..\lib\uap10.0\Telegram.Td.winmd" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions example/uwp/Telegram.Td.UWP.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<description>TDLib for Universal Windows Platform</description>
<copyright>© Telegram FZ-LLC. All rights reserved.</copyright>
<dependencies>
<group targetFramework="net9.0-windows10.0.26100.0" />
<group targetFramework="UAP10.0" />
</dependencies>
</metadata>
Expand Down
29 changes: 26 additions & 3 deletions example/uwp/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ param (
[string]$mode = "all",
[string]$compress = "7z",
[switch]$release_only = $false,
[switch]$nupkg = $false
[switch]$nupkg = $false,
[switch]$net9 = $false
)
$ErrorActionPreference = "Stop"

Expand All @@ -14,7 +15,7 @@ $vcpkg_root = Resolve-Path $vcpkg_root
$vcpkg_cmake="${vcpkg_root}\scripts\buildsystems\vcpkg.cmake"
$arch_list = $arch
$config_list = @( "Debug", "Release" )
if ($release_only -or $nupkg) {
if ($release_only -or $nupkg -or $net9) {
$config_list = @(, "RelWithDebInfo")
}
$targets = @{ Debug = "Debug"; Release = "Retail"; RelWithDebInfo = "CommonConfiguration"}
Expand Down Expand Up @@ -119,13 +120,35 @@ function export-vsix {
cd ..
}

function build-projection {
dotnet build ../Telegram.Td.Interop.csproj -c Release
if ($LASTEXITCODE -ne 0) {
throw "Build for projection failed with exit code $LASTEXITCODE"
}

New-Item -ItemType Directory -Force -Path nupkg/build/net9.0-windows10.0.26100.0
New-Item -ItemType Directory -Force -Path nupkg/buildTransitive/net9.0-windows10.0.26100.0
cp ../Telegram.Td.UWP.net9.targets nupkg/build/net9.0-windows10.0.26100.0/Telegram.Td.UWP.targets
cp ../Telegram.Td.UWP.net9.targets nupkg/buildTransitive/net9.0-windows10.0.26100.0/Telegram.Td.UWP.targets

New-Item -ItemType Directory -Force -Path nupkg/lib/net9.0-windows10.0.26100.0
cp ../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
}

function export-nupkg {
cd build-uwp
Remove-Item nupkg -Force -Recurse -ErrorAction SilentlyContinue

if ($net9) {
build-projection
}

New-Item -ItemType Directory -Force -Path nupkg/build/native
New-Item -ItemType Directory -Force -Path nupkg/build/uap10.0
cp ../LICENSE_1_0.txt nupkg
cp ../Telegram.Td.UWP.nuspec nupkg
cp ../Telegram.Td.UWP.targets nupkg/build/native
cp ../Telegram.Td.UWP.targets nupkg/build/uap10.0

ForEach ($arch in $arch_list) {
$fixed_arch = $arch.ToLower();
Expand Down Expand Up @@ -159,7 +182,7 @@ function run {
build
}
if (($mode -eq "export") -or ($mode -eq "all")) {
if ($nupkg) {
if ($nupkg -or $net9) {
export-nupkg
} else {
export-vsix
Expand Down