【发布时间】:2019-11-19 08:57:31
【问题描述】:
如果未安装 NetCore 3.1(预览版),我想取消安装
我创建了这个 CustomAction:
using Microsoft.Deployment.WindowsInstaller;
using Microsoft.Win32;
namespace WixCustomAction
{
public class CustomActions
{
[CustomAction]
public static ActionResult CheckDotNetCore31Installed(Session session)
{
session.Log("Begin CheckDotNetCore31Installed");
RegistryKey lKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\dotnet\Setup\InstalledVersions\x64\sharedhost");
var version = (string)lKey.GetValue("Version");
session["DOTNETCORE31"] = version == "3.1.0-preview3.19553.2" ? "1" : "0";
return ActionResult.Success;
}
}
}
然后在 WXS 文件中:
<<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
<Product ...>
(...)
<Property Id="DOTNETCORE31">0</Property>
<Condition Message="You must first install the .NET Core 3.1 Runtime">
Installed OR DOTNETCORE31="1"
</Condition>
<InstallExecuteSequence>
<Custom Action="Check.NetCore" Before="LaunchConditions">NOT Installed</Custom>
</InstallExecuteSequence>
</Product>
<Fragment>
<Binary Id="WixCA.dll" SourceFile="$(var.WixCustomAction.TargetDir)$(var.WixCustomAction.TargetName).CA.dll" />
<CustomAction Id="Check.NetCore" BinaryKey="WixCA.dll" DllEntry="CheckDotNetCore31Installed" Execute="immediate" />
</Fragment>
这就是我遇到问题的地方,因为我总是收到警告消息。 一个主意 ?谢谢
【问题讨论】:
-
请添加警告信息。
-
对我来说是“
”这一行。如果你问这个问题,就说明我什么都不懂:( -
测试值不会是
<![CDATA[Installed OR (DOTNETCORE31 = 1)]]>? -
语法似乎更正确,但对于这个问题,结果不会改变:/
标签: c# .net-core installation wix custom-action