The build is done in Visual Studio 2022 with 10.0.22000.0 SDK version.
Choose an empty folder for the future build, for example D:\TBuild. It will be named BuildPath in the rest of this document. Create two folders there, *BuildPath*\ThirdParty and *BuildPath*\Libraries.
All commands (if not stated otherwise) will be launched from x86 Native Tools Command Prompt for VS 2022.bat (should be in Start Menu > Visual Studio 2022 menu folder). Pay attention not to use any other Command Prompt.
You will require api_id and api_hash to access the Telegram API servers. To learn how to obtain them click here.
Open x86 Native Tools Command Prompt for VS 2022.bat, go to BuildPath and run
git clone --recursive https://github.com/telegramdesktop/tdesktop.git
tdesktop\Telegram\build\prepare\win.bat
Go to *BuildPath*\tdesktop\Telegram and run (using your api_id and api_hash)
configure.bat -D TDESKTOP_API_ID=YOUR_API_ID -D TDESKTOP_API_HASH=YOUR_API_HASH
For better debugging you may want to install Qt Visual Studio Tools: