Create new-service with multiple dependencies from powershell

时间:2016-06-06 14:18:08

标签: powershell tfsbuild tfs2015

Background: I have a custom task for TFS 2015 Build/Release to create a new windows service using powershell

>>> authors = [[u'Smith, J.', u'Williams, K.', u'Daniels, W.'], [u'Smith, J.'], [u'Williams, K.', u'Daniels, W.']]
>>> author_name = {0: u'Smith, J.', 1: u'Williams, K.', 2: u'Daniels, W.'}
>>> author_to_id = {name: id for id, name in author_name.items()}
>>> [[author_to_id[name] for name in doc] for doc in authors]
[[0, 1, 2], [0], [1, 2]]

This works perfectly fine with a single dependency using the -DependsOn argument. The problem is one of my services has two dependencies. The MSDN documentation states to use a comma separated list of dependencies. I've tried this with no luck. The service gets created but the dependencies are missing and the service fails to start. I have verified that the task is passing the values to the powershell script as expected. I'm passing -DependsOn MSMQ,MSDTC

I've tried passing it as a quoted string, which fails. I can pass the dependencies singularly and that works just fine.

My question is simply, how can I pass multiple dependencies to the New-Service powershell command from a TFS Build Task?

1 个答案:

答案 0 :(得分:1)

根据MSDN-DependsOn是一个字符串数组,因此将其作为字符串数组传递,即:

-DependsOn ("MSMQ","MSDTC")