0

I am using windows 10 64bit operating system. IT have .net framework 3.5 pre installed and we need to just enable it for .net dependent applications to work

My requirement is to create a new MSI which first enables .net 3.5 and later install my application.

First I tried to create bundle but bundle is creating only EXE and its not having permission to install the .net framework. Later I added custom action in Product.wsx to run "NetFx20SP2_x64.exe" which worked. But I am not sure whether its right way to do or not.

IS there any way to enable .NEt framework 3.5 using wix installer(3.11) without calling executables or create bundle.

Bundle.wsx (code snippet)
    <PackageGroup Id="Netfx4Full">
      <ExePackage Id="Netfx4Full" 
                  Cache="yes" 
                  Compressed="yes" 
                  PerMachine="yes" 
                  Permanent="yes" 
                  Vital="yes"
                  InstallCondition="VersionNT64"
                  InstallCommand="/s"
                  UninstallCommand="/s /uninstall"
                  SourceFile=".\NetFx20SP2_x64.exe"
                  DetectCondition="Netfx4FullVersion AND (NOT VersionNT64 OR Netfx4x64FullVersion)"  />
    </PackageGroup>

Custom action in Product.wsx
    <!--CustomAction Id="RegisterEXE"
                  Directory="APPLICATIONROOTDIRECTORY"
                  ExeCommand="&quot;[APPLICATIONROOTDIRECTORY]Upgrade\NetFx20SP2_x64.exe&quot; /Register"
                  Execute="deferred"
                  Return="ignore"  
                  Impersonate="no"
                 /-->
Sijith
  • 3,740
  • 17
  • 61
  • 101

1 Answers1

0

Your way isn't that bad. Haven't found options to solve that problem without CustomAction.

Personally I prefer custom action that runs cmd with DISM command. In this case you'll have exit code which will show you result of action.

For example:

var command = @"/c Dism /online /enable-feature /featurename:NetFx3 /All";
var output = string.Empty;
using (var p = new Process())
{
    p.StartInfo = new ProcessStartInfo()
    {
        FileName = "cmd.exe",
        Arguments = command,
        UseShellExecute = false,
        RedirectStandardError = true,
        RedirectStandardOutput = true,
        CreateNoWindow = true,
    };
    p.Start();
    while (!p.StandardOutput.EndOfStream)
    {
        output += $"{p.StandardOutput.ReadLine()}{Environment.NewLine}";
    }
    p.WaitForExit();

    // Here I'll recommend you to analyze the result
    if (p.ExitCode != 0)
    {
    
        throw new Exception($"{p.ExitCode}:{ p.StandardError.ReadToEnd()}");
    }
}
ba-a-aton
  • 574
  • 1
  • 4
  • 14