为什么我在WIX中的托管自定义操作中获得SourceDir的空白值? [英] Why I am getting blank value for SourceDir in a managed Custom Action in WIX?

查看:73
本文介绍了为什么我在WIX中的托管自定义操作中获得SourceDir的空白值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我正在使用的Product.wxs的代码:

Here is the code for the Product.wxs I am using:

<Product Id="*" Name="abc" Language="1033" Version="1.0.0.0" Manufacturer="def" UpgradeCode="2b75c560-783e-4688-9a02-da09bf986597">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <MediaTemplate />

    <Binary Id="myCustomActionsDLL" SourceFile="..\SetupConfiguration\bin\debug\SetupConfiguration.CA.dll" />
    <CustomAction Id="SetProperty" Execute="immediate"
                        Property="CA_myCustomAction"
                        Value="InstallDir=[MergeRedirectFolder];SourceDir=[SourceDir]" />
    <CustomAction Id="CA_myCustomAction"
        BinaryKey="myCustomActionsDLL"
        DllEntry="SetABCConfiguration"
        Execute="deferred" Impersonate="no"
        Return="check" />

    <InstallExecuteSequence>
      <Custom Action="SetProperty" After="InstallInitialize">Not Installed</Custom>
      <Custom Action="CA_myCustomAction" Before="InstallFinalize">Not Installed</Custom>
    </InstallExecuteSequence>

    <Feature Id="ProductFeature" Title="abc" Level="1">
      <ComponentGroupRef Id="ABCGroup" />
    </Feature>
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="def" Name="def">
          <Directory Id="dirFC83E07AC2C77525961486C88A01C277" Name="ABC">
            <Directory Id="MergeRedirectFolder"/>
          </Directory>
          </Directory>
      </Directory>
    </Directory>
  </Fragment>

[CustomAction]
public static ActionResult SetABCConfiguration(Session session)
{
    string strSourceFolder = session.CustomActionData["SourceDir"]; // returning blank value
    string strWebGeniePhyPath = session.CustomActionData["InstallDir"]; // returning correct value
}

我故意遗漏了组件 ABCGroup 的代码,它只包含一个热量收集目录,该目录很长.

I have deliberately left out the code for component ABCGroup, it just contains a heat harvested directory, which is a long list.

请帮助.

推荐答案

SourceDir属性 ResolveSource操作.WiX默认不编写ResolveSource操作,您必须使用 ResolveSource元素.

The SourceDir property is set by the ResolveSource Action. WiX doesn't author the ResolveSource action by default, you have to add it to your sequence using the ResolveSource Element.

这篇关于为什么我在WIX中的托管自定义操作中获得SourceDir的空白值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