InstallStatus.Checker 1.0.3

dotnet add package InstallStatus.Checker --version 1.0.3
                    
NuGet\Install-Package InstallStatus.Checker -Version 1.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="InstallStatus.Checker" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="InstallStatus.Checker" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="InstallStatus.Checker" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add InstallStatus.Checker --version 1.0.3
                    
#r "nuget: InstallStatus.Checker, 1.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package InstallStatus.Checker@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=InstallStatus.Checker&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=InstallStatus.Checker&version=1.0.3
                    
Install as a Cake Tool

安装状态检查器

一个用于在 Windows 上检查已安装应用程序状态的 .NET 库,支持 MSIX 和 MSI 两种包格式。

功能特性

  • 使用 MSIX 包系列名称检查应用程序是否已安装
  • 使用 MSI 注册表信息检查应用程序是否已安装
  • 获取详细安装信息(版本、安装位置等)
  • 支持以 JSON 格式返回结果,便于集成
  • 支持直接返回布尔值结果,使用更简洁
  • 可扩展的架构,支持添加更多应用类型的检查

安装方式

通过 NuGet 包管理器安装:

Install-Package InstallStatus.Checker

或者通过 .NET CLI 安装:

dotnet add package InstallStatus.Checker

使用方法

基本用法(JSON 结果)

using InstallStatus.Checker;

// 创建检查信息
var checkInfo = new InstallCheckInfo
{
    TargetPackageFamilyName = "YourPackageFamilyName", // 用于MSIX应用
    TargetAppId = "YourAppId" // 用于MSI应用
};

// 检查安装状态,返回JSON格式结果
string jsonResult = InstallChecker.CheckInstallStatusAsJson(checkInfo);

// 解析结果
var result = System.Text.Json.JsonSerializer.Deserialize<InstallCheckResult>(jsonResult);

// 使用结果
if (result.MSIXIsInstalled)
{
    Console.WriteLine($"MSIX应用版本: {result.MSIXAppVersion}");
    Console.WriteLine($"MSIX安装位置: {result.MSIXInstallLocation}");
}

if (result.MSIIsInstalled)
{
    Console.WriteLine($"MSI应用版本: {result.MSIAppVersion}");
    Console.WriteLine($"MSI安装位置: {result.MSIInstallLocation}");
    Console.WriteLine($"MSI可执行文件路径: {result.MSIExecutablePath}");
}

基本用法(布尔值结果)

using InstallStatus.Checker;

// 创建检查信息
var checkInfo = new InstallCheckInfo
{
    TargetPackageFamilyName = "YourPackageFamilyName", // 用于MSIX应用
    TargetAppId = "YourAppId" // 用于MSI应用
};

// 检查安装状态,直接返回布尔值
bool isInstalled = InstallChecker.CheckInstallStatusAsBool(checkInfo);

// 使用结果
if (isInstalled)
{
    Console.WriteLine("应用已安装");
}
else
{
    Console.WriteLine("应用未安装");
}

API 参考

InstallCheckInfo

包含要检查应用程序信息的类,核心属性说明:

  • TargetPackageFamilyName:要检查的 MSIX 应用程序的包系列名称。
  • TargetAppId:要检查的 MSI 应用程序的标识符(通常是注册表键名)。

InstallCheckResult

包含安装检查结果的类,继承自 BasicInstallCheckResult,分为 MSIX 相关属性和 MSI 相关属性:

基础属性
  • IsInstalled:应用是否已安装(布尔类型)。
  • CheckLogs:检查过程中的日志信息(字符串列表)。
MSIX 属性
  • MSIXIsInstalled:MSIX 应用程序是否已安装(布尔类型)。
  • MSIXCheckLogs:MSIX 安装检查过程的日志(字符串列表)。
  • MSIXAppVersion:已安装 MSIX 应用程序的版本(字符串类型)。
  • MSIXErrorMsg:MSIX 检查失败时的错误消息(字符串类型,检查成功时为空)。
  • MSIXInstallLocation:MSIX 应用程序的安装位置(字符串类型)。
MSI 属性
  • MSIIsInstalled:MSI 应用程序是否已安装(布尔类型)。
  • MSICheckLogs:MSI 安装检查过程的日志(字符串列表)。
  • MSIAppVersion:已安装 MSI 应用程序的版本(字符串类型)。
  • MSIErrorMsg:MSI 检查失败时的错误消息(字符串类型,检查成功时为空)。
  • MSIInstallLocation:MSI 应用程序的安装位置(字符串类型)。
  • MSIExecutablePath:MSI 应用程序的可执行文件路径(字符串类型)。

InstallChecker

包含库主要功能的静态类:

  • CheckInstallStatusAsJson(InstallCheckInfo info):检查指定应用程序的安装状态,返回JSON格式结果。
  • CheckInstallStatusAsBool(InstallCheckInfo info):检查指定应用程序的安装状态,直接返回布尔值结果。

要求

  • .NET 4.8 或 .NET 8.0 及以上版本
  • Windows 10 版本 19041.0 或以上

补充说明

  • 日志属性(XXXCheckLogs)会记录检查过程中的关键步骤(如注册表读取、包信息查询),便于调试排查问题。
  • 错误消息属性(XXXErrorMsg)仅在检查失败时返回具体错误信息,检查成功时为空字符串。
  • 当同时提供 MSIX 和 MSI 应用信息时,会先检查 MSIX 应用,如果未找到再检查 MSI 应用。
Product Compatible and additional computed target framework versions.
.NET net8.0-windows10.0.19041 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8

    • No dependencies.
  • net8.0-windows10.0.19041

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 167 12/26/2025
1.0.1 179 12/23/2025