Compare commits

...
Author SHA1 Message Date
Matthieu GallienandClaude Opus 5.5 0d02504352 feat(msi): keep the installation scope of a previous per-user installation
FindRelatedProducts only finds the related products installed in the
current scope: without this, upgrading a per-user installation would
run as a new per-machine installation next to it.

A per-user installation stores its folder in HKCU (version information,
see HKMU). When it is found, switch to the per-user scope
(MSIINSTALLPERUSER=1) and reuse its folder. FindRelatedProducts is moved
after AppSearch, so that it runs in the right scope; it also hides the
installation scope page, as for per-machine upgrades.

This also makes the updater (msiexec /i without properties) upgrade
per-user installations in place.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Matthieu Gallien <[email protected]>
2026-11-06 17:42:00 +01:00
Matthieu GallienandClaude Opus 5.5 fdded4597f feat(msi): show the installation scope page in the wizard
Insert NcInstallScopeDlg between the welcome page and the feature
selection page.

Leaving the page applies the chosen scope:
- per-machine: ALLUSERS=1, installation folder in Program Files (or the
  folder of a previous per-machine installation)
- per-user: ALLUSERS=2 and MSIINSTALLPERUSER=1, installation folder in
  %LOCALAPPDATA%\Programs

The page is only shown for a new installation, when the scope was not
requested on the command line (MSIINSTALLPERUSER=1) and no previous MSI or
NSIS installation was found. Silent installations are unchanged and still
install per-machine by default.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Matthieu Gallien <[email protected]>
2026-11-06 17:40:12 +01:00
Matthieu GallienandClaude Opus 5.5 8f1f38239b feat(msi): add a wizard page to choose the installation scope
Add NcInstallScopeDlg, a wizard page offering a per-user ("just for you")
or a per-machine ("all users of this machine") installation, stored in
the NC_INSTALL_SCOPE property (per-machine by default).

The page reuses the strings of the WiX InstallScopeDlg, which are already
translated for all the cultures the installer is built for.

The page is not part of the wizard yet.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Matthieu Gallien <[email protected]>
2026-11-06 17:37:43 +01:00
Matthieu GallienandClaude Opus 5.5 b82199f8bb fix(msi): write registry entries matching the installation scope
A per-user installation cannot write to HKLM (error 1406).

- version information and URI handler use HKMU, i.e. HKLM for
  per-machine and HKCU for per-user installations
- skipUpdateCheck is only read by the client from HKLM, so it is only
  written for per-machine installations
- overlay icons need HKLM ShellIconOverlayIdentifiers, so they are only
  installed for per-machine installations

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Matthieu Gallien <[email protected]>
2026-11-06 17:33:12 +01:00
Matthieu GallienandClaude Opus 5.5 fb385ef8a7 fix(msi): keep per-machine install folder and ACLs out of per-user installs
The previous installation folder is read from HKLM and was applied to
every installation, overriding the per-user default folder (and the
command line) with the Program Files path of a per-machine installation.
Only use it for per-machine installations.

EnsureACL removes inherited permissions and leaves users with read and
execute rights only, which would prevent a per-user installation from
being upgraded or removed: only run it for per-machine installations.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Matthieu Gallien <[email protected]>
2026-11-06 17:33:11 +01:00
Matthieu GallienandClaude Opus 5.5 6208d2521f feat(msi): make the MSI package installable per-user
Turn the package into a dual-purpose package: drop InstallScope=perMachine
and set ALLUSERS=2, so that Windows Installer picks the installation
context from MSIINSTALLPERUSER. Without it the package still installs
per-machine, as before; MSIINSTALLPERUSER=1 installs it for the current
user only. MSIINSTALLPERUSER requires Windows Installer 5.0.

