Search code examples
.net-coreinno-setup.net-8.0.net-runtime

Detecting .NET 8 desktop runtime is installed in Inno Setup


I use the following code in Inno Setup to install .NET 8 Desktop runtime:

function InitializeSetup: Boolean;
var             
  dotNetDownloaderPath: string;
  dotNetDownloaderArgs: string;
  downloadResultCode: Integer;
begin
  Result := True;    

  dotNetDownloaderPath := ExpandConstant('{tmp}\windowsdesktop-runtime-8.0.3-win-x64.exe');
  dotNetDownloaderArgs := '';

  ExtractTemporaryFile('windowsdesktop-runtime-8.0.3-win-x64.exe');

  // Run the downloader to fetch the .NET 8 runtime installers
  Exec(dotNetDownloaderPath, dotNetDownloaderArgs, '', SW_HIDE, ewWaitUntilTerminated, downloadResultCode);    
 

end;

It works but I need to skip installation in case .NET 8 Desktop runtime is already installed on the machine. Is it a registry key with which I can detect .NET 8 Desktop runtime is installed? Or please suggest some other way.


Solution

  • I implemented what I needed with the help of InnoDependencyInstaller

    and adding to the installer the following code:

    [Code]
    function InitializeSetup: Boolean;
    begin    
      Dependency_AddDotNet80;     
      Dependency_AddDotNet80Desktop;   
    
      Result := True;
    end;
    

    It seems to work correctly for .NET 8.