0

When publishing a .net application (it's in C#) not using Clickonce, how can I ensure that the correct version of the framework (e.g. 4.0), will be installed along with the application if not already installed?

When publishing using Clickonce, Clickonce can automatically detect whether the targeted version of .net is installed on the target computer, and if it isn't - download and install it automatically. What if I don't use Clickonce, but rather iexpress or any other packaging system?

ispiro
  • 26,556
  • 38
  • 136
  • 291

1 Answers1

1

This appears to be somewhat related to the question How to detect what .NET Framework versions and service packs are installed?, so I'm linking to it here for reference.

Essentially, there's no built-in support in to detect the .NET framework and install it; you have to do this yourself. Theoretically you could write something in batch for this; a simple example could look like:

@echo off
setlocal

rem Check if .NET 4.0 is installed; if not, try to install it
reg query "HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Full" /v Install
if not errorlevel 0 dotNetFx40_Full_x86_x64.exe /q /norestart

rem Check if the install was successful; if it was, install app
reg query "HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Full" /v Install
if not errorlevel 0 exit /b 1

::[...install app, etc...]

Bundle a copy of .NET 4.0 (dotNetFx40_Full_x86_x64.exe) in the IExpress archive, set that batch file as your install command (eg cmd /c install.bat), and set Long File Name support.

Community
  • 1
  • 1
fission
  • 1,170
  • 18
  • 35