1

我正在尝试将<util:User Id="UpdateServiceAccountLogonAsService" UpdateIfExists="yes" CreateUser="no" Name="[SERVICEACCOUNTFULL]" LogonAsService="yes"/>logonAsService 授予 UI 指定的用户。此属性值在此util :User 在运行时得到处理之前已更新。

我知道这一点,因为我可以给 SERVICEACCOUNTFULL 属性一个默认值“localhost\defaultUserValue”并设置 CreateUser="yes",它会在我的自定义操作设置属性值生成关于显示原始值的运行时消息框错误。不知道为什么无法创建用户,但它显示了正确的时机。如果我将属性默认值硬编码为我将它们设置为动态(使用CreateUser="no")的值,它就可以工作。

<ServiceInstall />作为同一组件的一部分,我拥有的标签正确地使用了属性的更新值,但<util:User />不会。

请记住,我正在验证 createUser 步骤是否发生在设置属性值的自定义操作程序之后。但现在我会奇怪地提到,createUser 操作的执行是在日志中,就在获取属性值的自定义操作的上方,以及 who Before="InstallFiles".

帮助?谢谢!

===========

嗨,罗伯,

不完全确定你需要看什么,但我认为这些是相关的:

<Component Id="Service" Guid='*'>
  <File Source='$(var.root)My Service.exe' />
  <ServiceInstall Id="ServiceInstall"
    Name="MyServer"
    DisplayName="My Server"
    Type="ownProcess"
    Start="auto"
    ErrorControl="normal"
    Description="My Server Windows Service"
    Interactive="no"
    Account="[SERVICEACCOUNTFULL]"
    Password="[SERVICEACCOUNTPASSWORD]" />
  <ServiceControl Id="StopMyServer" Name="MyServer" Stop="both" Wait="yes" Remove="uninstall" />
  <util:User Id="UpdateServiceAccountLogonAsService" UpdateIfExists="yes" 
    CreateUser="no" Name="[SERVICEACCOUNTFULL]" LogonAsService="yes"/>
</Component>

...

<Binary Id="ConfigBinary" SourceFile="$(var.....TargetDir)$(var.Configuration.TargetName).CA.exe" />

<Property Id="Net">net.exe</Property>
<CustomAction Id="NetStart" Property="Net" ExeCommand="START MyServer" Return="check" />

<Property Id="PerformNetStart" Value="0" />
<CustomAction Id='SetPerformNetStart' Property='PerformNetStart' Value='1' />
<CustomAction Id="RunConfiguration" BinaryKey="ConfigBinary" DllEntry="RunConfiguration" Execute="immediate" Return="check" />
<CustomAction Id='IsPrivileged' Error='You must be an admin to install this feature' />

<InstallExecuteSequence>
    <Custom Action='IsPrivileged' Before='RunConfiguration'>
    <![CDATA[Not Privileged AND &FeatureServer > 2 ]]>
    </Custom>
    <Custom Action="RunConfiguration" Before="InstallFiles">
    <![CDATA[&FeatureServer > 2 AND Not Installed ]]>
    </Custom>
    <Custom Action="SetPerformNetStart" Before="InstallFiles">
    <![CDATA[&FeatureServer > 2 AND Not Installed ]]>
    </Custom>
    <Custom Action="NetStart" After="InstallFinalize">
    PerformNetStart = 1
    </Custom>
</InstallExecuteSequence>

然后在 C# 中:

public static ActionResult RunConfiguration(Session session)
{
    session["SERVICEACCOUNTFULL"] = "MyDomain\svcAccount";
    session["SERVICEACCOUNTPASSWORD"] = "secret;

    return ActionResult.Success;
}

以下是硬编码有效值运行的日志:

MSI (s) (F0:F8) [18:29:29:191]: Created Custom Action Server with PID 4796 (0x12BC).
MSI (s) (F0:CC) [18:29:29:211]: Running as a service.
MSI (s) (F0:CC) [18:29:29:213]: Hello, I'm your 32bit Impersonated custom action server.
MSI (s) (F0!48) [18:29:29:240]: PROPERTY CHANGE: Adding CreateUserRollback property. Its value is '**********'.
MSI (s) (F0!48) [18:29:29:243]: Doing action: CreateUserRollback
Action 18:29:29: CreateUserRollback. 
Action start 18:29:29: CreateUserRollback.
CreateUserRollback: 
Action ended 18:29:29: CreateUserRollback. Return value 1.
MSI (s) (F0!48) [18:29:29:247]: PROPERTY CHANGE: Adding CreateUser property. Its value is '**********'.
MSI (s) (F0!48) [18:29:29:247]: Doing action: CreateUser
Action 18:29:29: CreateUser. 
Action start 18:29:29: CreateUser.
CreateUser: 
Action ended 18:29:29: CreateUser. Return value 1.
Action ended 18:29:29: ConfigureUsers. Return value 1.
MSI (s) (F0:F0) [18:29:29:252]: Skipping action: IsPrivileged (condition is false)
MSI (s) (F0:F0) [18:29:29:252]: Doing action: RunConfiguration
Action 18:29:29: RunConfiguration. 
Action start 18:29:29: RunConfiguration.
MSI (s) (F0:E0) [18:29:29:286]: Invoking remote custom action. DLL: C:\Windows\Installer\MSIC008.tmp, Entrypoint: RunConfiguration
SFXCA: Extracting custom action to temporary directory: C:\Users\Jason\AppData\Local\Temp\MSIC008.tmp-\
SFXCA: Binding to CLR version v4.0.30319
Calling custom action ...Configuration!...RunConfiguration
Begin RunConfiguration
Setting MSI values from RunConfiguration
MSI (s) (F0!48) [18:29:47:629]: PROPERTY CHANGE: Modifying RUNTIMECONNECTIONSTRING property. Its current value is 'DEFAULT'. Its new value: 'Data Source=.;Initial Catalog=DB;Integrated Security=True'.
MSI (s) (F0!48) [18:29:47:629]: PROPERTY CHANGE: Modifying SERVICEACCOUNTFULL property. Its current value is 'MyDomain\DEFAULTVALUE'. Its new value: 'MyDomain\svcAccount'.
...
Returning from RunConfiguration

它以这种向后的顺序记录,这可以解释问题,除了当我在 CreateUser="yes" 上做出 CreateUser 操作错误时,它显然在配置自定义操作返回后发生了几个节拍。但也许它以某种奇怪的方式排队,实际上执行顺序就是问题所在——在那种情况下,我仍然不知道如何控制该顺序。

这是您诊断的好信息吗?

4

1 回答 1

1

问题是您RunConfiguration设置元素使用的属性的自定义操作User运行得太晚了。而不是安排RunConfigurationbeforeInstallFiles而是安排 before 的动作ConfigureUsers。就像是:

<Custom Action="RunConfiguration" Before="ConfigureUsers">
<![CDATA[&FeatureServer > 2 AND Not Installed ]]>
</Custom>
于 2013-03-27T04:41:36.967 回答