c# - 如何在 C# 中获取安装程序类中的 msi 路径

标签 c# windows-installer managedinstallerclass

我想知道 msi 位于我在设置中用作自定义操作的 InstallerClass 中的路径。

我尝试在 Context.Parameters 中使用 pathSrcDir 等属性,但这些值不存在(抛出 NullReferenceException).是否有任何其他方式获取该路径或这些值为空的任何原因???

谢谢

最佳答案

您需要通过 VS 中的属性窗口传递操作数据中的相关属性:

/sourceDir="[SourceDir]\"

然后,使用上下文检索它:

string path = Context.Parameters["SourceDir"];

关于c# - 如何在 C# 中获取安装程序类中的 msi 路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7188394/

相关文章:

javascript - 从客户端获取代码隐藏中的输入文本框值

c# - Sprache DelimitBy 换行

c# - Windows服务通过ManagedInstallerClass启动失败,通过InstallUtil启动成功

c# - 以编程方式安装 Windows 服务

c# - 转义和取消转义无效字符

c# - MVC MusicStore Artist.Name 对象引用未设置为对象的实例

windows-installer - 如何在 vs 2022 中以 x64 配置构建 vdproj

windows-installer - 链接的msi/Bootstrapper/先决条件?

c# - 存在较新版本的先决条件时无法安装