3

我正在尝试使用 CI 的 TopShelf 安装服务。但是,无论何时在安装过程中发生异常,TopShelf 都会回滚事务并继续构建过程,并返回 0x0 状态。

这意味着就 CI 服务器而言,部署是成功的。

我在 MSBuild 中使用的命令示例是:

<Message Text ="Installing Service" />
<Exec Command=""$(MSDeployPath)" -verb:sync -source:runCommand="$(RemoteServicePath) install /instance:$(DeployEnvironment)",dontUseCommandExe=false,waitAttempts=10,waitInterval=10000 -dest:auto,computername=%(ComputerName) -verbose -retryInterval:10000 -retryAttempts:10"></Exec>

我收到的输出是:

[Exec] Running a transacted installation. <br>
[Exec] <br>
[Exec] Verbose: Received response from agent (HTTP status 'OK'). <br>
[Exec] Info: <br>
[Exec] Beginning the Install phase of the installation. <br>
[Exec] <br>
[Exec] Info: Installing service Foo...<br>
[Exec] <br>
[Exec] Info: Creating EventLog source Foo in log Application...<br>
[Exec] <br>
[Exec] Info: <br>
[Exec] An exception occurred during the Install phase.<br>
[Exec] <br>
[Exec] Info: System.ComponentModel.Win32Exception: The specified service already exists<br>
[Exec] <br>
[Exec] The Rollback phase of the installation is beginning.<br>
[Exec] Restoring event log to previous state for source Foo.<br>
[Exec] <br>
[Exec] The Rollback phase completed successfully.<br>
[Exec] <br>
[Exec] The transacted install has completed.<br>

有什么想法可以使构建在异常上失败吗?

4

1 回答 1

1

最新版本的 Topshelf (3.0.2) 添加了 TopshelfExitCode,它是一个枚举,可以转换为 (int) 并从控制台应用程序中的 Main 返回。

如果安装/卸载失败,则错误代码非零(枚举具有所有可能的值)。所以现在它应该与批处理文件/构建很好地配合,当事情没有正确安装时,期望非零退出代码。

于 2012-09-21T14:17:12.533 回答