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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions WINDOWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ You can build Fedora Media Writer yourself. It has just a few dependencies and b
### Dependencies

* `Qt6` (`qtbase`, `qtdeclarative`, `qtsvg` and `qtquickcontrols2`) - already part of the installer
* `Microsoft Visual C++ Redistributable` for C++ (MSVC) runtime libraries
* `Microsoft Visual C++ Redistributable` for C++ (MSVC) runtime libraries - the installer will prompt you to install this if it's not already on your system

### Steps

Expand All @@ -42,4 +42,35 @@ make

### Crosscompilation

There is also the [build.sh](/dist/win/build.sh) script included that I use for building a the installer for distribution on this site. It should do everything automatically if you're in Fedora. There are instructions on how to use it inside at the top of the file
There is also the [build.sh](/dist/win/build.sh) script included that I use for building a the installer for distribution on this site. It should do everything automatically if you're in Fedora. There are instructions on how to use it inside at the top of the file.

#### Visual C++ Redistributable Installation

The installer handles the [Microsoft Visual C++ Redistributable (2015-2022)](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170) installation on-demand, which is required for the application to run.

**How it works:**
1. During installation, the installer checks if VC++ Redistributable is already installed
2. If not installed, it prompts the user with a Yes/No dialog:
```
Microsoft Visual C++ Redistributable is not installed on your system.

It is required for Fedora Media Writer to run properly.

Would you like to download and install it now? (approximately 25 MB)
```
3. If the user chooses **"Yes"**:
- Downloads `vc_redist.x64.exe` from Microsoft's official servers
- Installs it automatically with a progress bar (`/passive` mode)
- Cleans up the downloaded file
4. If the user chooses **"No"**:
- Shows a message with a direct download link for manual installation later

**Benefits:**
- Smaller installer size (no bundled redistributable)
- Only downloads when needed
- Always gets the latest version from Microsoft
- Requires internet connection during installation if VC++ is not already installed

**Manual installation:**
If you prefer to install it separately or if the download fails, you can download it manually from:
https://aka.ms/vs/17/release/vc_redist.x64.exe
21 changes: 21 additions & 0 deletions dist/win/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,27 @@ fi
popd >/dev/null
popd >/dev/null

echo "=== Downloading VC++ Redistributable for bundling"
VCREDIST_URL="https://aka.ms/vs/17/release/vc_redist.x64.exe"
VCREDIST_FILE="$SCRIPTDIR/vc_redist.x64.exe"

if [ ! -f "$VCREDIST_FILE" ]; then
echo "Downloading Visual C++ Redistributable..."
curl -L -o "$VCREDIST_FILE" "$VCREDIST_URL"
if [ $? -ne 0 ]; then
echo "Warning: Failed to download VC++ Redistributable."
echo "You can manually download it from: $VCREDIST_URL"
echo "Place it at: $VCREDIST_FILE"
echo ""
echo "Continuing build without bundled VC++ Redistributable..."
else
echo "VC++ Redistributable downloaded successfully ($(du -h "$VCREDIST_FILE" | cut -f1))"
fi
else
echo "VC++ Redistributable already exists at $VCREDIST_FILE ($(du -h "$VCREDIST_FILE" | cut -f1))"
echo "Using existing file. Delete it to re-download the latest version."
fi

echo "=== Composing installer"
unix2dos < "$ROOTPATH/LICENSE.GPL-2" > "$BUILDPATH/app/release/LICENSE.GPL-2.txt"
unix2dos < "$ROOTPATH/LICENSE.LGPL-2" > "$BUILDPATH/app/release/LICENSE.LGPL-2.txt"
Expand Down
84 changes: 84 additions & 0 deletions dist/win/mediawriter.nsi
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
!include "MUI2.nsh"
!include LogicLib.nsh
!include nsDialogs.nsh
!include WinMessages.nsh
ManifestDPIAware true
XPStyle on

Expand All @@ -18,6 +21,10 @@ XPStyle on
!define DESCRIPTION "Tool to write Fedora images to flash drives"
!define FULLVERSION "${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}.0"

# VC++ Redistributable configuration
!define VCREDIST_FILE "vc_redist.x64.exe"
!define VCREDIST_URL "https://aka.ms/vs/17/release/vc_redist.x64.exe"

Name "${APPNAME}"
Caption "${APPNAME} ${FULLVERSION}"

Expand Down Expand Up @@ -87,6 +94,10 @@ Icon "../../src/app/data/icons/mediawriter.ico"

!define MUI_ICON ../../src/app/data/icons/mediawriter.ico

