The output of a Microsoft Visual Studio Setup Project is a setup package (*.msi). If you run this setup package on a system, you can’t re-install the package on that system, without changing the version of the setup package. If you want to update the .net C# application without changing the version number, you can use the following PowerShell script:

 

function DeploySubsystem([string]$name, [string]$msiPackageProductCodeGuid, [string]$msiPackagePath)
{
    "Uninstall $name"
    $parameters = "/qn /x $msiPackageProductCodeGuid"
    $processPath = "msiexec"
    "Run [$processPath $parameters]"
    $process = [System.Diagnostics.Process]::Start( $processPath, $parameters )
    $process.WaitForExit()

    "Sleep for 5 seconds to make sure the system has updated the registry"
    [System.Threading.Thread]::Sleep(5000)

    "Install $name"
    $parameters = "/qn /i ""$msiPackagePath"""
    $processPath = "msiexec"
    "Run [$processPath $parameters]"
    $process = [System.Diagnostics.Process]::Start( $processPath, $parameters )
    $process.WaitForExit()
}

 

To call the function use:

DeploySubsystem "MyFirstApplicaiton" "{396E89DB-5E5C-4781-9E88-0FEC56D9C06C}" "C:\Temp\MyFirstApplication.Setup.msi"   

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.