我正在尝试使用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>


有什么想法可以使构建失败吗?

最佳答案

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

如果安装/卸载失败,则错误代码为非零(枚举具有所有可能的值)。因此,当事情没有正确安装时,它应该可以很好地与批处理文件/内部版本配合使用,并期待非零退出代码。

关于msbuild - TopShelf MSDeploy安装错误退出代码,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11868573/

10-13 06:08