# VC++ Redistributable configuration
!define VCREDIST_FILE "vc_redist.x64.exe"
!define VCREDIST_URL "https://aka.ms/vs/17/release/vc_redist.x64.exe"

!insertmacro MUI_PAGE_LICENSE "../../build/app/release/LICENSE.GPL-2.txt"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
Expand Down Expand Up @@ -268,6 +279,12 @@ LangString AdmingRightsRequired ${LANG_TURKISH} "Admin rights requi
LangString AdmingRightsRequired ${LANG_UKRAINIAN} "Admin rights required!"
LangString AdmingRightsRequired ${LANG_UZBEK} "Admin rights required!"

LangString VCRedistNotInstalled ${LANG_ENGLISH} "Microsoft Visual C++ Redistributable is not installed on your system.$\n$\nIt is required for ${APPNAME} to run properly.$\n$\nWould you like to download and install it now? (approximately 25 MB)"
LangString VCRedistDownloading ${LANG_ENGLISH} "Downloading Microsoft Visual C++ Redistributable..."
LangString VCRedistInstalling ${LANG_ENGLISH} "Installing Microsoft Visual C++ Redistributable..."
LangString VCRedistDownloadFailed ${LANG_ENGLISH} "Failed to download Visual C++ Redistributable.$\n$\nPlease check your internet connection and try again,$\nor download it manually from:$\nhttps://aka.ms/vs/17/release/vc_redist.x64.exe"
LangString VCRedistSkipped ${LANG_ENGLISH} "You have chosen to skip the Visual C++ Redistributable installation.$\n$\n${APPNAME} may not work correctly without it.$\n$\nYou can download it manually from:$\nhttps://aka.ms/vs/17/release/vc_redist.x64.exe"

!macro VerifyUserIsAdmin
UserInfo::GetAccountType
pop $0
Expand All @@ -278,6 +295,44 @@ ${If} $0 != "admin" ;Require admin rights on NT4+
${EndIf}
!macroend

; Function to detect if VC++ Redistributable 2015-2022 is installed
; Returns: 1 if installed, 0 if not installed (in $R0)
Function CheckVCRedist
Push $0
Push $1

; Default to not installed
StrCpy $R0 "0"

ClearErrors
; Check the primary registry location for x64 VC++ 2015-2022
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed"
${If} $0 == "1"
StrCpy $R0 "1"
Goto vcredist_check_done
${EndIf}

ClearErrors
; Check alternative registry location
ReadRegStr $0 HKLM "SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed"
${If} $0 == "1"
StrCpy $R0 "1"
Goto vcredist_check_done
${EndIf}

ClearErrors
; Check older registry location
ReadRegDWORD $1 HKLM "SOFTWARE\Microsoft\DevDiv\VC\Servicing\14.0\RuntimeMinimum" "Install"
${If} $1 == "1"
StrCpy $R0 "1"
Goto vcredist_check_done
${EndIf}

vcredist_check_done:
Pop $1
Pop $0
FunctionEnd

function .onInit
!ifdef INNER

Expand All @@ -291,6 +346,35 @@ function .onInit

setShellVarContext all
!insertmacro VerifyUserIsAdmin

; Prompt user about VC++ Redistributable BEFORE main installation
MessageBox MB_YESNO|MB_ICONQUESTION "$(VCRedistNotInstalled)" IDYES install_vcredist_init IDNO skip_vcredist_init

install_vcredist_init:
InitPluginsDir
DetailPrint "$(VCRedistInstalling)"

; Extract bundled VC++ Redistributable to temp directory
File /oname=$TEMP\vcredist_bundled.exe "${VCREDIST_FILE}"

; Install VC++ Redistributable with passive UI (shows progress, no interaction)
ExecWait '"$TEMP\vcredist_bundled.exe" /install /passive /norestart' $0

; Clean up
Delete "$TEMP\vcredist_bundled.exe"

${If} $0 == 0
DetailPrint "VC++ Redistributable installation completed successfully"
${Else}
DetailPrint "VC++ Redistributable installation returned code: $0"
MessageBox MB_OK|MB_ICONINFORMATION "VC++ Redistributable installation completed (code: $0)"
${EndIf}
Goto vcredist_init_done

skip_vcredist_init:
MessageBox MB_OK|MB_ICONINFORMATION "$(VCRedistSkipped)"

vcredist_init_done:
functionEnd

section "install"
Expand Down
78 changes: 78 additions & 0 deletions dist/win/mediawriter_native.nsi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
!include "MUI2.nsh"
!include "nsDialogs.nsh"
ManifestDPIAware true
XPStyle on

