我想从我的C#.NET应用程序以编程方式安装一个给定的.msi包,最好是我的应用程序指定的安装参数(如安装路径,拒绝crapware等).
我做了一些搜索,但我还没有找到任何有用的东西.最有希望的命中了这个话题,但我找不到任何文档Microsoft.Deployment.WindowsInstaller
或WindowsInstaller.Installer
与此有关.
我发现一个例子在安装过程中加密的web.config 这里,但我的应用程序是一个Windows服务.该aspnetreg_iis
方法仅适用于web.config文件.
我知道如何以编程方式加密配置文件,但我不认为我可以使用WiX做到这一点.我错了吗?有任何想法吗?
有没有办法读取msi文件中的属性?
例如,给定一个msi文件名Testpackage.msi
我需要找到
productName
PackageCode
version
Run Code Online (Sandbox Code Playgroud)
我将使用它与WMI卸载
string objPath = string.Format("Win32_Product.IdentifyingNumber='{0}',Name='{1}',Version='{2}'", "{AC9C1263-2BA8-4863-BE18-01232375CE42}", "testproduct", "10.0.0.0");
Run Code Online (Sandbox Code Playgroud)
更新:使用Orca是一个很好的选择,如果这可以以编程方式实现,那么我可以使用它来生成自动发行说明.并且在卸载程序中也是如此.
我正在使用这些Microsoft.Deployment.WindowsInstaller
库从 .msi 文件中读出值。属性没问题,summary-information也可以读出,例如:
static void Main(string[] args)
{
using (var database = new QDatabase(@"C:\myMsi.msi", DatabaseOpenMode.ReadOnly))
{
Console.WriteLine(database.ExecutePropertyQuery("ProductVersion"));
Console.WriteLine(database.ExecutePropertyQuery("ProductName"));
Console.WriteLine(database.ExecutePropertyQuery("Manufacturer"));
Console.WriteLine(database.ExecutePropertyQuery("ARPREADME"));
}
}
Run Code Online (Sandbox Code Playgroud)
该QDatabase
对象甚至有一个很好的SummaryInfo
属性,保存摘要信息。但是,我还没有找到如何获取 .MSI 所针对的平台。
好像可以读出平台,因为Orca也是这样做的(在Orca中打开Summary Information就可以看到平台)。
我怎样才能获得 .msi 所针对的平台?
首先,为模糊的屏幕截图道歉并且不包括代码中的全名.
我在使用Wix Framework尝试使用dll中的自定义操作时遇到问题.
我正在使用Wix 3.10.2
我在我的解决方案下有一个名为Install.CustomAction的C#Custom Action项目.然后在主Wix项目中引用它.你可以在这看到
我在主Product.wxs文件中将CA dll引用为二进制文件
<Binary Id="CustomActions.dll" SourceFile="$(var.<porjectname>.Install.CustomAction.TargetDir)<projectname>.CustomAction.CA.dll"/>
Run Code Online (Sandbox Code Playgroud)
现在在一个片段中,我有像这样引用的动作
<CustomAction Id="CA_RestoreDB" BinaryKey="CustomActions.dll" DllEntry="RestoreMobileDB" Execute="immediate" Return="check" />
<InstallExecuteSequence>
<Custom Action="CA_RestoreDB" After="InstallFinalize"/>
</InstallExecuteSequence>
Run Code Online (Sandbox Code Playgroud)
所以,尽管如此,我希望一切顺利.
在名为CustomAction.cs的实际c#文件中,我使用[CustomAction]属性进行了此设置
[CustomAction]
public ActionResult RestoreMobileDB(Session session)
{
//string installPath = session.GetTargetPath(TARGETDIR);
string x = session["INSTALLFOLDER"];
session.Log("Begin CustomAction1");
doSomeStuff(x, session);
return ActionResult.Success;
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,一切看起来都很好,而且我正在努力工作.但是当我来编译所有内容时,我得到了这个错误
Severity Code Description Project File Line Suppression State
Error The command ""C:\Program Files (x86)\WiX Toolset v3.10\bin\..\sdk\MakeSfxCA.exe" "C:\Work Files\Development\<product>\<solution>\<project>.Install.CustomAction\obj\x86\Release\<project>.Install.CustomAction.CA.dll" "C:\Program Files (x86)\WiX Toolset v3.10\bin\..\sdk\x86\SfxCA.dll" "C:\Work Files\Development\<product>\<solution>\<project>Install.CustomAction\obj\x86\Release\<project>.Install.CustomAction.dll" "C:\Program Files (x86)\WiX Toolset v3.10\SDK\Microsoft.Deployment.WindowsInstaller.dll;C:\Work Files\Development\<product>\<solution>\<project>.Install.CustomAction\CustomAction.config"" …
Run Code Online (Sandbox Code Playgroud) 如何让Wix在最终的MSI中包含一个没有行的CustomTable?如果我只是像这样定义表
<CustomTable Id="MyTable">
<Column Id="Id" Type="string" Category="Identifier" PrimaryKey="yes"/>
<Column Id="Root" Type="string"/>
<Column Id="Key" Type="string"/>
<Column Id="Name" Type="string"/>
</CustomTable>
Run Code Online (Sandbox Code Playgroud)
Wix在最终输出中省略了它.
我的DTF CustomAction期望它在那里,以便它可以在执行期间向它添加行.
有任何想法吗?
我正在尝试编写ac#自定义操作并使用.Net 2,但是我似乎无法让事情发挥作用.我相信MSI使用的是错误的CLR版本.我在日志文件中看到MSI正在调用我的CA的几行(如果我注释掉我的CA,则不会出现换行符):
SFXCA: Binding to CLR version v4.0.30319.
Run Code Online (Sandbox Code Playgroud)
我的自定义操作似乎没有加载(假设我没有看到任何日志消息).我正在使用Wiz 3.6.3014.0.是否支持或Windows Installer是否只使用计算机上可用的最新运行时?
谢谢
我有一堆.SQL脚本放在InstallShield的"支持文件"视图中.
我想在我的自定义操作中访问这些SQL脚本(通过DTF).我怎样才能做到这一点?