MFC 1.3 · Шаг 6. Установщик и переносимая папка

Что будет сделано на этой странице. Вы соберёте из своих программ установщик TMC_Suite_Setup.exe по скрипту installer\TMC_Suite.iss из репозитория (программой Inno Setup 6) — или, если установщик не нужен, сделаете переносимую папку / ZIP-архив, который можно просто скопировать на другой компьютер.

Этот шаг необязателен: для работы на своём компьютере достаточно программ из dist\<платформа>\bin (шаг 5).


6.1 Что кладёт в установщик скрипт installer\TMC_Suite.iss

Скрипт есть в репозитории (версия установщика в нём — 1.3). Пути в нём заданы от корня проекта (строка SourceDir=..). Он упаковывает:

Что Откуда берётся (от корня проекта) Куда ставится Есть в репозитории?
64-битные программы dist\win64\bin\* (без *.pdb, *.idb, *.ilk) {app}\bin\win64 нет — создаёт сборка Release x64
32-битные программы dist\win32\bin\* (без *.pdb, *.idb, *.ilk) {app}\bin\win32 нет — создаёт сборка Release Win32
Руководство пользователя (HTML) docs\user-manual\sphinx\_build\html\* {app}\docs\user-manual нет
Образцы заданий samples\SAMPLE_R\* {app}\samples\SAMPLE_R нет
Лицензии installer\LICENSE_ru.txt, LICENSE, NOTICE {app} да
Картинки мастера, значок, логотипы installer\assets\* (внутри установщика) да

{app} — папка установки, по умолчанию C:\Program Files\TMC Suite.

Кроме копирования файлов, установщик (по тексту скрипта):

  • спрашивает, какую версию ставить: 64-битную, 32-битную или обе;
  • создаёт ярлыки в меню «Пуск» (папка TMC Suite) и, по галочке, на рабочем столе;
  • записывает в реестр путь установки (HKLM\Software\TMC Suite\InstallPath, Version) и заранее прописывает ядрам пути к вьюверам (раздел HKCU\Software\PlanarRT_H\… и HKCU\Software\PlanarRT_X\…), чтобы ядро не спрашивало их при первом вызове;
  • даёт группе «Пользователи» право изменения папки {app}, чтобы задания из {app}\samples можно было считать без прав администратора;
  • требует прав администратора при установке (PrivilegesRequired=admin).

Visual C++ Redistributable установщик не ставит и не требует: программы собраны со статической MFC (/MT).


6.2 Почему из одних исходников GitHub установщик сразу не собирается

Папок docs\ и samples\ в репозитории нет, а скрипт требует, чтобы в них были файлы. Если запустить компиляцию на чистых исходниках (даже после сборки программ), Inno Setup остановится с ошибкой (проверено):

Error on line 97 in C:\src\TMC_Suite\installer\TMC_Suite.iss: No files found matching "C:\src\TMC_Suite\docs\user-manual\sphinx\_build\html\*"
Compile aborted.

а если положить только руководство, но не образцы, —

Error on line 99 in C:\src\TMC_Suite\installer\TMC_Suite.iss: No files found matching "C:\src\TMC_Suite\samples\SAMPLE_R\*"

Поэтому перед компиляцией нужно самостоятельно положить что-то в обе папки (пункт 6.4). Сам скрипт менять не нужно.


6.3 Соберите обе разрядности Release

Установщик берёт обе папки программ, dist\win64\bin и dist\win32\bin. Если какой-то нет, будет ошибка вида Error on line 95 … No files found matching "…\dist\win32\bin\*" (проверено). Debug-сборки в установщик не попадают.

В Developer PowerShell, в корне проекта:

cd C:\src\TMC_Suite
msbuild src\tamic.slnx /m /t:Rebuild /p:Configuration=Release /p:Platform=x64
msbuild src\tamic.slnx /m /t:Rebuild /p:Configuration=Release /p:Platform=Win32

(или в Visual Studio — см. шаг 3).


6.4 Положите руководство и образцы заданий

Руководство пользователя → C:\src\TMC_Suite\docs\user-manual\sphinx\_build\html\

Ярлык меню «Пуск» «Руководство пользователя» открывает файл index.html из этой папки, поэтому в ней должен быть как минимум index.html.

  • Если у вас есть HTML-версия руководства пользователя — скопируйте всё её содержимое (index.html и остальные файлы и папки) в эту папку.
  • Если нет — сделайте страницу-ссылку на сайт с документацией:

    1. Создайте папки по пути C:\src\TMC_Suite\docs\user-manual\sphinx\_build\html (в Проводнике по одной: docs → user-manual → sphinx → _build → html).
    2. Откройте Блокнот, вставьте текст:

      <!DOCTYPE html>
      <html><head><meta charset="utf-8"><title>TMC Suite</title></head>
      <body><p>Documentation: <a href="https://www.tamic.ru">www.tamic.ru</a></p></body></html>
      
    3. Файл → Сохранить как… → папка …\_build\html → Тип файла: Все файлы (*.*) → имя index.html → Сохранить.

