Monday 28 November 2022

Adding custom prerequisite software to Visual studio installer project

 One of my application require asp.net runtime to be installed in the client system to run the application. Visual studio installer project doesn't have option to add Microsoft ASP.NET Core 6.0.11 Shared Framework (x64) to the project pre-requisite screen in visual studio.



The list of Prerequisite is loaded from configuration available in 

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VisualStudio\BootstrapperPackages

Or on the location where visual studio is installed. :D



Solution:

note: Microsoft ASP.NET Core 6.0.11 Shared Framework (x64) needs to be installed in the system so that we can get some info from control panel.


  1) clone a folder and rename it to "aspnet6coreruntime_x64"

2) remove all the files/folders other than these:

    



3)  modify package.xml to : 

<?xml version="1.0" encoding="utf-8" ?>

<Package xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper" Name="DisplayName" Culture="Culture">


  <!-- Defines a localizable string table for error messages-->

  <Strings>

    <String Name="DisplayName">Microsoft ASP.NET Core 6.0.11 Shared Framework (x64)</String>

    <String Name="Culture">en</String>

    <String Name="AdminRequired">You do not have the permissions required to install the ASP.NET Core 6.0 Runtime (v6.0.11). Please contact your administrator.</String>

    <String Name="InvalidOS">Installation of the ASP.NET Core 6.0 Runtime (v6.0.11) (x64) is supported only on x64 machines.</String>

    <String Name="GeneralFailure">A failure occurred attempting to install the ASP.NET Core 6.0 Runtime (v6.0.11).</String>

    <String Name="InvalidPlatformWinNT">Installation of the Microsoft ASP.NET Core 6.0 Runtime (v6.0.11) is not supported on this operating system.</String>

  </Strings>

</Package>


4) modify product.xml to :

<?xml version="1.0" encoding="utf-8" ?> 


<Product xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper" ProductCode="Microsoft ASP.NET Core 6.0.11 Shared Framework (x64)">


  <!-- Defines list of files to be copied on build -->

  <PackageFiles CopyAllPackageFiles="false">

    <PackageFile Name="aspnetcore-runtime-6.0.11-win-x64.exe"

                 HomeSite="https://download.visualstudio.microsoft.com/download/pr/e874914f-d43d-4b61-8479-f6a5536e44b1/7043adfe896aa9f980ce23e884aae37d/aspnetcore-runtime-6.0.11-win-x64.exe"

                 PublicKey="0" />

    <PackageFile Name="NetCoreCheck.exe" />

  </PackageFiles>


  <!-- Run the NetCoreCheck tool that will determine if the necessary framework is installed -->

  <InstallChecks>

    <ExternalCheck Property="NetCoreCheck" PackageFile="NetCoreCheck.exe" Arguments="Microsoft ASP.NET Core 6.0.11 Shared Framework (x64)"/>

  </InstallChecks>


  <!-- Defines how to invoke the setup for the .Net Runtime 6.0 -->

  <Commands Reboot="Defer">

    <Command PackageFile="aspnetcore-runtime-6.0.11-win-x64.exe" Arguments=' /q '>


      <!-- These checks determine whether the package is to be installed -->

      <InstallConditions>

        <!-- Block install on any platform other than x64 (Arm64 will usually work too) -->

        <FailIf Property="ProcessorArchitecture" Compare="ValueEqualTo" Value="Intel" String="InvalidOS" BeforeInstallChecks="true"/>

        <FailIf Property="ProcessorArchitecture" Compare="ValueEqualTo" Value="Arm" String="InvalidOS" BeforeInstallChecks="true"/>

        <!-- Block install on less than Windows 7 RTM -->

        <FailIf Property="VersionNT" Compare="VersionLessThan" Value="6.1.0" String="InvalidPlatformWinNT"/>

        <!-- NetCoreCheck returning 0 means the runtime is already installed -->

        <BypassIf Property="NetCoreCheck" Compare="ValueEqualTo" Value="0"/>

        <!-- Block install if user does not have admin privileges -->

        <FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/>

      </InstallConditions>


      <ExitCodes>

        <ExitCode Value="0" Result="Success"/>

        <ExitCode Value="3010" Result="SuccessReboot"/>

        <DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />

      </ExitCodes>


    </Command>

  </Commands>

</Product>


4.1) packageFile is the name of the file downloaded from microsoft site: https://download.visualstudio.microsoft.com/download/pr/e874914f-d43d-4b61-8479-f6a5536e44b1/7043adfe896aa9f980ce23e884aae37d/aspnetcore-runtime-6.0.11-win-x64.exe

4.2) HomeSite is the url of downloadable location. 
4.3) Arguments is the name of the installed library which can be found in control panel. 



5) Now restart visual studio and open the project solution. 
6) 

No comments:

Post a Comment

Kubernetes easy installation guide

 Install Kubernetes guide: After lots of research, I've found a easy to follow tutorial to install Kubernetes cluster. Here's the li...