Expand Down Expand Up @@ -87,6 +88,10 @@ Icon "../../src/app/data/icons/mediawriter.ico"

!define MUI_ICON ../../src/app/data/icons/mediawriter.ico

# VC++ Redistributable configuration
!define VCREDIST_FILE "vc_redist.x64.exe"
!define VCREDIST_URL "https://aka.ms/vs/17/release/vc_redist.x64.exe"

!insertmacro MUI_PAGE_LICENSE "../../build/app/release/LICENSE.GPL-2.txt"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
Expand Down Expand Up @@ -268,6 +273,12 @@ LangString AdmingRightsRequired ${LANG_TURKISH} "Admin rights requi
LangString AdmingRightsRequired ${LANG_UKRAINIAN} "Admin rights required!"
LangString AdmingRightsRequired ${LANG_UZBEK} "Admin rights required!"

LangString VCRedistNotInstalled ${LANG_ENGLISH} "Microsoft Visual C++ Redistributable is not installed on your system.$\n$\nIt is required for ${APPNAME} to run properly.$\n$\nWould you like to download and install it now? (approximately 25 MB)"
LangString VCRedistDownloading ${LANG_ENGLISH} "Downloading Microsoft Visual C++ Redistributable..."
LangString VCRedistInstalling ${LANG_ENGLISH} "Installing Microsoft Visual C++ Redistributable..."
LangString VCRedistDownloadFailed ${LANG_ENGLISH} "Failed to download Visual C++ Redistributable.$\n$\nPlease check your internet connection and try again,$\nor download it manually from:$\nhttps://aka.ms/vs/17/release/vc_redist.x64.exe"
LangString VCRedistSkipped ${LANG_ENGLISH} "You have chosen to skip the Visual C++ Redistributable installation.$\n$\n${APPNAME} may not work correctly without it.$\n$\nYou can download it manually from:$\nhttps://aka.ms/vs/17/release/vc_redist.x64.exe"

!macro VerifyUserIsAdmin
UserInfo::GetAccountType
pop $0
Expand All @@ -278,6 +289,44 @@ ${If} $0 != "admin" ;Require admin rights on NT4+
${EndIf}
!macroend

; Function to detect if VC++ Redistributable 2015-2022 is installed
; Returns: 1 if installed, 0 if not installed (in $R0)
Function CheckVCRedist
Push $0
Push $1

; Default to not installed
StrCpy $R0 "0"

ClearErrors
; Check the primary registry location for x64 VC++ 2015-2022
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed"
${If} $0 == "1"
StrCpy $R0 "1"
Goto vcredist_check_done
${EndIf}

ClearErrors
; Check alternative registry location
ReadRegStr $0 HKLM "SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed"
${If} $0 == "1"
StrCpy $R0 "1"
Goto vcredist_check_done
${EndIf}

ClearErrors
; Check older registry location
ReadRegDWORD $1 HKLM "SOFTWARE\Microsoft\DevDiv\VC\Servicing\14.0\RuntimeMinimum" "Install"
${If} $1 == "1"
StrCpy $R0 "1"
Goto vcredist_check_done
${EndIf}

vcredist_check_done:
Pop $1
Pop $0
FunctionEnd

function .onInit
!ifdef INNER

Expand All @@ -291,6 +340,35 @@ function .onInit

setShellVarContext all
!insertmacro VerifyUserIsAdmin

; Prompt user about VC++ Redistributable BEFORE main installation
MessageBox MB_YESNO|MB_ICONQUESTION "$(VCRedistNotInstalled)" IDYES install_vcredist_init IDNO skip_vcredist_init

install_vcredist_init:
InitPluginsDir
DetailPrint "$(VCRedistInstalling)"

; Extract bundled VC++ Redistributable to temp directory
File /oname=$TEMP\vcredist_bundled.exe "${VCREDIST_FILE}"

; Install VC++ Redistributable with passive UI (shows progress, no interaction)
ExecWait '"$TEMP\vcredist_bundled.exe" /install /passive /norestart' $0

; Clean up
Delete "$TEMP\vcredist_bundled.exe"

${If} $0 == 0
DetailPrint "VC++ Redistributable installation completed successfully"
${Else}
DetailPrint "VC++ Redistributable installation returned code: $0"
MessageBox MB_OK|MB_ICONINFORMATION "VC++ Redistributable installation completed (code: $0)"
${EndIf}
Goto vcredist_init_done

skip_vcredist_init:
MessageBox MB_OK|MB_ICONINFORMATION "$(VCRedistSkipped)"

vcredist_init_done:
functionEnd

section "install"
Expand Down
Loading