Образцы заданий → C:\src\TMC_Suite\samples\SAMPLE_R\

  1. Создайте папки C:\src\TMC_Suite\samples\SAMPLE_R.
  2. Положите туда задания .tpl, которые хотите раздавать вместе с программой, — хотя бы пробное test1.tpl из шага 5. Подпапки допускаются, они копируются целиком.
  3. Если у вас установлен TMC Suite 1.3 из официального установщика (раздел Releases), можно скопировать его образцы: из C:\Program Files\TMC Suite\samples\SAMPLE_R в C:\src\TMC_Suite\samples\SAMPLE_R.

Обе папки указаны в .gitignore, git не будет предлагать их добавить.


6.5 Компиляция установщика

Вариант 1: в окне Inno Setup

  1. Запустите Inno Setup Compiler из меню «Пуск».
  2. Если откроется окно Welcome — закройте его кнопкой Cancel (или выберите Open an existing script file).
  3. File → Open… → выберите C:\src\TMC_Suite\installer\TMC_Suite.iss → Открыть.
  4. Build → Compile (клавиши Ctrl+F9).
  5. Внизу окна, в журнале компиляции, в конце должна появиться строка Successful compile (… sec). Resulting Setup program filename is: и путь к файлу. Если Inno Setup предложит запустить получившийся установщик (Run) — можно отказаться.

Вариант 2: из командной строки

В любом окне PowerShell (Developer не обязателен):

cd C:\src\TMC_Suite
& "${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe" installer\TMC_Suite.iss

Если Inno Setup ставился «только для меня», путь к компилятору другой:

& "$env:LOCALAPPDATA\Programs\Inno Setup 6\ISCC.exe" installer\TMC_Suite.iss

Успех — последние строки вывода:

Successful compile (11,453 sec). Resulting Setup program filename is:
C:\src\TMC_Suite\installer\Output\TMC_Suite_Setup.exe

и $LASTEXITCODE равен 0 (при ошибке — 2). Строку Non-commercial use only в начале вывода печатает сам Inno Setup 6.7; условия лицензии Inno Setup смотрите на https://jrsoftware.org.

Ключ /DDistDir=<папка> позволяет взять программы не из dist, а из другой папки с той же структурой (<папка>\win64\bin, <папка>\win32\bin; путь от корня проекта), например: ISCC.exe /DDistDir=dist_test installer\TMC_Suite.iss.

Результат

  • Файл: C:\src\TMC_Suite\installer\Output\TMC_Suite_Setup.exe (папка installer\Output указана в .gitignore).
  • Замер: компиляция — 11,5 с; размер установщика с пробным заданием и страницей-ссылкой вместо руководства — 10,2 МБ. С полным руководством и образцами он больше (официальный установщик 1.3 в Releases — около 31,8 МБ).

Проверьте установщик: запустите его, пройдите мастер (выбор папки → выбор версии → установка), затем откройте из меню «Пуск» → TMC Suite любую программу.


6.6 Переносимая папка без установщика

Если установщик не нужен, программы можно просто скопировать: им не нужны ни установка, ни Visual C++ Redistributable, ни запись в реестр.

Команды (в PowerShell, в корне проекта, после сборки Release x64 и Release Win32) создают папку и ZIP-архив той же структуры, что и архивы TMC_Suite_v1.3_*.zip в Releases (dist\win32\bin, dist\win64\bin):

cd C:\src\TMC_Suite
$dst = "C:\TMC_Suite_1.3_portable"
foreach ($p in 'win64','win32') {
  New-Item -ItemType Directory -Force "$dst\dist\$p\bin" | Out-Null
  Copy-Item "dist\$p\bin\*.exe" "$dst\dist\$p\bin\"
}
Copy-Item LICENSE, NOTICE $dst
Compress-Archive -Path $dst -DestinationPath "C:\TMC_Suite_1.3_portable.zip" -Force

Результат (проверено): папка C:\TMC_Suite_1.3_portable с 14 файлами (6 + 6 программ, LICENSE, NOTICE) и архив C:\TMC_Suite_1.3_portable.zip около 22,8 МБ. Файлы .pdb не копируются — они не нужны для работы. Если нужна только одна разрядность, оставьте в foreach одно значение: 'win64' или 'win32'.