Also add a PerUserInstall condition to be used by the next changes.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Matthieu Gallien <[email protected]>
2026-11-06 17:33:10 +01:00
Matthieu GallienandClaude Sonnet 5 1434c737c2 feat(windows): sync admin/win/scripts with upstream client-building
Port the optional second/dual code-signing certificate support added
upstream in nextcloud/client-building (PR #159, commit 28b6ceb) after
the scripts were migrated into admin/win/scripts at commit 1082118.
Adds USE_SECOND_CODE_SIGNING and the SECOND_CERTIFICATE_*/SECOND_SIGN_*
variables, appending a second signature via `signtool sign /as`.

Signed-off-by: Matthieu Gallien <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-11-06 13:50:20 +01:00
copilot-swe-agent[bot] e74cfb47a2 feat: migrate Windows build scripts from client-building into admin/win/scripts
Agent-Logs-Url: https://github.com/nextcloud/desktop/sessions/977d4996-08e2-4615-9395-f3f2de506a7a

Signed-off-by: Matthieu Gallien <[email protected]>
2026-11-06 13:50:19 +01:00
22 changed files with 1826 additions and 17 deletions

No files matched your search

+1
View File
@@ -32,6 +32,7 @@ install(FILES
Nextcloud.wxs
${CMAKE_CURRENT_BINARY_DIR}/RegistryCleanup.vbs
RegistryCleanupCustomAction.wxs
InstallScopeDlg.wxs
gui/banner.bmp
gui/dialog.bmp
DESTINATION msi/)
+44
View File
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: GPL-2.0-or-later
-->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<!--
Wizard page to choose between a per-machine and a per-user installation.
The texts are the ones of the WiX InstallScopeDlg (WixUIExtension), which are already
translated for all the cultures of the installer.
The choice is stored in NC_INSTALL_SCOPE ("perMachine" or "perUser"). When to show the page
and the properties set when leaving it are defined in the <UI> element of Nextcloud.wxs.
-->
<Property Id="NC_INSTALL_SCOPE" Value="perMachine" />
<UI>
<Dialog Id="NcInstallScopeDlg" Width="370" Height="270" Title="!(loc.InstallScopeDlg_Title)" KeepModeless="yes">
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallScopeDlgBannerBitmap)" />
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="!(loc.InstallScopeDlgTitle)" />
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="!(loc.InstallScopeDlgDescription)" />
<Control Id="Scope" Type="RadioButtonGroup" X="20" Y="55" Width="330" Height="120" Property="NC_INSTALL_SCOPE">
<RadioButtonGroup Property="NC_INSTALL_SCOPE">
<RadioButton Value="perUser" X="0" Y="0" Width="295" Height="16" Text="!(loc.InstallScopeDlgPerUser)" />
<RadioButton Value="perMachine" X="0" Y="60" Width="295" Height="16" Text="!(loc.InstallScopeDlgPerMachine)" />
</RadioButtonGroup>
</Control>
<Control Id="PerUserDescription" Type="Text" X="33" Y="70" Width="300" Height="36" NoPrefix="yes" Text="!(loc.InstallScopeDlgPerUserDescription)" />
<Control Id="PerMachineDescription" Type="Text" X="33" Y="131" Width="300" Height="36" NoPrefix="yes" Text="!(loc.InstallScopeDlgPerMachineDescription)" />
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)" />
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
</Dialog>
</UI>
</Fragment>
</Wix>
+98 -15
View File
@@ -21,7 +21,28 @@
UpgradeCode="$(var.UpgradeCode)"
Language="1033" Codepage="$(var.codepage)" Version="$(var.VerFull)">
<Package Id="*" Keywords="Installer" Description="$(var.AppName) $(var.VerDesc)" Manufacturer="$(var.AppVendor)"
InstallerVersion="300" Platform="$(var.Platform)" Languages="1033" Compressed="yes" SummaryCodepage="$(var.codepage)" InstallScope="perMachine" />
InstallerVersion="500" Platform="$(var.Platform)" Languages="1033" Compressed="yes" SummaryCodepage="$(var.codepage)" />
<!--
Dual-purpose package (per-machine or per-user), see:
https://learn.microsoft.com/en-us/windows/win32/msi/single-package-authoring
ALLUSERS=2 lets Windows Installer pick the context from MSIINSTALLPERUSER:
- MSIINSTALLPERUSER unset (default): per-machine installation, same behaviour as before
- MSIINSTALLPERUSER=1: per-user installation
MSIINSTALLPERUSER is only honoured by Windows Installer 5.0+ (Windows 7 and later),
hence InstallerVersion="500" above.
Administrators can still force a per-machine installation with ALLUSERS=1.
-->
<Property Id="ALLUSERS" Value="2" />
<!--
Condition that is true for a per-user installation:
- ALLUSERS empty: per-user context (this is how Windows Installer reports it once the context is resolved)
- ALLUSERS=2 and MSIINSTALLPERUSER=1: per-user context requested, not yet resolved
-->
<?define PerUserInstall = "(NOT ALLUSERS OR (ALLUSERS=2 AND MSIINSTALLPERUSER=1))" ?>
<!--
Upgrading: Since we always want to allow up-/downgrade, we don't specify a maximum version, thus
@@ -40,10 +61,33 @@
<Media Id="1" Cabinet="$(var.AppShortName).cab" EmbedCab="yes" />
<!-- If already installed: Use previously chosen path (use 32-bit registry like NSIS does) -->
<Property Id="INSTALLDIR">
<!--
If already installed: Use previously chosen path (use 32-bit registry like NSIS does)
The path is stored in HKLM, so it only applies to per-machine installations: a per-user
installation must not pick up the Program Files folder of a (previous) per-machine one.
-->
<Property Id="NC_PERMACHINE_INSTALLDIR" Secure="yes">
<RegistrySearch Id="RegistryInstallDir" Type="raw" Root="HKLM" Key="Software\$(var.AppVendor)\$(var.AppName)" Win64="no" />
</Property>
<SetProperty Id="INSTALLDIR" Value="[NC_PERMACHINE_INSTALLDIR]" After="FindRelatedProducts" Sequence="both">NC_PERMACHINE_INSTALLDIR AND NOT $(var.PerUserInstall)</SetProperty>
<!--
Previous per-user installation: its path is stored in HKCU (see RegistryVersionInfo, HKMU).
An upgrade keeps the per-user scope: MSIINSTALLPERUSER must be set before FindRelatedProducts,
which only finds the related products installed in the current scope, so FindRelatedProducts
is moved after AppSearch (it runs before it by default).
-->
<Property Id="NC_PERUSER_INSTALLDIR" Secure="yes">
<RegistrySearch Id="RegistryPerUserInstallDir" Type="raw" Root="HKCU" Key="Software\$(var.AppVendor)\$(var.AppName)" Win64="no" />
</Property>
<SetProperty Action="SetPerUserScopeFromPreviousInstall" Id="MSIINSTALLPERUSER" Value="1" After="AppSearch" Sequence="both">NC_PERUSER_INSTALLDIR AND NOT NSIS_UNINSTALLEXE</SetProperty>
<SetProperty Action="SetPerUserInstallDir" Id="INSTALLDIR" Value="[NC_PERUSER_INSTALLDIR]" After="FindRelatedProducts" Sequence="both">NC_PERUSER_INSTALLDIR AND $(var.PerUserInstall)</SetProperty>
<InstallUISequence>
<FindRelatedProducts After="SetPerUserScopeFromPreviousInstall" />
</InstallUISequence>
<InstallExecuteSequence>
<FindRelatedProducts After="SetPerUserScopeFromPreviousInstall" />
</InstallExecuteSequence>
<!-- Detect legacy NSIS installation -->
<Property Id="NSIS_UNINSTALLEXE">
@@ -52,6 +96,15 @@
</RegistrySearch>
</Property>
<!--
Installation scope wizard page (NcInstallScopeDlg, see InstallScopeDlg.wxs): only shown for a new installation
when the scope was not requested on the command line (MSIINSTALLPERUSER=1) and no previous installation
(MSI or legacy NSIS) was found, an upgrade keeps the scope of the installed version.
-->
<SetProperty Id="NC_SHOW_INSTALL_SCOPE_DLG" Value="1" After="FindRelatedProducts" Sequence="ui">NOT Installed AND NOT MSIINSTALLPERUSER AND NOT WIX_UPGRADE_DETECTED AND NOT NSIS_UNINSTALLEXE</SetProperty>
<!-- Remember the per-machine installation folder, to restore it when going back from per-user to per-machine -->
<SetProperty Id="NC_PERMACHINE_DEFAULTDIR" Value="[INSTALLDIR]" After="CostFinalize" Sequence="ui">NC_SHOW_INSTALL_SCOPE_DLG</SetProperty>
<!-- Property to disable update checks -->
<Property Id="SKIPAUTOUPDATE" Value="0" />
@@ -71,8 +124,8 @@
<!-- Install: Remove previous NSIS installation, if detected -->
<Custom Action="ExecNsisUninstaller" Before="ProcessComponents">NSIS_UNINSTALLEXE AND NOT Installed</Custom>
<!-- Install: Ensure ACLs are set -->
<Custom Action="EnsureACL" After="InstallFiles">NOT Installed</Custom>
<!-- Install: Ensure ACLs are set (per-machine only: a per-user installation must stay writable by its user) -->
<Custom Action="EnsureACL" After="InstallFiles">NOT Installed AND NOT $(var.PerUserInstall)</Custom>
<!-- Uninstall: Remove sync folders from Explorer's Navigation Pane, only effective for the current user (home users) -->
<Custom Action="RemoveNavigationPaneEntries" After="RemoveFiles">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
@@ -118,10 +171,33 @@
<UIRef Id="WixUI_FeatureTree" />
<UIRef Id="WixUI_ErrorProgressText" />
<!-- Skip the license page -->
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="CustomizeDlg" Order="3">1</Publish>
<DialogRef Id="NcInstallScopeDlg" />
<!--
Skip the license page, and show the installation scope page when needed
(the last NewDialog event of a control wins: the Order 3 and 4 events replace the WixUI_FeatureTree ones)
-->
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="CustomizeDlg" Order="3">NOT NC_SHOW_INSTALL_SCOPE_DLG</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="NcInstallScopeDlg" Order="4">NC_SHOW_INSTALL_SCOPE_DLG</Publish>
<!-- Skip the page on the way back too -->
<Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="3">1</Publish>
<Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="3">NOT NC_SHOW_INSTALL_SCOPE_DLG</Publish>
<Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="NcInstallScopeDlg" Order="4">NC_SHOW_INSTALL_SCOPE_DLG</Publish>
<!--
Installation scope page: apply the chosen scope
- per-machine: ALLUSERS=1, installed in Program Files (or the folder of a previous per-machine installation)
- per-user: ALLUSERS=2 + MSIINSTALLPERUSER=1, installed in %LOCALAPPDATA%\Programs
The installation folder has already been resolved (CostFinalize), so it is changed with SetTargetPath.
-->
<Publish Dialog="NcInstallScopeDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
<Publish Dialog="NcInstallScopeDlg" Control="Next" Property="ALLUSERS" Value="1" Order="1">NC_INSTALL_SCOPE = "perMachine"</Publish>
<Publish Dialog="NcInstallScopeDlg" Control="Next" Property="MSIINSTALLPERUSER" Value="{}" Order="2">NC_INSTALL_SCOPE = "perMachine"</Publish>
<Publish Dialog="NcInstallScopeDlg" Control="Next" Property="INSTALLDIR" Value="[NC_PERMACHINE_DEFAULTDIR]" Order="3">NC_INSTALL_SCOPE = "perMachine"</Publish>
<Publish Dialog="NcInstallScopeDlg" Control="Next" Property="ALLUSERS" Value="2" Order="4">NC_INSTALL_SCOPE = "perUser"</Publish>
<Publish Dialog="NcInstallScopeDlg" Control="Next" Property="MSIINSTALLPERUSER" Value="1" Order="5">NC_INSTALL_SCOPE = "perUser"</Publish>
<Publish Dialog="NcInstallScopeDlg" Control="Next" Property="INSTALLDIR" Value="[LocalAppDataFolder]Programs\$(var.AppName)\" Order="6">NC_INSTALL_SCOPE = "perUser"</Publish>
<Publish Dialog="NcInstallScopeDlg" Control="Next" Event="SetTargetPath" Value="INSTALLDIR" Order="7">1</Publish>
<Publish Dialog="NcInstallScopeDlg" Control="Next" Event="NewDialog" Value="CustomizeDlg" Order="8">1</Publish>
<!-- https://wixtoolset.org/documentation/manual/v3/howtos/ui_and_localization/run_program_after_install.html -->
<Publish Dialog="ExitDialog"
@@ -167,9 +243,12 @@
</Directory>
<DirectoryRef Id="TARGETDIR">
<!-- Version numbers used to detect existing installation (use 32-bit registry like NSIS does) -->
<!--
Version numbers used to detect existing installation (use 32-bit registry like NSIS does)
HKMU = HKLM for per-machine installations, HKCU for per-user installations
-->
<Component Id="RegistryVersionInfo" Guid="*" Win64="no">
<RegistryKey Root="HKLM" Key="Software\$(var.AppVendor)\$(var.AppName)" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
<RegistryKey Root="HKMU" Key="Software\$(var.AppVendor)\$(var.AppName)" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
<RegistryValue Type="string" Value="[INSTALLDIR]" />
<RegistryValue Type="integer" Name="VersionMajor" Value="$(var.VerMajor)" />
<RegistryValue Type="integer" Name="VersionMinor" Value="$(var.VerMinor)" />
@@ -181,23 +260,27 @@
</RegistryKey>
</Component>
<!-- Platform bitness-dependent settings -->
<!--
Platform bitness-dependent settings
The client only reads these device defaults from HKLM, so they are only written for per-machine installations.
-->
<Component Id="RegistryDefaultSettings" Guid="*" Win64="$(var.PlatformWin64)">
<Condition>NOT $(var.PerUserInstall)</Condition>
<RegistryKey Root="HKLM" Key="Software\$(var.AppVendor)\$(var.AppName)">
<!-- Property to disable update checks -->
<RegistryValue Type="integer" Name="skipUpdateCheck" Value="[SKIPAUTOUPDATE]" />
</RegistryKey>
</Component>
<!-- Register URI handler -->
<!-- Register URI handler (HKMU: machine-wide or current user only, following the installation scope) -->
<Component Id="RegistryUriHandler" Guid="*" Win64="$(var.PlatformWin64)">
<RegistryKey Root="HKLM" Key="Software\Classes\$(var.AppCommandOpenUrlScheme)" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
<RegistryKey Root="HKMU" Key="Software\Classes\$(var.AppCommandOpenUrlScheme)" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
<RegistryValue Type="string" Value="URL:$(var.AppName) Protocol" />
<RegistryValue Type="string" Name="URL Protocol" Value="" />
</RegistryKey>
<RegistryKey Root="HKLM" Key="Software\Classes\$(var.AppCommandOpenUrlScheme)\DefaultIcon" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
<RegistryKey Root="HKMU" Key="Software\Classes\$(var.AppCommandOpenUrlScheme)\DefaultIcon" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
<RegistryValue Type="string" Value="[INSTALLDIR]$(var.AppExe)" />
</RegistryKey>
<RegistryKey Root="HKLM" Key="Software\Classes\$(var.AppCommandOpenUrlScheme)\shell\open\command" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
<RegistryKey Root="HKMU" Key="Software\Classes\$(var.AppCommandOpenUrlScheme)\shell\open\command" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
<RegistryValue Type="string" Value="&quot;[INSTALLDIR]$(var.AppExe)&quot; &quot;%1&quot;" />
</RegistryKey>
</Component>
+2 -2
View File
@@ -107,7 +107,7 @@ exit 0
set codepage=%~1
echo :: Compiling MSI project for codepage !codepage!
"%WIX%\bin\candle.exe" -dcodepage=!codepage! -dProductCode=%PRODUCTCODE% -dPlatform=%BuildArch% -arch %BuildArch% -dHarvestAppDir="%HarvestAppDir%" -ext WixUtilExtension NCMsiHelper.wxs WinShellExt.wxs collect.wxs Nextcloud.wxs RegistryCleanupCustomAction.wxs
"%WIX%\bin\candle.exe" -dcodepage=!codepage! -dProductCode=%PRODUCTCODE% -dPlatform=%BuildArch% -arch %BuildArch% -dHarvestAppDir="%HarvestAppDir%" -ext WixUtilExtension NCMsiHelper.wxs WinShellExt.wxs collect.wxs Nextcloud.wxs RegistryCleanupCustomAction.wxs InstallScopeDlg.wxs
if %ERRORLEVEL% neq 0 exit %ERRORLEVEL%
echo/
@@ -121,7 +121,7 @@ exit 0
set culture=%%c
echo :: Linking MSI project for !culture!
"%WIX%\bin\light.exe" -sw1076 -ext WixUIExtension -ext WixUtilExtension -cultures:!culture!;en-us NCMsiHelper.wixobj WinShellExt.wixobj collect.wixobj Nextcloud.wixobj RegistryCleanupCustomAction.wixobj -out "!culture!_@MSI_INSTALLER_FILENAME@"
"%WIX%\bin\light.exe" -sw1076 -ext WixUIExtension -ext WixUtilExtension -cultures:!culture!;en-us NCMsiHelper.wixobj WinShellExt.wixobj collect.wixobj Nextcloud.wixobj RegistryCleanupCustomAction.wixobj InstallScopeDlg.wixobj -out "!culture!_@MSI_INSTALLER_FILENAME@"
if %ERRORLEVEL% neq 0 exit %ERRORLEVEL%
if NOT "!culture!" == "en-us" (
+6
View File
@@ -0,0 +1,6 @@
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: GPL-2.0-or-later
# Un-ignore batch scripts whose names start with "build" — they are tracked source files,
# not build artefacts, and must not be excluded by the repository-level "build*" rule.
!build*.bat
+243
View File
@@ -0,0 +1,243 @@
<!--
- SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: GPL-2.0-or-later
-->
# Windows Build Scripts
This directory contains Windows batch scripts for building, packaging, signing, and uploading
the Nextcloud Desktop Client on Windows. They were originally maintained in the separate
[nextcloud/client-building](https://github.com/nextcloud/client-building) repository and have
been moved here so that build tooling lives alongside the source it builds.
> **Note:** NSIS EXE installer creation is **not** supported by these scripts.
> The official Windows installer is the WiX-based MSI (see `admin/win/msi/`).
---
## Prerequisites
- Windows 10 or later (64-bit)
- [KDE Craft](https://community.kde.org/Get_Involved/development/Windows) with all
`nextcloud-client` dependencies installed
- Visual Studio 2022 (Community or higher) with C++ workload
- [WiX Toolset v3](https://wixtoolset.org/releases/) installed and `WIX` environment
variable pointing to its root (e.g. `C:\Program Files (x86)\WiX Toolset v3.14`)
- [Git for Windows](https://git-scm.com/download/win) (provides Git Bash and `mkdir.exe`)
- [png2ico](https://www.winterdrache.de/freeware/png2ico/) placed at
`C:\Nextcloud\tools\png2ico.exe` (or override `Png2Ico_EXECUTABLE`)
For code signing (optional):
- A valid code-signing certificate in PFX format
- Set `CERTIFICATE_FILENAME`, `CERTIFICATE_CSP`, `CERTIFICATE_KEY_CONTAINER_NAME`, and
`CERTIFICATE_PASSWORD` in your environment before running
---
## Quick Start
Open a **Git Bash** shell in the repository root and run:
```bat
cd admin/win/scripts
./build.bat
```
This will, in order:
1. Build the desktop client (`build-desktop.bat`)
2. Collect all runtime libraries and resources (`build-installer-collect.bat`)
3. Build the MSI installer (`build-installer-msi.bat`)
To run without signing or uploading:
```bat
USE_CODE_SIGNING=0 UPLOAD_BUILD=0 ./build.bat Release
```
To do a dry run (validates all required variables without building):
```bat
TEST_RUN=1 ./build.bat
```
### Code signing with a second certificate (dual signing)
- Signed files (the collected exe/dll payload as well as the final MSI) are always signed with
the certificate configured via `CERTIFICATE_FILENAME`, `CERTIFICATE_CSP`,
`CERTIFICATE_KEY_CONTAINER_NAME` and `CERTIFICATE_PASSWORD` whenever `USE_CODE_SIGNING=1`
(default).
- Optionally, a second, independent signature can be appended on top of the first one by
setting `USE_SECOND_CODE_SIGNING=1` and configuring `SECOND_CERTIFICATE_FILENAME`,
`SECOND_CERTIFICATE_CSP`, `SECOND_CERTIFICATE_KEY_CONTAINER_NAME` and
`SECOND_CERTIFICATE_PASSWORD` (same scheme as the first certificate).
`SECOND_SIGN_FILE_DIGEST_ALG`, `SECOND_SIGN_TIMESTAMP_URL` and
`SECOND_SIGN_TIMESTAMP_DIGEST_ALG` mirror the equivalent `SIGN_*` variables for the second
signature.
- `USE_SECOND_CODE_SIGNING` is disabled by default (`0`) and has no effect unless
`USE_CODE_SIGNING=1`, since the second signature is appended (`signtool sign /as`) to the
first one rather than replacing it.
---
## Environment Variables
All variables have sensible defaults defined in `defaults.inc.bat`. You may override any of
them in your shell environment before calling any script.
| Variable | Default | Description |
|---|---|---|
| `DESKTOP_REPO_PATH` | derived from script location | Absolute path to the repository root (auto-detected) |
| `PROJECT_PATH` | `c:/Nextcloud` | Workspace root for build artifacts (`install/`, `collect/`, `daily/`) |
| `BUILD_TYPE` | `RelWithDebInfo` | CMake build type (`Release`, `Debug`, `RelWithDebInfo`) |
| `BUILD_TARGETS` | `Win64` | Comma-separated architectures to build (`Win64`, `Win32`, or both) |
| `CRAFT_PATH` | auto (Craft default) | Path to the KDE Craft root for the target architecture |
| `VS_VERSION` | `2022` | Visual Studio version (`2017`, `2019`, `2022`) |
| `VCINSTALLDIR` | auto from `VS_VERSION` | Path to the Visual C++ installation directory |
| `WIN_GIT_PATH` | `C:\Program Files\Git` | Git for Windows root (provides `mkdir.exe`) |
| `Png2Ico_EXECUTABLE` | `c:/Nextcloud/tools/png2ico.exe` | Path to the png2ico converter |
| `WIX` | `C:/Program Files (x86)/WiX Toolset v3.14` | WiX Toolset installation directory |
| `WIX_SDK_PATH` | `%WIX%/SDK/VS2017` | WiX SDK path used by the NCMsiHelper CMake target |
| `BUILD_INSTALLER_MSI` | `1` | Set to `0` to skip MSI creation |
| `USE_CODE_SIGNING` | `1` | Set to `0` to skip all signing steps |
| `UPLOAD_BUILD` | `1` | Set to `0` to skip the SCP upload step |
| `INSTALLER_OUTPUT_PATH` | `%PROJECT_PATH%/daily/` | Directory where the finished MSI is placed |
| `EXTRA_DEPLOY_PATH` | `%PROJECT_PATH%/deploy-extra/%BUILD_TYPE%/%BUILD_ARCH%` | Optional directory of extra DLLs to bundle |
| `PULL_DESKTOP` | `0` | Set to `1` to clone a fresh copy of the repository before building |
| `CHECKOUT_DESKTOP` | `0` | Set to `1` together with `PULL_DESKTOP=1` to choose a specific tag |
| `TAG_DESKTOP` | `master` | Branch or tag to clone when `CHECKOUT_DESKTOP=1` |
| `CMAKE_EXTRA_FLAGS_DESKTOP` | *(empty)* | Extra CMake flags forwarded to the desktop build |
| `BUILD_UPDATER` | `OFF` | Set to `ON` to build the auto-updater |
For code signing, additionally set:
| Variable | Description |
|---|---|
| `CERTIFICATE_FILENAME` | Path to the PFX certificate file |
| `CERTIFICATE_CSP` | Cryptographic Service Provider name |
| `CERTIFICATE_KEY_CONTAINER_NAME` | Key container name inside the CSP |
| `CERTIFICATE_PASSWORD` | Certificate password |
| `SIGN_FILE_DIGEST_ALG` | Digest algorithm (default: `sha256`) |
| `SIGN_TIMESTAMP_URL` | Timestamp server URL (default: `http://timestamp.digicert.com`) |
| `SIGN_TIMESTAMP_DIGEST_ALG` | Timestamp digest algorithm (default: `sha256`) |
| `APPLICATION_VENDOR` | Vendor string used in the signing description (default: `Nextcloud GmbH`) |
For an optional second (appended) signature, additionally set `USE_SECOND_CODE_SIGNING=1` and:
| Variable | Description |
|---|---|
| `SECOND_CERTIFICATE_FILENAME` | Path to the second PFX certificate file |
| `SECOND_CERTIFICATE_CSP` | Cryptographic Service Provider name for the second certificate |
| `SECOND_CERTIFICATE_KEY_CONTAINER_NAME` | Key container name inside the second CSP |
| `SECOND_CERTIFICATE_PASSWORD` | Second certificate password |
| `SECOND_SIGN_FILE_DIGEST_ALG` | Digest algorithm for the second signature (default: `sha256`) |
| `SECOND_SIGN_TIMESTAMP_URL` | Timestamp server URL for the second signature (default: `http://timestamp.digicert.com`) |
| `SECOND_SIGN_TIMESTAMP_DIGEST_ALG` | Timestamp digest algorithm for the second signature (default: `sha256`) |
For uploading (`UPLOAD_BUILD=1`), additionally set:
| Variable | Description |
|---|---|
| `SFTP_SERVER` | Hostname of the SSH/SCP target server |
| `SFTP_USER` | SSH username |
| `SFTP_PATH` | Remote path on the server |
---
## Script Reference
### Top-level entry points
| Script | Purpose |
|---|---|
| `build.bat` | **Main entry point.** Runs build → collect → MSI in sequence. |
| `task-build-log.bat` | Same as `build.bat` but writes output to a timestamped log file under `%PROJECT_PATH%/logs/`. Suitable for Windows Task Scheduler. |
| `task-build-job.sh` | Thin Git Bash wrapper around `task-build-log.bat` for use in Task Scheduler jobs configured with Git Bash. |
### Per-stage loop wrappers
These iterate over `BUILD_TARGETS` and call the corresponding `single-build-*.bat` helper for
each target architecture.
| Script | Purpose |
|---|---|
| `build-desktop.bat` | Build the desktop client for all configured architectures. |
| `build-installer-collect.bat` | Collect all runtime files for each architecture. |
| `build-installer-msi.bat` | Build and (optionally) sign and upload the MSI for each architecture. |
### Per-architecture implementation scripts
Call these directly when you want to build for a single architecture:
```bat
single-build-desktop.bat <BUILD_TYPE> <BUILD_ARCH>
single-build-installer-collect.bat <BUILD_TYPE> <BUILD_ARCH>
single-build-installer-msi.bat <BUILD_TYPE> <BUILD_ARCH>
```
Example (Release, 64-bit only):
```bat
single-build-desktop.bat Release Win64
single-build-installer-collect.bat Release Win64
single-build-installer-msi.bat Release Win64
```
### Utility scripts
| Script | Purpose |
|---|---|
| `sign.bat <file>` | Sign a single binary with `signtool`. Reads certificate settings from environment. |
| `upload.bat <file>` | Upload a file to the configured SCP server. |
### Include files
| Script | Purpose |
|---|---|
| `defaults.inc.bat` | Sets all default environment variables. Sourced by every script. |
| `common.inc.bat` | Sets architecture-specific variables (`BUILD_ARCH`, `CRAFT_PATH`, `QT_*`). |
| `datetime.inc.bat` | Sets `_date` and `_time` in a locale-independent format. |
| `datetime.inc.callee.sh` | Git Bash helper called by `datetime.inc.bat` to obtain the current date. |
---
## Artifact Layout
After a successful build the following directories are created under `PROJECT_PATH`:
```
install/<BUILD_TYPE>/<BUILD_ARCH>/
bin/ — compiled binaries installed by cmake --target install
msi/ — MSI build helper DLL and WiX scripts (from CMake install)
...
collect/<BUILD_TYPE>/<BUILD_ARCH>/
*.dll — all runtime DLLs needed by the client
*.exe — client executables
...
daily/
Nextcloud-<version>-<arch>.msi — final signed MSI installer
```
---
## Relationship to `admin/win/msi/`
The scripts in this directory are **orchestration wrappers**. The actual WiX source files and
CMake targets that compile the MSI helper DLL (`NCMsiHelper`) and generate `make-msi.bat` live
in `admin/win/msi/` and `admin/win/tools/`. The final MSI build step in
`single-build-installer-msi.bat` calls `make-msi.bat` (placed by CMake install into
`install/<type>/<arch>/msi/`) with the collect directory as input.
---
## What is NOT included
- **NSIS EXE installer creation** — The legacy NSIS installer (`nextcloud.nsi`) and the
wrapper script `build-installer-exe.bat` are not included here. The WiX MSI is the current
official Windows installer format.
- **Dependency bootstrapping** (`init.bat`, `build-qtkeychain.bat`, `build-zlib.bat`) — These
were part of the original standalone `client-building` setup and are now obsolete. All
build-time dependencies are provided by KDE Craft.
+33
View File
@@ -0,0 +1,33 @@
@echo off
REM SPDX-FileCopyrightText: 2019 Michael Schuster
REM SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
REM SPDX-License-Identifier: GPL-2.0-or-later
setlocal EnableDelayedExpansion
Rem ********************************************************************************************
rem "desktop - Build for Windows 64-bit and/or 32-bit"
Rem ********************************************************************************************
call "%~dp0/defaults.inc.bat" %1
Rem ********************************************************************************************
rem Reference: https://ss64.com/nt/setlocal.html
rem Reference: https://ss64.com/nt/start.html
for %%G in (%BUILD_TARGETS%) do (
if "%BUILD_TYPE%" == "Debug" (
set "DLL_SUFFIX=d"
) else (
set "DLL_SUFFIX="
)
echo "**** build desktop for %%G (%~nx0)."
start "single-build-desktop.bat %BUILD_TYPE% %%G" /D "%PROJECT_PATH%/" /B /wait "%~dp0/single-build-desktop.bat" %BUILD_TYPE% %%G
if !ERRORLEVEL! neq 0 exit !ERRORLEVEL!
)
Rem ********************************************************************************************
exit 0
+35
View File
@@ -0,0 +1,35 @@
@echo off
REM SPDX-FileCopyrightText: 2019 Michael Schuster
REM SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
REM SPDX-License-Identifier: GPL-2.0-or-later
setlocal EnableDelayedExpansion
Rem ********************************************************************************************
rem "installer - collect files for Windows 64-bit and/or 32-bit"
Rem ********************************************************************************************
call "%~dp0/defaults.inc.bat" %1
Rem ********************************************************************************************
rem Reference: https://ss64.com/nt/setlocal.html
rem Reference: https://ss64.com/nt/start.html
for %%G in (%BUILD_TARGETS%) do (
if "%BUILD_TYPE%" == "Debug" (
set "DLL_SUFFIX=d"
) else (
set "DLL_SUFFIX="
)
set "EXTRA_DEPLOY_PATH=%PROJECT_PATH%/deploy-extra/%BUILD_TYPE%/%%G"
echo "**** collect installer files for %%G (%~nx0)."
start "single-build-installer-collect.bat %BUILD_TYPE% %%G" /D "%PROJECT_PATH%/" /B /wait "%~dp0/single-build-installer-collect.bat" %BUILD_TYPE% %%G
if !ERRORLEVEL! neq 0 exit !ERRORLEVEL!
)
Rem ********************************************************************************************
exit 0
+33
View File
@@ -0,0 +1,33 @@
@echo off
REM SPDX-FileCopyrightText: 2019 Michael Schuster
REM SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
REM SPDX-License-Identifier: GPL-2.0-or-later
setlocal EnableDelayedExpansion
Rem ********************************************************************************************
rem "MSI installer - build for Windows 64-bit and/or 32-bit"
Rem ********************************************************************************************
call "%~dp0/defaults.inc.bat" %1
Rem ********************************************************************************************
rem Reference: https://ss64.com/nt/setlocal.html
rem Reference: https://ss64.com/nt/start.html
for %%G in (%BUILD_TARGETS%) do (
if "%BUILD_TYPE%" == "Debug" (
set DLL_SUFFIX=d
) else (
set DLL_SUFFIX=
)
echo "**** build MSI installer for %%G (%~nx0)."
start "single-build-installer-msi.bat %BUILD_TYPE% %%G" /D "%PROJECT_PATH%/" /B /wait "%~dp0/single-build-installer-msi.bat" %BUILD_TYPE% %%G
if !ERRORLEVEL! neq 0 exit !ERRORLEVEL!
)
Rem ********************************************************************************************
exit 0
+86
View File
@@ -0,0 +1,86 @@
@echo off
REM SPDX-FileCopyrightText: 2019 Michael Schuster
REM SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
REM SPDX-License-Identifier: GPL-2.0-or-later
setlocal EnableDelayedExpansion
cls
echo "***** Build started. (%~nx0)"
Rem ********************************************************************************************
rem "Build everything"
Rem ********************************************************************************************
call "%~dp0/defaults.inc.bat" %1
Rem ********************************************************************************************
echo "* BUILD_TYPE=%BUILD_TYPE%"
echo "* BUILD_TARGETS=%BUILD_TARGETS%"
rem Reference: https://ss64.com/nt/setlocal.html
rem Reference: https://ss64.com/nt/start.html
Rem ********************************************************************************************
rem "check for required environment variables"
Rem ********************************************************************************************
call :testEnv PROJECT_PATH
call :testEnv BUILD_TYPE
call :testEnv BUILD_TARGETS
call :testEnv Png2Ico_EXECUTABLE
call :testEnv VS_VERSION
call :testEnv VCINSTALLDIR
call :testEnv WIN_GIT_PATH
if %ERRORLEVEL% neq 0 goto onError
Rem ********************************************************************************************
rem "desktop"
Rem ********************************************************************************************
echo "***** build desktop."
start "build-desktop.bat %BUILD_TYPE%" /D "%PROJECT_PATH%/" /B /wait "%~dp0/build-desktop.bat" %BUILD_TYPE%
if %ERRORLEVEL% neq 0 goto onError
Rem ********************************************************************************************
rem "collect files for the installer"
Rem ********************************************************************************************
echo "***** collect files for the installer."
start "build-installer-collect.bat %BUILD_TYPE%" /D "%PROJECT_PATH%/" /B /wait "%~dp0/build-installer-collect.bat" %BUILD_TYPE%
if %ERRORLEVEL% neq 0 goto onError
Rem ********************************************************************************************
rem "build the MSI installer"
Rem ********************************************************************************************
if "%BUILD_INSTALLER_MSI%" == "0" (
echo "** Don't build the MSI installer (disabled by BUILD_INSTALLER_MSI)"
) else (
echo "***** build the MSI installer."
start "build-installer-msi.bat %BUILD_TYPE%" /D "%PROJECT_PATH%/" /B /wait "%~dp0/build-installer-msi.bat" %BUILD_TYPE%
)
if %ERRORLEVEL% neq 0 goto onError
Rem ********************************************************************************************
echo "***** Build finished. (%~nx0)"
exit 0
:onError
echo "***** Build FAILED! (%~nx0)"
if %ERRORLEVEL% neq 0 exit %ERRORLEVEL%
if !ERRORLEVEL! neq 0 exit !ERRORLEVEL!
exit 1
:testEnv
if "!%*!" == "" (
echo "Missing environment variable: %*"
exit /B 1
)
exit /B
+32
View File
@@ -0,0 +1,32 @@
@echo off
REM SPDX-FileCopyrightText: 2019 Michael Schuster
REM SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
REM SPDX-License-Identifier: GPL-2.0-or-later
Rem ********************************************************************************************
rem "common environment Variables"
Rem ********************************************************************************************
set "BUILD_ARCH=%~2"
set "CMAKE_GENERATOR=Ninja"
set "BRANCH_NAME=%~3"
Rem CRAFT_PATH can be overridden externally; fall back to conventional KDE Craft locations.
if "%CRAFT_PATH%" == "" (
if "%BUILD_ARCH%" == "Win32" ( set "CRAFT_PATH=c:\Craft32" )
if "%BUILD_ARCH%" == "Win64" ( set "CRAFT_PATH=c:\Nextcloud\%BRANCH_NAME%\windows-msvc2022_64-cl" )
)
if "%BUILD_ARCH%" == "Win32" ( set "QT_PATH=%CRAFT_PATH%" )
if "%BUILD_ARCH%" == "Win32" ( set "PATH=%CRAFT_PATH%\bin;%CRAFT_PATH%\dev-utils\bin;%PATH%" )
if "%BUILD_ARCH%" == "Win32" ( set "QT_BIN_PATH=%CRAFT_PATH%\bin" )
if "%BUILD_ARCH%" == "Win32" ( set "QT_PREFIX=%CRAFT_PATH%" )
if "%BUILD_ARCH%" == "Win64" ( set "QT_PATH=%CRAFT_PATH%" )
if "%BUILD_ARCH%" == "Win64" ( set "PATH=%CRAFT_PATH%\bin;%CRAFT_PATH%\dev-utils\bin;%PATH%" )
if "%BUILD_ARCH%" == "Win64" ( set "QT_BIN_PATH=%CRAFT_PATH%\bin" )
if "%BUILD_ARCH%" == "Win64" ( set "QT_PREFIX=%CRAFT_PATH%" )
Rem Default EXTRA_DEPLOY_PATH when not already set by the calling script.
Rem This path is optional; if it does not exist or is empty the collect step silently skips it.
if "%EXTRA_DEPLOY_PATH%" == "" set "EXTRA_DEPLOY_PATH=%PROJECT_PATH%/deploy-extra/%BUILD_TYPE%/%BUILD_ARCH%"
+24
View File
@@ -0,0 +1,24 @@
@echo off
REM SPDX-FileCopyrightText: 2019 Michael Schuster
REM SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
REM SPDX-License-Identifier: GPL-2.0-or-later
REM Based on an idea of:
REM https://superuser.com/questions/1287756/how-can-i-get-the-date-in-a-locale-independent-format-in-a-batch-file/1287820#1287820
REM for /f "usebackq skip=1 tokens=1-3" %%g in (`wmic Path Win32_LocalTime Get Day^,Month^,Year ^| findstr /r /v "^$"`) do (
REM set _day=00%%g
REM set _month=00%%h
REM set _year=%%i
REM )
REM wmic Path Win32_LocalTime Get Day^,Month^,Year
REM Day Month Year
REM 23 5 2019
for /f "usebackq tokens=1-2" %%g in (`sh "%~dp0/datetime.inc.callee.sh" ^| findstr /r /v "^$"`) do (
set _date=%%g
set _time=%%h
)
REM echo %_date%
REM echo %_time%
REM echo %_date:~0,4%%_date:~5,2%%_date:~8,2%
+6
View File
@@ -0,0 +1,6 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2019 Michael Schuster
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: GPL-2.0-or-later
echo `date '+%Y-%m-%d %H:%M:%S'`
exit 0
+172
View File
@@ -0,0 +1,172 @@
@echo off
REM SPDX-FileCopyrightText: 2019 Michael Schuster
REM SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
REM SPDX-License-Identifier: GPL-2.0-or-later
Rem ********************************************************************************************
rem "Build defaults - environment Variables"
Rem ********************************************************************************************
Rem ********************************************************************************************
rem "CUSTOMIZE HERE:"
Rem ********************************************************************************************
Rem These are the default build environment variables for all build scripts.
Rem You may specify them from outside.
Rem IMPORTANT: Keep an eye on all the slashes and backslashes in the paths.
Rem If you intend to modify or specify them outside, keep the scheme!
Rem ********************************************************************************************
Rem Branding options
if "%APP_NAME%" == "" set "APP_NAME=Nextcloud"
if "%APP_NAME_SANITIZED%" == "" set "APP_NAME_SANITIZED=Nextcloud"
if "%APPLICATION_NAME%" == "" set "APPLICATION_NAME=Nextcloud Files Client"
if "%USE_BRANDING%" == "" set "USE_BRANDING=0"
if "%BUILD_TYPE%" == "" set "BUILD_TYPE=RelWithDebInfo"
Rem ********************************************************************************************
Rem Derive the Nextcloud desktop repository root from this script's location.
Rem The scripts live at admin/win/scripts/ inside the repo, so three levels up is the repo root.
if "%DESKTOP_REPO_PATH%" == "" set "DESKTOP_REPO_PATH=%~dp0..\..\.."
Rem ********************************************************************************************
Rem Build environment
Rem Comma separated list of build targets (default: Win64)
if "%BUILD_TARGETS%" == "" set "BUILD_TARGETS=Win64"
Rem PROJECT_PATH is the workspace root for build artifacts (install/, collect/, daily/).
Rem It should NOT be inside the repository. The desktop source is at DESKTOP_REPO_PATH.
if "%PROJECT_PATH%" == "" set "PROJECT_PATH=c:/Nextcloud"
if "%Png2Ico_EXECUTABLE%" == "" set "Png2Ico_EXECUTABLE=c:/Nextcloud/tools/png2ico.exe"
if "%VS_VERSION%" == "" set "VS_VERSION=2022"
Rem Required for Qt's windeployqt to find the VC Redist Setup (and for auto-discovery of signtool.exe)
if "%VCINSTALLDIR%" == "" (
if "%VS_VERSION%" == "2017" (
set "VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC"
)
if "%VS_VERSION%" == "2019" (
set "VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC"
)
if "%VS_VERSION%" == "2022" (
set "VCINSTALLDIR=C:\Program Files\Microsoft Visual Studio\2022\Community\VC"
)
)
Rem Required for Git Bash's mkdir.exe (mkdir -p ...)
if "%WIN_GIT_PATH%" == "" set "WIN_GIT_PATH=C:\Program Files\Git"
Rem ********************************************************************************************
Rem Test run? 1 = just show environment variables, 0 = normal build (default)
if "%TEST_RUN%" == "" set "TEST_RUN=0"
Rem ********************************************************************************************
Rem Date and version for Desktop and Installer build
Rem Try to use our locale-independent helper
call "%~dp0/datetime.inc.bat"
if "%BUILD_DATE%" == "" (
if "%_date%" == "" (
set "BUILD_DATE=%date:~10,4%%date:~4,2%%date:~7,2%"
) else (
set "BUILD_DATE=%_date:~0,4%%_date:~5,2%%_date:~8,2%"
)
)
if "%VERSION_SUFFIX%" == "" set "VERSION_SUFFIX="
Rem Git tag for checkout when CHECKOUT_DESKTOP=1 (default: master for daily build)
if "%TAG_DESKTOP%" == "" set "TAG_DESKTOP=master"
if "%CRAFT_TAG_DESKTOP%" == "" set "CRAFT_TAG_DESKTOP=stable-34.0"
Rem ********************************************************************************************
Rem Git pull/checkout defaults.
Rem Since the build scripts now live inside the desktop repository, both options default to 0.
Rem Set PULL_DESKTOP=1 and CHECKOUT_DESKTOP=1 only when you want a fresh clone of the desktop
Rem source to a different location (e.g. for an isolated release build).
if "%PULL_DESKTOP%" == "" set "PULL_DESKTOP=0"
if "%CHECKOUT_DESKTOP%" == "" set "CHECKOUT_DESKTOP=0"
Rem Branding overrides
if "%USE_BRANDING%" == "1" (
set "PULL_DESKTOP=0"
set "CHECKOUT_DESKTOP=0"
)
Rem Updater: ON = build, OFF = don't build (default)
if "%BUILD_UPDATER%" == "" set "BUILD_UPDATER=OFF"
Rem ********************************************************************************************
Rem Installer Options
Rem NSIS EXE installer: not supported; use MSI instead (BUILD_INSTALLER_MSI=1)
if "%BUILD_INSTALLER%" == "" set "BUILD_INSTALLER=0"
Rem MSI installer: 1 = build (default), 0 = don't build
if "%BUILD_INSTALLER_MSI%" == "" set "BUILD_INSTALLER_MSI=1"
if "%INSTALLER_OUTPUT_PATH%" == "" set "INSTALLER_OUTPUT_PATH=%PROJECT_PATH%\daily\"
Rem ********************************************************************************************
Rem Code Signing Options: 1 = enable (default), 0 = disable
if "%USE_CODE_SIGNING%" == "" set "USE_CODE_SIGNING=1"
Rem Vendor Name: Used for signing, also used by the installer
if "%APPLICATION_VENDOR%" == "" set "APPLICATION_VENDOR=Nextcloud GmbH"
Rem PFX Key and Password - it may be a good idea to set the password outside (environment variables)
if "%CERTIFICATE_FILENAME%" == "" set "CERTIFICATE_FILENAME="
if "%CERTIFICATE_CSP%" == "" set "CERTIFICATE_CSP="
if "%CERTIFICATE_KEY_CONTAINER_NAME%" == "" set "CERTIFICATE_KEY_CONTAINER_NAME="
if "%CERTIFICATE_PASSWORD%" == "" set "CERTIFICATE_PASSWORD="
if "%SIGN_FILE_DIGEST_ALG%" == "" set "SIGN_FILE_DIGEST_ALG=sha256"
if "%SIGN_TIMESTAMP_URL%" == "" set "SIGN_TIMESTAMP_URL=http://timestamp.digicert.com"
if "%SIGN_TIMESTAMP_DIGEST_ALG%" == "" set "SIGN_TIMESTAMP_DIGEST_ALG=sha256"
Rem ********************************************************************************************
Rem Second Code Signing Options: 1 = enable, 0 = disable (default)
Rem Optional additional signature appended to the first one (dual signing). Not required
Rem even when USE_CODE_SIGNING=1 - only used when explicitly enabled.
if "%USE_SECOND_CODE_SIGNING%" == "" set "USE_SECOND_CODE_SIGNING=0"
Rem PFX Key and Password for the second certificate - same scheme as the first one
if "%SECOND_CERTIFICATE_FILENAME%" == "" set "SECOND_CERTIFICATE_FILENAME="
if "%SECOND_CERTIFICATE_CSP%" == "" set "SECOND_CERTIFICATE_CSP="
if "%SECOND_CERTIFICATE_KEY_CONTAINER_NAME%" == "" set "SECOND_CERTIFICATE_KEY_CONTAINER_NAME="
if "%SECOND_CERTIFICATE_PASSWORD%" == "" set "SECOND_CERTIFICATE_PASSWORD="
if "%SECOND_SIGN_FILE_DIGEST_ALG%" == "" set "SECOND_SIGN_FILE_DIGEST_ALG=sha256"
if "%SECOND_SIGN_TIMESTAMP_URL%" == "" set "SECOND_SIGN_TIMESTAMP_URL=http://timestamp.digicert.com"
if "%SECOND_SIGN_TIMESTAMP_DIGEST_ALG%" == "" set "SECOND_SIGN_TIMESTAMP_DIGEST_ALG=sha256"
Rem ********************************************************************************************
Rem Upload build: 1 = enable (default), 0 = disable
if "%UPLOAD_BUILD%" == "" set "UPLOAD_BUILD=1"
Rem Delete build after successful upload: 1 = delete, 0 = keep (default)
if "%UPLOAD_DELETE%" == "" set "UPLOAD_DELETE=0"
Rem Note: Storing SFTP_PATH outside in Windows's env leads to trouble due to the preceding slash!
if "%SFTP_PATH%" == "" set "SFTP_PATH=/var/www/html/desktop/daily/Windows"
if "%SFTP_SERVER%" == "" set "SFTP_SERVER="
if "%SFTP_USER%" == "" set "SFTP_USER="
Rem ********************************************************************************************
Rem CMake extra build flags (optional)
Rem Here you may define special flags for the Desktop build, e.g. the Update Server URL
Rem ( -DAPPLICATION_UPDATE_URL="https://your.url" ). see: desktop/build/config.h and version.h
if "%CMAKE_EXTRA_FLAGS_DESKTOP%" == "" set "CMAKE_EXTRA_FLAGS_DESKTOP="
if "%WIX%" == "" set "WIX=C:/Program Files (x86)/WiX Toolset v3.14"
if "%WIX_SDK_PATH%" == "" set "WIX_SDK_PATH=C:/Program Files (x86)/WiX Toolset v3.14/SDK/VS2017"
Rem ********************************************************************************************
+147
View File
@@ -0,0 +1,147 @@
@echo off
REM SPDX-FileCopyrightText: 2019 Michael Schuster
REM SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
REM SPDX-License-Identifier: GPL-2.0-or-later
setlocal EnableDelayedExpansion
cls
Rem ********************************************************************************************
rem "sign a binary file (exe, dll)"
Rem ********************************************************************************************
call "%~dp0/defaults.inc.bat"
Rem ********************************************************************************************
echo "*** Sign file: %~1"
if "%~1" == "" (
echo "Missing parameter: Please specify file to sign"
exit 1
)
Rem ********************************************************************************************
echo "* PROJECT_PATH=%PROJECT_PATH%"
echo "* SIGNTOOL=%SIGNTOOL%"
echo "* VCINSTALLDIR=%VCINSTALLDIR%"
echo "* Build date %BUILD_DATE%"
echo "* APPLICATION_VENDOR %APPLICATION_VENDOR%"
echo "* TAG_DESKTOP %TAG_DESKTOP%"
echo "* APPLICATION_NAME %APPLICATION_NAME%"
echo "* SIGN_FILE_DIGEST_ALG=%SIGN_FILE_DIGEST_ALG%"
echo "* SIGN_TIMESTAMP_URL=%SIGN_TIMESTAMP_URL%"
echo "* SIGN_TIMESTAMP_DIGEST_ALG=%SIGN_TIMESTAMP_DIGEST_ALG%"
echo "* USE_CODE_SIGNING=%USE_CODE_SIGNING%"
echo "* USE_SECOND_CODE_SIGNING=%USE_SECOND_CODE_SIGNING%"
echo "* SECOND_SIGN_FILE_DIGEST_ALG=%SECOND_SIGN_FILE_DIGEST_ALG%"
echo "* SECOND_SIGN_TIMESTAMP_URL=%SECOND_SIGN_TIMESTAMP_URL%"
echo "* SECOND_SIGN_TIMESTAMP_DIGEST_ALG=%SECOND_SIGN_TIMESTAMP_DIGEST_ALG%"
echo "* PATH=%PATH%"
Rem ********************************************************************************************
rem "check for required environment variables"
Rem ********************************************************************************************
if "%USE_CODE_SIGNING%" == "0" (
echo "** Abort sign: Code signing is disabled by USE_CODE_SIGNING"
exit
)
call :testEnv PROJECT_PATH
call :testEnv APPLICATION_VENDOR
call :testEnv TAG_DESKTOP
call :testEnv APPLICATION_NAME
call :testEnv CERTIFICATE_FILENAME
call :testEnv CERTIFICATE_CSP
call :testEnv CERTIFICATE_KEY_CONTAINER_NAME
call :testEnv CERTIFICATE_PASSWORD
call :testEnv SIGN_FILE_DIGEST_ALG
call :testEnv SIGN_TIMESTAMP_URL
call :testEnv SIGN_TIMESTAMP_DIGEST_ALG
if %ERRORLEVEL% neq 0 goto onError
if "%USE_SECOND_CODE_SIGNING%" == "1" (
call :testEnv SECOND_CERTIFICATE_FILENAME
call :testEnv SECOND_CERTIFICATE_CSP
call :testEnv SECOND_CERTIFICATE_KEY_CONTAINER_NAME
call :testEnv SECOND_CERTIFICATE_PASSWORD
call :testEnv SECOND_SIGN_FILE_DIGEST_ALG
call :testEnv SECOND_SIGN_TIMESTAMP_URL
call :testEnv SECOND_SIGN_TIMESTAMP_DIGEST_ALG
)
if %ERRORLEVEL% neq 0 goto onError
Rem ********************************************************************************************
rem "try to find signtool, if not specified via environment"
Rem ********************************************************************************************
REM Note: vcvars is the official way to set the path for all the VC and Win SDK tools.
REM signtool.exe resides in a SDK version specific directory, like:
REM C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86\signtool.exe
if "%SIGNTOOL%" == "" (
echo "** SIGNTOOL not set: trying to find via VCINSTALLDIR:"
call :testEnv VCINSTALLDIR
if %ERRORLEVEL% neq 0 goto onError
echo "** Calling vcvars64.bat to add signtool to the PATH:"
call "%VCINSTALLDIR%\Auxiliary\Build\vcvars64.bat"
if %ERRORLEVEL% neq 0 goto onError
for %%i in (signtool.exe) do @set SIGNTOOL=%%~$PATH:i
if "!SIGNTOOL!" == "" (
echo "** Unable to find signtool.exe in the PATH."
goto onError
) else (
echo "** Found signtool.exe: !SIGNTOOL!"
)
)
call :testEnv SIGNTOOL
if %ERRORLEVEL% neq 0 goto onError
Rem ********************************************************************************************
rem "sign"
Rem ********************************************************************************************
rem Reference: https://ss64.com/nt/setlocal.html
rem Reference: https://ss64.com/nt/start.html
echo "* Run signtool on file: %~1"
start "signtool" /D "%PROJECT_PATH%" /B /wait "%SIGNTOOL%" sign /debug /v /d "%APPLICATION_NAME% %TAG_DESKTOP%" /tr "%SIGN_TIMESTAMP_URL%" /td %SIGN_TIMESTAMP_DIGEST_ALG% /fd %SIGN_FILE_DIGEST_ALG% /f "%CERTIFICATE_FILENAME%" /csp "%CERTIFICATE_CSP%" /kc "[{{%CERTIFICATE_PASSWORD%}}]=%CERTIFICATE_KEY_CONTAINER_NAME%" "%~1"
if %ERRORLEVEL% neq 0 goto onError
Rem ********************************************************************************************
rem "sign (second, optional certificate - appended signature)"
Rem ********************************************************************************************
if "%USE_SECOND_CODE_SIGNING%" == "1" (
echo "* Run signtool (second signature, appended) on file: %~1"
start "signtool-second" /D "%PROJECT_PATH%" /B /wait "%SIGNTOOL%" sign /as /debug /v /d "%APPLICATION_NAME% %TAG_DESKTOP%" /tr "%SECOND_SIGN_TIMESTAMP_URL%" /td %SECOND_SIGN_TIMESTAMP_DIGEST_ALG% /fd %SECOND_SIGN_FILE_DIGEST_ALG% /f "%SECOND_CERTIFICATE_FILENAME%" /csp "%SECOND_CERTIFICATE_CSP%" /kc "[{{%SECOND_CERTIFICATE_PASSWORD%}}]=%SECOND_CERTIFICATE_KEY_CONTAINER_NAME%" "%~1"
if %ERRORLEVEL% neq 0 goto onError
)
Rem ********************************************************************************************
echo "*** Finished sign file: %~1"
exit 0
:onError
echo "*** Sign FAILED for file: %~1"
if %ERRORLEVEL% neq 0 exit %ERRORLEVEL%
if !ERRORLEVEL! neq 0 exit !ERRORLEVEL!
exit 1
:testEnv
if "!%*!" == "" (
echo "Missing environment variable: %*"
exit /B 1
)
exit /B
+193
View File
@@ -0,0 +1,193 @@
@echo off
REM SPDX-FileCopyrightText: 2019 Michael Schuster
REM SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
REM SPDX-License-Identifier: GPL-2.0-or-later
setlocal EnableDelayedExpansion
cls
echo "*** Build: desktop (%~nx0)"
Rem ********************************************************************************************
rem "environment Variables"
Rem ********************************************************************************************
call "%~dp0/common.inc.bat" %1 %2 %CRAFT_TAG_DESKTOP%
Rem ********************************************************************************************
if "%TAG%" == "" set TAG=%TAG_DESKTOP%
set "VERSION_SUFFIX=%VERSION_SUFFIX%"
if "%VERSION_SUFFIX%" == "" (
set "CMAKE_VERSION_SUFFIX=-DMIRALL_VERSION_SUFFIX=\"\""
) else (
set "CMAKE_VERSION_SUFFIX=-DMIRALL_VERSION_SUFFIX=%VERSION_SUFFIX%"
)
Rem MY_REPO is the Nextcloud desktop repository root. When CHECKOUT_DESKTOP=0 (the default),
Rem the existing checkout at DESKTOP_REPO_PATH is used directly.
set "MY_REPO=%DESKTOP_REPO_PATH%"
set "MY_BUILD_PATH=%MY_REPO%\build"
set "MY_INSTALL_PATH=%PROJECT_PATH%/install/%BUILD_TYPE%/%BUILD_ARCH%"
set "MY_QT_DEPLOYMENT_PATH=%MY_INSTALL_PATH%/qt-libs"
echo "* APP_NAME=%APP_NAME%"
echo "* USE_BRANDING=%USE_BRANDING%"
echo "* BUILD_TYPE=%BUILD_TYPE%"
echo "* BUILD_ARCH=%BUILD_ARCH%"
echo "* CMAKE_GENERATOR=%CMAKE_GENERATOR%"
echo "* CMAKE_EXTRA_FLAGS_DESKTOP=%CMAKE_EXTRA_FLAGS_DESKTOP%"
echo "* PROJECT_PATH=%PROJECT_PATH%"
echo "* QT_PREFIX=%QT_PREFIX%"
echo "* QT_PATH=%QT_PATH%"
echo "* QT_BIN_PATH=%QT_BIN_PATH%"
echo "* VCINSTALLDIR=%VCINSTALLDIR%"
echo "* Png2Ico_EXECUTABLE=%Png2Ico_EXECUTABLE%"
echo "* Build date %BUILD_DATE%"
echo "* VERSION_SUFFIX %VERSION_SUFFIX%"
echo "* TAG %TAG%"
echo "* PULL_DESKTOP %PULL_DESKTOP%"
echo "* CHECKOUT_DESKTOP %CHECKOUT_DESKTOP%"
echo "* BUILD_UPDATER %BUILD_UPDATER%"
echo "* BUILD_INSTALLER_MSI %BUILD_INSTALLER_MSI%"
echo "* DESKTOP_REPO_PATH=%DESKTOP_REPO_PATH%"
echo "* MY_REPO=%MY_REPO%"
echo "* MY_BUILD_PATH=%MY_BUILD_PATH%"
echo "* MY_INSTALL_PATH=%MY_INSTALL_PATH%"
echo "* MY_QT_DEPLOYMENT_PATH=%MY_QT_DEPLOYMENT_PATH%"
echo "* WIX_SDK_PATH=%WIX_SDK_PATH%"
echo "* PATH=%PATH%"
Rem ********************************************************************************************
rem "check for required environment variables"
Rem ********************************************************************************************
call :testEnv APP_NAME
call :testEnv PROJECT_PATH
call :testEnv BUILD_TYPE
call :testEnv BUILD_ARCH
call :testEnv CMAKE_GENERATOR
call :testEnv QT_PREFIX
call :testEnv QT_PATH
call :testEnv QT_BIN_PATH
call :testEnv VCINSTALLDIR
call :testEnv Png2Ico_EXECUTABLE
call :testEnv WIX_SDK_PATH
call :testEnv BUILD_DATE
call :testEnv BUILD_UPDATER
call :testEnv TAG
if %ERRORLEVEL% neq 0 goto onError
if "%BUILD_ARCH%" == "Win64" ( call "%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" x64 )
if "%BUILD_ARCH%" == "Win32" ( call "%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" amd64_x86 )
Rem ********************************************************************************************
rem "Test run?"
Rem ********************************************************************************************
if "%TEST_RUN%" == "1" (
echo "** TEST RUN - exit."
exit
)
Rem ********************************************************************************************
rem "clean up"
Rem ********************************************************************************************
echo "* Remove old installation files %MY_INSTALL_PATH% from previous build."
start "rm -rf" /B /wait rm -rf "%MY_INSTALL_PATH%/"*
if %ERRORLEVEL% neq 0 goto onError
echo "* Remove old dependencies files %MY_QT_DEPLOYMENT_PATH% from previous build."
start "rm -rf" /B /wait rm -rf "%MY_QT_DEPLOYMENT_PATH%/"*
if %ERRORLEVEL% neq 0 goto onError
echo "* Remove %MY_BUILD_PATH% from previous build."
start "rm -rf" /B /wait rm -rf "%MY_BUILD_PATH%/"*
if %ERRORLEVEL% neq 0 goto onError
Rem ********************************************************************************************
rem "git pull, build, collect dependencies"
Rem ********************************************************************************************
rem Reference: https://ss64.com/nt/setlocal.html
rem Reference: https://ss64.com/nt/start.html
if "%PULL_DESKTOP%" == "1" (
Rem Checkout master first to have it clean for git pull
if "%CHECKOUT_DESKTOP%" == "1" (
echo "* Remove %MY_REPO% from previous build."
start "rm -rf" /B /wait rm -rf "%MY_REPO%/"
if %ERRORLEVEL% neq 0 goto onError
echo "* git clone %TAG% at %MY_REPO%/."
start "git clone %TAG%" /B /wait git clone --depth=1 --branch=%TAG% https://github.com/nextcloud/desktop %MY_REPO%
)
if !ERRORLEVEL! neq 0 goto onError
) else (
if "%CHECKOUT_DESKTOP%" == "1" (
echo "* Remove %MY_REPO% from previous build."
start "rm -rf" /B /wait rm -rf "%MY_REPO%/"*
if %ERRORLEVEL% neq 0 goto onError
echo "* git checkout %TAG% at %MY_REPO%/."
start "git checkout %TAG%" /B /wait git clone --depth=1 --branch=%TAG% https://github.com/nextcloud/desktop %MY_REPO%
if !ERRORLEVEL! neq 0 goto onError
)
if %ERRORLEVEL% neq 0 goto onError
)
if %ERRORLEVEL% neq 0 goto onError
echo "* Create desktop build directory"
start "mkdir %MY_BUILD_PATH%" /D "%PROJECT_PATH%/" /B /wait "%WIN_GIT_PATH%\usr\bin\mkdir.exe" -p "%MY_BUILD_PATH%"
if %ERRORLEVEL% neq 0 goto onError
echo "* save git HEAD commit hash from repo %MY_REPO%/."
start "git rev-parse HEAD" /D "%MY_REPO%/" /B /wait git rev-parse HEAD > "%PROJECT_PATH%"/tmp
if %ERRORLEVEL% neq 0 goto onError
set /p GIT_REVISION= < "%PROJECT_PATH%"\tmp
if %ERRORLEVEL% neq 0 goto onError
del "%PROJECT_PATH%"\tmp
echo "* Run cmake with CMAKE_INSTALL_PREFIX and CMAKE_BUILD_TYPE set at %MY_BUILD_PATH%."
echo "cmake "-G%CMAKE_GENERATOR%" -S "%DESKTOP_REPO_PATH%" -DMIRALL_VERSION_SUFFIX="%VERSION_SUFFIX%" -DBUILD_TESTING="OFF" -DWITH_CRASHREPORTER="OFF" -DBUILD_UPDATER="%BUILD_UPDATER%" -DBUILD_WIN_MSI="%BUILD_INSTALLER_MSI%" -DMIRALL_VERSION_BUILD="%BUILD_DATE%" -DCMAKE_INSTALL_PREFIX="%MY_INSTALL_PATH%" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DCMAKE_PREFIX_PATH="%CRAFT_PATH%" -DPng2Ico_EXECUTABLE="%Png2Ico_EXECUTABLE%" -DWIX_SDK_PATH="%WIX_SDK_PATH%""
start "cmake.." /D "%MY_BUILD_PATH%" /B /wait cmake "-G%CMAKE_GENERATOR%" -S "%DESKTOP_REPO_PATH%" -DMIRALL_VERSION_SUFFIX="%VERSION_SUFFIX%" -DBUILD_TESTING="OFF" -DWITH_CRASHREPORTER="OFF" -DBUILD_UPDATER="%BUILD_UPDATER%" -DBUILD_WIN_MSI="%BUILD_INSTALLER_MSI%" -DMIRALL_VERSION_BUILD="%BUILD_DATE%" -DCMAKE_INSTALL_PREFIX="%MY_INSTALL_PATH%" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DCMAKE_PREFIX_PATH="%CRAFT_PATH%" -DPng2Ico_EXECUTABLE="%Png2Ico_EXECUTABLE%" -DWIX_SDK_PATH="%WIX_SDK_PATH%"
if %ERRORLEVEL% neq 0 goto onError
echo "* Run cmake to compile and install."
start "cmake build" /D "%MY_BUILD_PATH%" /B /wait cmake --build . --config %BUILD_TYPE% --target install
if %ERRORLEVEL% neq 0 goto onError
if "%BUILD_TYPE%" == "Debug" (
set WINDEPLOYQT_BUILD_TYPE=debug
) else (
set WINDEPLOYQT_BUILD_TYPE=release
)
echo "* Run windeployqt to collect all %APP_NAME%.exe dependencies and output it to %MY_QT_DEPLOYMENT_PATH%/."
start "windeployqt" /B /wait %QT_BIN_PATH%/windeployqt.exe --%WINDEPLOYQT_BUILD_TYPE% --compiler-runtime "%MY_INSTALL_PATH%/bin/%APP_NAME%.exe" --dir "%MY_QT_DEPLOYMENT_PATH%/" --qmldir "%MY_REPO%\src\gui" -websockets
if %ERRORLEVEL% neq 0 goto onError
Rem ********************************************************************************************
echo "*** Finished Build: desktop %BUILD_TYPE% %BUILD_ARCH% (GIT_REVISION=%GIT_REVISION%) (%~nx0)"
exit 0
:onError
echo "*** Build FAILED: desktop %BUILD_TYPE% %BUILD_ARCH% (%~nx0)"
if %ERRORLEVEL% neq 0 exit %ERRORLEVEL%
if !ERRORLEVEL! neq 0 exit !ERRORLEVEL!
exit 1
:testEnv
if "!%*!" == "" (
echo "Missing environment variable: %*"
exit /B 1
)
exit /B
+320
View File
@@ -0,0 +1,320 @@
@echo off
REM SPDX-FileCopyrightText: 2019 Michael Schuster
REM SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
REM SPDX-License-Identifier: GPL-2.0-or-later
setlocal EnableDelayedExpansion
cls
echo "*** Build: installer-collect (%~nx0)"
Rem ********************************************************************************************
rem "environment Variables"
Rem ********************************************************************************************
call "%~dp0/common.inc.bat" %1 %2 %CRAFT_TAG_DESKTOP%
Rem ********************************************************************************************
Rem MY_REPO is the Nextcloud desktop repository root, used to locate qt.conf and the app icon.
set "MY_REPO=%DESKTOP_REPO_PATH%"
set "MY_BUILD_PATH=%MY_REPO%/build"
set "MY_INSTALL_PATH=%PROJECT_PATH%/install/%BUILD_TYPE%/%BUILD_ARCH%"
set "MY_QT_DEPLOYMENT_PATH=%MY_INSTALL_PATH%/qt-libs"
set "MY_COLLECT_PATH=%PROJECT_PATH%/collect/%BUILD_TYPE%/%BUILD_ARCH%"
echo "* APP_NAME=%APP_NAME%"
echo "* APP_NAME_SANITIZED=%APP_NAME_SANITIZED%"
echo "* USE_BRANDING=%USE_BRANDING%"
echo "* BUILD_TYPE=%BUILD_TYPE%"
echo "* BUILD_ARCH=%BUILD_ARCH%"
echo "* PROJECT_PATH=%PROJECT_PATH%"
echo "* Build date %BUILD_DATE%"
echo "* VERSION_SUFFIX %VERSION_SUFFIX%"
echo "* APPLICATION_VENDOR %APPLICATION_VENDOR%"
echo "* TAG_DESKTOP %TAG_DESKTOP%"
echo "* APPLICATION_NAME %APPLICATION_NAME%"
echo "* WIN_GIT_PATH=%WIN_GIT_PATH%"
echo "* VCINSTALLDIR=%VCINSTALLDIR%"
echo "* EXTRA_DEPLOY_PATH=%EXTRA_DEPLOY_PATH%"
echo "* DLL_SUFFIX=%DLL_SUFFIX%"
echo "* DESKTOP_REPO_PATH=%DESKTOP_REPO_PATH%"
echo "* MY_REPO=%MY_REPO%"
echo "* MY_BUILD_PATH=%MY_BUILD_PATH%"
echo "* MY_INSTALL_PATH=%MY_INSTALL_PATH%"
echo "* MY_QT_DEPLOYMENT_PATH=%MY_QT_DEPLOYMENT_PATH%"
echo "* MY_COLLECT_PATH=%MY_COLLECT_PATH%"
echo "* PATH=%PATH%"
echo "* USE_CODE_SIGNING=%USE_CODE_SIGNING%"
echo "* USE_SECOND_CODE_SIGNING=%USE_SECOND_CODE_SIGNING%"
Rem ********************************************************************************************
rem "check for required environment variables"
Rem ********************************************************************************************
call :testEnv APP_NAME
call :testEnv APP_NAME_SANITIZED
call :testEnv PROJECT_PATH
call :testEnv BUILD_TYPE
call :testEnv BUILD_ARCH
call :testEnv WIN_GIT_PATH
call :testEnv EXTRA_DEPLOY_PATH
if "%USE_CODE_SIGNING%" == "1" (
call :testEnv VCINSTALLDIR
call :testEnv APPLICATION_VENDOR
call :testEnv TAG_DESKTOP
call :testEnv APPLICATION_NAME
call :testEnv CERTIFICATE_FILENAME
call :testEnv CERTIFICATE_CSP
call :testEnv CERTIFICATE_KEY_CONTAINER_NAME
call :testEnv CERTIFICATE_PASSWORD
call :testEnv SIGN_FILE_DIGEST_ALG
call :testEnv SIGN_TIMESTAMP_URL
call :testEnv SIGN_TIMESTAMP_DIGEST_ALG
if "%USE_SECOND_CODE_SIGNING%" == "1" (
call :testEnv SECOND_CERTIFICATE_FILENAME
call :testEnv SECOND_CERTIFICATE_CSP
call :testEnv SECOND_CERTIFICATE_KEY_CONTAINER_NAME
call :testEnv SECOND_CERTIFICATE_PASSWORD
call :testEnv SECOND_SIGN_FILE_DIGEST_ALG
call :testEnv SECOND_SIGN_TIMESTAMP_URL
call :testEnv SECOND_SIGN_TIMESTAMP_DIGEST_ALG
)
)
if %ERRORLEVEL% neq 0 goto onError
Rem ********************************************************************************************
rem "Test run?"
Rem ********************************************************************************************
if "%TEST_RUN%" == "1" (
echo "** TEST RUN - exit."
exit
)
Rem ********************************************************************************************
rem "clean up"
Rem ********************************************************************************************
echo "* Remove old installation files %MY_COLLECT_PATH% from previous build."
start "rm -rf" /B /wait rm -rf "%MY_COLLECT_PATH%/"*
if %ERRORLEVEL% neq 0 goto onError
Rem ********************************************************************************************
rem "collect dependencies"
Rem ********************************************************************************************
rem Reference: https://ss64.com/nt/setlocal.html
rem Reference: https://ss64.com/nt/start.html
Rem Output path for collected files
echo "* mkdir %MY_COLLECT_PATH%"
start "mkdir collect" /D "%MY_INSTALL_PATH%/" /B /wait "%WIN_GIT_PATH%\usr\bin\mkdir.exe" -p "%MY_COLLECT_PATH%"
Rem Note: Force the use Git Bash's mkdir.exe, usually found in C:\Program Files\Git\usr\bin
if %ERRORLEVEL% neq 0 goto onError
Rem Desktop Client and resources
echo "* copy language files (i18n)."
start "copy i18n" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%MY_INSTALL_PATH%/i18n" "%MY_COLLECT_PATH%/"
if %ERRORLEVEL% neq 0 goto onError
echo "* copy desktop client files (bin/)."
start "copy bin/" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%MY_INSTALL_PATH%/bin/"* "%MY_COLLECT_PATH%/"
if %ERRORLEVEL% neq 0 goto onError
echo "* copy %APP_NAME_SANITIZED%_csync.dll."
start "copy %APP_NAME_SANITIZED%_csync.dll" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%MY_INSTALL_PATH%/bin/%APP_NAME_SANITIZED%_csync.dll" "%MY_COLLECT_PATH%/"
if %ERRORLEVEL% neq 0 goto onError
Rem exclude system file list
echo "* copy sync-exclude.lst."
start "copy sync-exclude.lst" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%MY_INSTALL_PATH%/config/%APP_NAME%/sync-exclude.lst" "%MY_COLLECT_PATH%/"
if %ERRORLEVEL% neq 0 goto onError
Rem icon (hi-res version created by png2ico, if unavailable use lo-res: admin/win/nsi/installer.ico)
echo "* copy %APP_NAME_SANITIZED%.ico."
if exist "%MY_BUILD_PATH%/src/gui/%APP_NAME_SANITIZED%.ico" (
start "copy %APP_NAME_SANITIZED%.ico" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%MY_BUILD_PATH%/src/gui/%APP_NAME_SANITIZED%.ico" "%MY_COLLECT_PATH%/%APP_NAME_SANITIZED%.ico"
) else (
echo " NOT FOUND - try to copy installer.ico to %APP_NAME_SANITIZED%.ico"
start "copy installer.ico to %APP_NAME_SANITIZED%.ico" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%MY_REPO%/admin/win/nsi/installer.ico" "%MY_COLLECT_PATH%/%APP_NAME_SANITIZED%.ico"
)
if %ERRORLEVEL% neq 0 goto onError
echo "* run windeployqt "%MY_COLLECT_PATH%/%APP_NAME_SANITIZED%.exe."
start "run windeployqt" /D "%MY_COLLECT_PATH%/" /B /wait windeployqt %PDB_OPTION% --compiler-runtime --qmldir "%MY_REPO%\src" --release --force --verbose 2 "%MY_COLLECT_PATH%/%APP_NAME_SANITIZED%.exe" "%MY_COLLECT_PATH%/%APP_NAME_SANITIZED%_csync.dll" "%MY_COLLECT_PATH%/%APP_NAME_SANITIZED%cmd.exe" "%MY_COLLECT_PATH%/%APP_NAME_SANITIZED%sync.dll"
if %ERRORLEVEL% neq 0 goto onError
Rem Remove Qt bearer plugins, they seem to cause issues on Windows
echo "* remove Qt bearer plugins"
start "remove Qt bearer plugins" /D "%MY_COLLECT_PATH%/" /B /wait rm -rf "%MY_COLLECT_PATH%/bearer"
if %ERRORLEVEL% neq 0 goto onError
echo "* copy Qt dependencies."
start "copy bin/" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%CRAFT_PATH%/bin/freetype%DLL_SUFFIX%.dll" "%MY_COLLECT_PATH%/"
if %ERRORLEVEL% neq 0 goto onError
Rem Qt config file for correct deployment
echo "* copy qt.conf."
start "copy qt.conf" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%MY_REPO%/admin/win/nsi/qt.conf" "%MY_COLLECT_PATH%/"
if %ERRORLEVEL% neq 0 goto onError
Rem OpenSSL's libcrypto: Be future-proof! ;)
echo "* get libcrypto's dll filename from %CRAFT_PATH%/bin/."
start "get libcrypto's dll filename" /D "%CRAFT_PATH%/bin/" /B /wait ls libcrypto-3*.dll > "%PROJECT_PATH%"/tmp
if %ERRORLEVEL% neq 0 goto onError
set /p LIBCRYPTO_DLL_FILENAME= < "%PROJECT_PATH%"\tmp
if %ERRORLEVEL% neq 0 goto onError
del "%PROJECT_PATH%"\tmp
echo "* LIBCRYPTO_DLL_FILENAME=%LIBCRYPTO_DLL_FILENAME%"
echo "* copy %CRAFT_PATH%/bin/%LIBCRYPTO_DLL_FILENAME%."
start "copy %LIBCRYPTO_DLL_FILENAME%" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%CRAFT_PATH%/bin/%LIBCRYPTO_DLL_FILENAME%" "%MY_COLLECT_PATH%/"
if %ERRORLEVEL% neq 0 goto onError
Rem OpenSSL's libssl
echo "* get libssl's dll filename from %CRAFT_PATH%/bin/."
start "get libssl's dll filename" /D "%CRAFT_PATH%/bin/" /B /wait ls libssl-3*.dll > "%PROJECT_PATH%"/tmp
if %ERRORLEVEL% neq 0 goto onError
set /p LIBSSL_DLL_FILENAME= < "%PROJECT_PATH%"\tmp
if %ERRORLEVEL% neq 0 goto onError
del "%PROJECT_PATH%"\tmp
echo "* LIBSSL_DLL_FILENAME=%LIBSSL_DLL_FILENAME%"
echo "* copy %CRAFT_PATH%/bin/%LIBSSL_DLL_FILENAME%."
start "copy %LIBSSL_DLL_FILENAME%" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%CRAFT_PATH%/bin/%LIBSSL_DLL_FILENAME%" "%MY_COLLECT_PATH%/"
if %ERRORLEVEL% neq 0 goto onError
echo "* copy libp11.dll"
start "copy libp11.dll" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%CRAFT_PATH%/bin/libp11.dll" "%MY_COLLECT_PATH%/"
if %ERRORLEVEL% neq 0 goto
echo "* copy kdsingleapplication-qt6.dll"
start "copy kdsingleapplication-qt6.dll" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%CRAFT_PATH%/bin/kdsingleapplication-qt6.dll" "%MY_COLLECT_PATH%/"
if %ERRORLEVEL% neq 0 goto
Rem zlib
echo "* copy zlib1%DLL_SUFFIX%.dll."
start "copy zlib1%DLL_SUFFIX%.dll" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%CRAFT_PATH%/bin/zlib1%DLL_SUFFIX%.dll" "%MY_COLLECT_PATH%/"
if %ERRORLEVEL% neq 0 goto
echo "* copy KArchive files (bin/)."
start "copy bin/" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%CRAFT_PATH%/bin/KF6Archive%DLL_SUFFIX%.dll"* "%CRAFT_PATH%/bin/bz2%DLL_SUFFIX%.dll" "%CRAFT_PATH%/bin/liblzma%DLL_SUFFIX%.dll" "%CRAFT_PATH%/bin/zstd%DLL_SUFFIX%.dll" "%CRAFT_PATH%/bin/pcre2-16%DLL_SUFFIX%.dll" "%CRAFT_PATH%/bin/libpng16%DLL_SUFFIX%.dll" "%CRAFT_PATH%/bin/harfbuzz%DLL_SUFFIX%.dll" "%CRAFT_PATH%/bin/jpeg62%DLL_SUFFIX%.dll" "%MY_COLLECT_PATH%/"
if %ERRORLEVEL% neq 0 goto onError
echo "* copy brotlicommon.dll"
start "copy brotlicommon.dll" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%CRAFT_PATH%/bin/brotlicommon.dll" "%MY_COLLECT_PATH%/"
if %ERRORLEVEL% neq 0 goto
echo "* copy brotlidec.dll"
start "copy brotlidec.dll" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%CRAFT_PATH%/bin/brotlidec.dll" "%MY_COLLECT_PATH%/"
if %ERRORLEVEL% neq 0 goto
Rem sqlite
echo "* copy libsqlite.dll"
start "copy libsqlite.dll" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%CRAFT_PATH%/bin/libsqlite.dll" "%MY_COLLECT_PATH%/"
if %ERRORLEVEL% neq 0 goto
echo "* copy Qt OpenSSL backend plugin"
start "copy qopensslbackend.dll" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%CRAFT_PATH%/plugins/tls/qopensslbackend.dll" "%MY_COLLECT_PATH%/tls"
if %ERRORLEVEL% neq 0 goto
echo "* copy b2-1.dll"
start "copy b2-1.dll" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%CRAFT_PATH%/bin/b2-1.dll" "%MY_COLLECT_PATH%/"
if %ERRORLEVEL% neq 0 goto
Rem deploy-extra: optional extra dll's and other resources
echo "* copy optional extra resources (dll's, etc.) from %EXTRA_DEPLOY_PATH%/."
( dir /b /a "%EXTRA_DEPLOY_PATH%" | findstr . ) > nul && (
start "copy %EXTRA_DEPLOY_PATH%/" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%EXTRA_DEPLOY_PATH%/"* "%MY_COLLECT_PATH%/"
) || (
echo "* NOTE: nothing found to copy from %EXTRA_DEPLOY_PATH%/."
goto skipDeployExtra
)
if %ERRORLEVEL% neq 0 goto onError
:skipDeployExtra
Rem VC Environment Variables
echo "** Calling vcvars64.bat to get the VC env vars:"
call "%VCINSTALLDIR%\Auxiliary\Build\vcvars64.bat"
Rem VC Redist
echo "* copy VC Redist Runtime DLLs from %VCToolsRedistDir%/."
if "%BUILD_ARCH%" == "Win64" (
start "copy VC Redist x64" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%VCToolsRedistDir%/x64/Microsoft.VC143.CRT/"* "%MY_COLLECT_PATH%/"
start "copy VC OMP Redist x64" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%VCToolsRedistDir%/x64/Microsoft.VC143.OpenMP/"* "%MY_COLLECT_PATH%/"
) else (
start "copy VC Redist x86" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%VCToolsRedistDir%/x86/Microsoft.VC143.CRT/"* "%MY_COLLECT_PATH%/"
start "copy VC OMP Redist x86" /D "%MY_COLLECT_PATH%/" /B /wait cp -af "%VCToolsRedistDir%/x86/Microsoft.VC143.OpenMP/"* "%MY_COLLECT_PATH%/"
)
if %ERRORLEVEL% neq 0 goto onError
echo "* remove VC Redist installer(s) from %MY_COLLECT_PATH%/."
start "remove vc*redist*.exe" /D "%MY_COLLECT_PATH%/" /B /wait rm -f "%MY_COLLECT_PATH%"/vc*redist*.exe
Rem ********************************************************************************************
rem "code signing"
Rem ********************************************************************************************
if "%USE_CODE_SIGNING%" == "0" (
echo "** Don't sign: Code signing is disabled by USE_CODE_SIGNING"
) else (
echo "** Trying to find signtool in the PATH (VC env vars):"
for %%i in (signtool.exe) do @set SIGNTOOL=%%~$PATH:i
if "!SIGNTOOL!" == "" (
echo "** Unable to find signtool.exe in the PATH."
goto onError
) else (
echo "** Found signtool.exe: !SIGNTOOL!"
)
echo "** Code signing begins:"
for %%G in (
"NCContextMenu.dll"
"NCOverlays.dll"
"%APP_NAME_SANITIZED%.exe"
"%APP_NAME_SANITIZED%cmd.exe"
"%APP_NAME_SANITIZED%sync.dll"
"%APP_NAME_SANITIZED%_csync.dll"
"qt6keychain%DLL_SUFFIX%.dll"
"%LIBCRYPTO_DLL_FILENAME%"
"%LIBSSL_DLL_FILENAME%"
"zlib1%DLL_SUFFIX%.dll"
) do (
start "sign %%~G" /D "%PROJECT_PATH%/" /B /wait %~dp0/sign.bat "%MY_COLLECT_PATH%/%%~G"
if !ERRORLEVEL! neq 0 goto onError
)
echo "** Code signing ends."
)
Rem ********************************************************************************************
echo "*** Finished Build: installer-collect %BUILD_TYPE% %BUILD_ARCH% (%~nx0)"
exit 0
:onError
echo "*** Build FAILED: installer-collect %BUILD_TYPE% %BUILD_ARCH% (%~nx0)"
if %ERRORLEVEL% neq 0 exit %ERRORLEVEL%
if !ERRORLEVEL! neq 0 exit !ERRORLEVEL!
exit 1
:testEnv
if "!%*!" == "" (
echo "Missing environment variable: %*"
exit /B 1
)
exit /B
+229
View File
@@ -0,0 +1,229 @@
@echo off
REM SPDX-FileCopyrightText: 2019 Michael Schuster
REM SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
REM SPDX-License-Identifier: GPL-2.0-or-later
setlocal EnableDelayedExpansion
cls
Rem ********************************************************************************************
rem "MSI installer - build setup for Windows 64-bit or 32-bit"
Rem ********************************************************************************************
call "%~dp0/common.inc.bat" %1 %2 %CRAFT_TAG_DESKTOP%
Rem ********************************************************************************************
rem Reference: https://ss64.com/nt/setlocal.html
rem Reference: https://ss64.com/nt/start.html
echo "**** Build installer-msi for %BUILD_TYPE% %BUILD_ARCH% (%~nx0)."
Rem ********************************************************************************************
Rem MY_REPO is the Nextcloud desktop repository root.
set "MY_REPO=%DESKTOP_REPO_PATH%"
set "MY_BUILD_PATH=%MY_REPO%/build"
set "MY_INSTALL_PATH=%PROJECT_PATH%/install/%BUILD_TYPE%/%BUILD_ARCH%"
set "MY_COLLECT_PATH=%PROJECT_PATH%/collect/%BUILD_TYPE%/%BUILD_ARCH%"
set "MY_MSI_PATH=%MY_INSTALL_PATH%/msi"
echo "* BUILD_TYPE=%BUILD_TYPE%"
echo "* BUILD_ARCH=%BUILD_ARCH%"
echo "* PROJECT_PATH=%PROJECT_PATH%"
echo "* INSTALLER_OUTPUT_PATH=%INSTALLER_OUTPUT_PATH%"
echo "* Build date %BUILD_DATE%"
echo "* VERSION_SUFFIX %VERSION_SUFFIX%"
echo "* APPLICATION_VENDOR %APPLICATION_VENDOR%"
echo "* TAG_DESKTOP %TAG_DESKTOP%"
echo "* APPLICATION_NAME %APPLICATION_NAME%"
echo "* DESKTOP_REPO_PATH=%DESKTOP_REPO_PATH%"
echo "* MY_REPO=%MY_REPO%"
echo "* MY_BUILD_PATH=%MY_BUILD_PATH%"
echo "* MY_INSTALL_PATH=%MY_INSTALL_PATH%"
echo "* MY_COLLECT_PATH=%MY_COLLECT_PATH%"
echo "* MY_MSI_PATH=%MY_MSI_PATH%"
echo "* WIX=%WIX%"
echo "* PATH=%PATH%"
echo "* USE_CODE_SIGNING=%USE_CODE_SIGNING%"
echo "* USE_SECOND_CODE_SIGNING=%USE_SECOND_CODE_SIGNING%"
echo "* UPLOAD_BUILD=%UPLOAD_BUILD%"
Rem ********************************************************************************************
rem "check for required environment variables"
Rem ********************************************************************************************
call :testEnv PROJECT_PATH
call :testEnv INSTALLER_OUTPUT_PATH
call :testEnv BUILD_TYPE
call :testEnv BUILD_ARCH
call :testEnv BUILD_DATE
call :testEnv WIX
if "%USE_CODE_SIGNING%" == "1" (
call :testEnv VCINSTALLDIR
call :testEnv APPLICATION_VENDOR
call :testEnv TAG_DESKTOP
call :testEnv APPLICATION_NAME
call :testEnv CERTIFICATE_FILENAME
call :testEnv CERTIFICATE_CSP
call :testEnv CERTIFICATE_KEY_CONTAINER_NAME
call :testEnv CERTIFICATE_PASSWORD
call :testEnv SIGN_FILE_DIGEST_ALG
call :testEnv SIGN_TIMESTAMP_URL
call :testEnv SIGN_TIMESTAMP_DIGEST_ALG
if "%USE_SECOND_CODE_SIGNING%" == "1" (
call :testEnv SECOND_CERTIFICATE_FILENAME
call :testEnv SECOND_CERTIFICATE_CSP
call :testEnv SECOND_CERTIFICATE_KEY_CONTAINER_NAME
call :testEnv SECOND_CERTIFICATE_PASSWORD
call :testEnv SECOND_SIGN_FILE_DIGEST_ALG
call :testEnv SECOND_SIGN_TIMESTAMP_URL
call :testEnv SECOND_SIGN_TIMESTAMP_DIGEST_ALG
)
)
if %ERRORLEVEL% neq 0 goto onError
Rem ********************************************************************************************
rem "Test run?"
Rem ********************************************************************************************
if "%TEST_RUN%" == "1" (
echo "** TEST RUN - exit."
exit
)
Rem ********************************************************************************************
rem "build MSI installer"
Rem ********************************************************************************************
rem Reference: https://ss64.com/nt/setlocal.html
rem Reference: https://ss64.com/nt/start.html
Rem Create output directory for the Installer
if not exist "%INSTALLER_OUTPUT_PATH%" (
echo "* Create output directory for the Installer: %INSTALLER_OUTPUT_PATH% (recursive)."
start "mkdir %INSTALLER_OUTPUT_PATH%" /D "%PROJECT_PATH%/" /B /wait "%WIN_GIT_PATH%\usr\bin\mkdir.exe" -p "%INSTALLER_OUTPUT_PATH%"
)
if %ERRORLEVEL% neq 0 goto onError
if "%BUILD_ARCH%" == "Win32" (
set "BITNESS=32"
) else (
set "BITNESS=64"
)
Rem VC Environment Variables
echo "** Calling vcvars64.bat to get the VC env vars:"
call "%VCINSTALLDIR%\Auxiliary\Build\vcvars64.bat"
Rem ********************************************************************************************
rem "code signing"
Rem ********************************************************************************************
if "%USE_CODE_SIGNING%" == "0" (
echo "** Don't sign: Code signing is disabled by USE_CODE_SIGNING"
) else (
echo "** Trying to find signtool in the PATH (VC env vars):"
for %%i in (signtool.exe) do @set "SIGNTOOL=%%~$PATH:i"
if "!SIGNTOOL!" == "" (
echo "** Unable to find signtool.exe in the PATH."
goto onError
) else (
echo "** Found signtool.exe: !SIGNTOOL!"
)
echo "** Signing helper DLL:"
for %%G in (
"NCMsiHelper%BITNESS%.dll"
) do (
start "sign %%~G" /D "%PROJECT_PATH%/" /B /wait %~dp0/sign.bat "%MY_MSI_PATH%/%%~G"
if !ERRORLEVEL! neq 0 goto onError
)
echo "** Code signing ends."
)
REM WiSubStg.vbs is part of the Windows Installer SDK and available with vcvars64.bat
REM It will be used for embedding extra locales in the MSI.
echo ** Trying to find WiSubStg.vbs in PATH ^(VC env vars^)
for %%i in (WiSubStg.vbs) do @set "WISUBSTG=%%~$PATH:i"
if "!WISUBSTG!" == "" (
echo ** Did not find WiSubStg.vbs -- the resulting MSI will be only in English
) else (
echo ** Found WiSubStg.vbs: !WISUBSTG!
REM WiLangId.vbs ^(also part of the Windows Installer SDK^) is used to update the
REM language IDs used in the installer.
echo ** Trying to find WiLangId.vbs in PATH ^(VC env vars^)
for %%i in (WiLangId.vbs) do @set "WILANGID=%%~$PATH:i"
if "!WILANGID!" == "" (
echo ** Did not find WiLangId.vbs -- the resulting MSI will only be in English
) else (
echo ** Found WiLangId.vbs: !WILANGID!
)
)
echo "* Run MSI build script with parameter '%MY_COLLECT_PATH%' to create installer."
start "make-msi.bat" /D "%MY_MSI_PATH%" /B /wait call make-msi.bat "%MY_COLLECT_PATH%"
if %ERRORLEVEL% neq 0 goto onError
Rem Find MSI, get filename
for /f "delims=" %%a in ('dir /b "%MY_MSI_PATH%"\*.msi') do (
set "MSI_FILENAME=%%a"
)
if "%USE_CODE_SIGNING%" == "0" (
echo "** Don't sign: Code signing is disabled by USE_CODE_SIGNING"
) else (
echo "** Signing %MSI_FILENAME%:"
for %%G in (
"%MSI_FILENAME%"
) do (
start "sign %%~G" /D "%PROJECT_PATH%/" /B /wait %~dp0/sign.bat "%MY_MSI_PATH%/%%~G"
if !ERRORLEVEL! neq 0 goto onError
)
echo "** Code signing ends."
)
echo "* Move %MSI_FILENAME% to '%INSTALLER_OUTPUT_PATH%'."
start "move msi" /D "%MY_MSI_PATH%" /B /wait mv "%MSI_FILENAME%" "%INSTALLER_OUTPUT_PATH%"/
if %ERRORLEVEL% neq 0 goto onError
if "%UPLOAD_BUILD%" == "0" (
echo "** Don't upload: Uploading is disabled by UPLOAD_BUILD"
) else (
echo "* Upload %MSI_FILENAME%."
start "upload msi" /D "%PROJECT_PATH%" /B /wait %~dp0/upload.bat %INSTALLER_OUTPUT_PATH%/%MSI_FILENAME%
)
Rem ********************************************************************************************
echo "**** Finished Build: installer-msi %BUILD_TYPE% %BUILD_ARCH% (%~nx0)"
exit 0
:onError
echo "**** Build FAILED: installer-msi %BUILD_TYPE% %BUILD_ARCH% (%~nx0)"
if %ERRORLEVEL% neq 0 exit %ERRORLEVEL%
if !ERRORLEVEL! neq 0 exit !ERRORLEVEL!
exit 1
:testEnv
if "!%*!" == "" (
echo "Missing environment variable: %*"
exit /B 1
)
exit /B
+6
View File
@@ -0,0 +1,6 @@
#!/bin/sh
# SPDX-FileCopyrightText: 2019 Michael Schuster
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: GPL-2.0-or-later
./task-build-log.bat $1
exit $?
+24
View File
@@ -0,0 +1,24 @@
@echo off
REM SPDX-FileCopyrightText: 2019 Michael Schuster
REM SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
REM SPDX-License-Identifier: GPL-2.0-or-later
call "%~dp0/defaults.inc.bat" %1
call "%~dp0/datetime.inc.bat"
set DATE_START=%_date% %_time%
set DATE_START_SANE=%_date%-%_time:~0,2%-%_time:~3,2%-%_time:~6,2%
set LOG_PATH=%PROJECT_PATH%/logs
set LOG_FILE=%LOG_PATH%/last-build-%DATE_START_SANE%-%BUILD_TYPE%.log
if not exist "%LOG_PATH%" mkdir "%LOG_PATH%"
echo --- START: %0 - %DATE_START% ---> "%LOG_FILE%"
REM set TEST_RUN=1
start "build.bat %BUILD_TYPE%" /D "%PROJECT_PATH%/" /B /wait "%~dp0/build.bat" %BUILD_TYPE% >> "%LOG_FILE%" 2>&1
set RESULT=%ERRORLEVEL%
call "%~dp0/datetime.inc.bat"
set DATE_END=%_date% %_time%
echo --- END: %0 - %DATE_END% --->> "%LOG_FILE%"
exit %RESULT%
+86
View File
@@ -0,0 +1,86 @@
@echo off
REM SPDX-FileCopyrightText: 2019 Michael Schuster
REM SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
REM SPDX-License-Identifier: GPL-2.0-or-later
setlocal EnableDelayedExpansion
cls
Rem ********************************************************************************************
rem "upload a build artifact via SCP"
Rem ********************************************************************************************
call "%~dp0/defaults.inc.bat"
Rem ********************************************************************************************
echo "*** Upload file: %~1%."
if "%1" == "" (
echo "Missing parameter: Please specify file to upload (in quotes)"
exit 1
)
Rem ********************************************************************************************
echo "* PROJECT_PATH=%PROJECT_PATH%"
echo "* SFTP_PATH=%SFTP_PATH%"
echo "* SFTP_SERVER=%SFTP_SERVER%"
echo "* SFTP_USER=%SFTP_USER%"
echo "* UPLOAD_BUILD=%UPLOAD_BUILD%"
echo "* UPLOAD_DELETE=%UPLOAD_DELETE%"
echo "* PATH=%PATH%"
Rem ********************************************************************************************
rem "check for required environment variables"
Rem ********************************************************************************************
call :testEnv PROJECT_PATH
call :testEnv SFTP_PATH
call :testEnv SFTP_SERVER
call :testEnv SFTP_USER
if %ERRORLEVEL% neq 0 goto onError
Rem ********************************************************************************************
rem "upload"
Rem ********************************************************************************************
rem Reference: https://ss64.com/nt/setlocal.html
rem Reference: https://ss64.com/nt/start.html
if "%UPLOAD_BUILD%" == "0" (
echo "** Abort upload: Uploading is disabled by UPLOAD_BUILD"
exit
)
set PATHTOEXEFILE=%1
set EXEFILENAME=%~nx1
set SSH_KEYFILE=%USERPROFILE%\.ssh\id_rsa
echo "* Upload installer."
start "upload" /D "%PROJECT_PATH%" /B /wait scp -i "%SSH_KEYFILE%" "%PATHTOEXEFILE%" %SFTP_USER%@%SFTP_SERVER%:"%SFTP_PATH%"/"%EXEFILENAME%" > "%PROJECT_PATH%\last_daily_upload.log" 2>&1
if %ERRORLEVEL% neq 0 goto onError
if "%UPLOAD_DELETE%" == "1" (
echo "* Delete installer after successful upload."
start "rm installer" /D "%PROJECT_PATH%" /B /wait rm "%PATHTOEXEFILE%"
)
if %ERRORLEVEL% neq 0 goto onError
Rem ********************************************************************************************
echo "*** Finished upload file: %~1%"
exit %ERRORLEVEL%
:onError
echo "*** Upload FAILED for file: %~1%"
exit %ERRORLEVEL%
:testEnv
if "!%*!" == "" (
echo "Missing environment variable: %*"
exit /B 1
)
exit /B
@@ -57,6 +57,12 @@
</Component>
<Component Id="NCOverlays" Guid="*" Win64="$(var.PlatformWin64)">
<!--
Explorer only reads ShellIconOverlayIdentifiers from HKLM, which a per-user installation cannot write:
only install the overlays for per-machine installations
(keep in sync with PerUserInstall in Nextcloud.wxs)
-->
<Condition>NOT (NOT ALLUSERS OR (ALLUSERS=2 AND MSIINSTALLPERUSER=1))</Condition>
<File Id="NCOverlays.dll" KeyPath="yes" Source="$(var.HarvestAppDir)\NCOverlays.dll">
<Class Id="$(var.OverlayGuidError)" Context="InprocServer32" Description="$(var.OverlayDescription)" ThreadingModel="apartment" Version="1.0" />
<Class Id="$(var.OverlayGuidOK)" Context="InprocServer32" Description="$(var.OverlayDescription)" ThreadingModel="apartment" Version="1.0" />