Чем переносимая папка отличается от установки:

  • нет ярлыков в меню «Пуск» — запускайте .exe из папки;
  • ядро при первом вызове вьювера (меню View) спросит, где лежит программа вьювера: укажите файл из той же папки bin той же разрядности (подробнее — шаг 5, пункт 5.5);
  • не кладите папку в C:\Program Files: ядро пишет результаты рядом с заданием, а туда обычному пользователю писать нельзя. Подойдёт, например, C:\TMC_Suite_1.3_portable или флешка.

Дальше — Шаг 7. Ошибки и их решение.

MFC 1.3 · Step 6. Installer and portable folder

What this page covers. You will build from your programs the installer TMC_Suite_Setup.exe using the installer\TMC_Suite.iss script from the repository (with Inno Setup 6) — or, if you do not need an installer, you will make a portable folder / ZIP archive that can simply be copied to another computer.

This step is optional: to work on your own computer, the programs from dist\<platform>\bin are enough (step 5).


6.1 What the installer\TMC_Suite.iss script puts into the installer

The script is in the repository (the installer version in it is 1.3). The paths in it are relative to the project root (the line SourceDir=..). It packages:

What Where it comes from (relative to the project root) Where it is installed In the repository?
64-bit programs dist\win64\bin\* (without *.pdb, *.idb, *.ilk) {app}\bin\win64 no — created by the Release x64 build
32-bit programs dist\win32\bin\* (without *.pdb, *.idb, *.ilk) {app}\bin\win32 no — created by the Release Win32 build
User manual (HTML) docs\user-manual\sphinx\_build\html\* {app}\docs\user-manual no
Sample task files samples\SAMPLE_R\* {app}\samples\SAMPLE_R no
Licenses installer\LICENSE_ru.txt, LICENSE, NOTICE {app} yes
Wizard images, icon, logos installer\assets\* (inside the installer) yes

{app} is the installation folder, by default C:\Program Files\TMC Suite.

Besides copying files, the installer (according to the script text):

  • asks which version to install: 64-bit, 32-bit or both;
  • creates shortcuts in the Start menu (the TMC Suite folder) and, if the checkbox is set, on the desktop;
  • writes the installation path to the registry (HKLM\Software\TMC Suite\InstallPath, Version) and presets the paths to the viewers for the kernels (the keys HKCU\Software\PlanarRT_H\… and HKCU\Software\PlanarRT_X\…), so that the kernel does not ask for them on the first call;
  • gives the Users group modify permission on the {app} folder, so that the task files from {app}\samples can be computed without administrator rights;
  • requires administrator rights for installation (PrivilegesRequired=admin).

The installer neither installs nor requires the Visual C++ Redistributable: the programs are built with static MFC (/MT).


6.2 Why the installer does not build from the GitHub sources alone

The docs\ and samples\ folders are not in the repository, while the script requires files in them. If you start the compilation on clean sources (even after building the programs), Inno Setup stops with an error (verified):

Error on line 97 in C:\src\TMC_Suite\installer\TMC_Suite.iss: No files found matching "C:\src\TMC_Suite\docs\user-manual\sphinx\_build\html\*"
Compile aborted.

and if you add only the manual but not the samples —

Error on line 99 in C:\src\TMC_Suite\installer\TMC_Suite.iss: No files found matching "C:\src\TMC_Suite\samples\SAMPLE_R\*"

Therefore, before compiling you need to put something into both folders yourself (section 6.4). The script itself does not need to be changed.


6.3 Build Release for both bitnesses

The installer takes both program folders, dist\win64\bin and dist\win32\bin. If one of them is missing, you get an error like Error on line 95 … No files found matching "…\dist\win32\bin\*" (verified). Debug builds are not included in the installer.

In Developer PowerShell, in the project root:

cd C:\src\TMC_Suite
msbuild src\tamic.slnx /m /t:Rebuild /p:Configuration=Release /p:Platform=x64
msbuild src\tamic.slnx /m /t:Rebuild /p:Configuration=Release /p:Platform=Win32

(or in Visual Studio — see step 3).


6.4 Add the user manual and sample task files

User manual → C:\src\TMC_Suite\docs\user-manual\sphinx\_build\html\

The Start menu shortcut Руководство пользователя (User manual) opens the file index.html from this folder, so it must contain at least index.html.

  • If you have an HTML version of the user manual, copy all its contents (index.html and the other files and folders) into this folder.
  • If not, make a page with a link to the documentation website:

    1. Create the folders along the path C:\src\TMC_Suite\docs\user-manual\sphinx\_build\html (in File Explorer, one at a time: docs → user-manual → sphinx → _build → html).
    2. Open Notepad and paste the text:

      <!DOCTYPE html>
      <html><head><meta charset="utf-8"><title>TMC Suite</title></head>
      <body><p>Documentation: <a href="https://www.tamic.ru">www.tamic.ru</a></p></body></html>
      
    3. File → Save As… → folder …\_build\html → Save as type: All Files (*.*) → name index.html → Save.

Sample task files → C:\src\TMC_Suite\samples\SAMPLE_R\

  1. Create the folders C:\src\TMC_Suite\samples\SAMPLE_R.
  2. Put there the .tpl task files you want to distribute together with the program — at least the test file test1.tpl from step 5. Subfolders are allowed; they are copied as a whole.
  3. If you have TMC Suite 1.3 installed from the official installer (the Releases section), you can copy its samples: from C:\Program Files\TMC Suite\samples\SAMPLE_R to C:\src\TMC_Suite\samples\SAMPLE_R.

Both folders are listed in .gitignore; git will not offer to add them.


6.5 Compiling the installer

Variant 1: in the Inno Setup window

  1. Start Inno Setup Compiler from the Start menu.
  2. If the Welcome window opens, close it with the Cancel button (or choose Open an existing script file).
  3. File → Open… → choose C:\src\TMC_Suite\installer\TMC_Suite.iss → Open.
  4. Build → Compile (keys Ctrl+F9).
  5. At the bottom of the window, in the compilation log, the line Successful compile (… sec). Resulting Setup program filename is: and the path to the file should appear at the end. If Inno Setup offers to run the resulting installer (Run), you can decline.

Variant 2: from the command line

In any PowerShell window (Developer is not required):

cd C:\src\TMC_Suite
& "${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe" installer\TMC_Suite.iss

If Inno Setup was installed “for me only”, the path to the compiler is different:

& "$env:LOCALAPPDATA\Programs\Inno Setup 6\ISCC.exe" installer\TMC_Suite.iss

Success — the last lines of the output:

Successful compile (11,453 sec). Resulting Setup program filename is:
C:\src\TMC_Suite\installer\Output\TMC_Suite_Setup.exe

and $LASTEXITCODE equals 0 (on error — 2). The line Non-commercial use only at the beginning of the output is printed by Inno Setup 6.7 itself; for the Inno Setup license terms, see https://jrsoftware.org.

The /DDistDir=<folder> switch lets you take the programs not from dist but from another folder with the same structure (<folder>\win64\bin, <folder>\win32\bin; the path is relative to the project root), for example: ISCC.exe /DDistDir=dist_test installer\TMC_Suite.iss.

Result

  • File: C:\src\TMC_Suite\installer\Output\TMC_Suite_Setup.exe (the installer\Output folder is listed in .gitignore).
  • Measurement: compilation — 11.5 s; the size of the installer with the test task file and the link page instead of the manual — 10.2 MB. With the full manual and samples it is larger (the official installer 1.3 in Releases is about 31.8 MB).

Check the installer: run it, go through the wizard (folder choice → version choice → installation), then open any program from the Start menu → TMC Suite.


6.6 Portable folder without an installer

If you do not need an installer, the programs can simply be copied: they need neither installation, nor the Visual C++ Redistributable, nor registry entries.

The commands (in PowerShell, in the project root, after building Release x64 and Release Win32) create a folder and a ZIP archive with the same structure as the TMC_Suite_v1.3_*.zip archives in Releases (dist\win32\bin, dist\win64\bin):

cd C:\src\TMC_Suite
$dst = "C:\TMC_Suite_1.3_portable"
foreach ($p in 'win64','win32') {
  New-Item -ItemType Directory -Force "$dst\dist\$p\bin" | Out-Null
  Copy-Item "dist\$p\bin\*.exe" "$dst\dist\$p\bin\"
}
Copy-Item LICENSE, NOTICE $dst
Compress-Archive -Path $dst -DestinationPath "C:\TMC_Suite_1.3_portable.zip" -Force

Result (verified): the folder C:\TMC_Suite_1.3_portable with 14 files (6 + 6 programs, LICENSE, NOTICE) and the archive C:\TMC_Suite_1.3_portable.zip of about 22.8 MB. The .pdb files are not copied — they are not needed to run the programs. If you need only one bitness, leave one value in foreach: 'win64' or 'win32'.

How a portable folder differs from an installation:

  • there are no Start menu shortcuts — start the .exe files from the folder;
  • on the first call of a viewer (the View menu), the kernel asks where the viewer program is: specify the file from the same bin folder of the same bitness (for details, see step 5, section 5.5);
  • do not put the folder into C:\Program Files: the kernel writes the results next to the task file, and a regular user cannot write there. For example, C:\TMC_Suite_1.3_portable or a USB flash drive will do.

Next — Step 7. Errors and their solutions.