如何通过 psake 中的属性来数据驱动任务依赖性?
在 MSBuild 中,您可以通过将项目组传递到目标来数据驱动目标依赖项,如下所示:
<ItemGroup>
<FullBuildDependsOn Include="Package;CoreFinalize"
Condition="@(FullBuildDependsOn) == ''" />
</ItemGroup>
<Target Name="FullBuild"
DependsOnTargets="@(FullBuildDependsOn)" />
如果您不覆盖 FullBuildDependsOn
项目组,则 FullBuild 目标默认依赖于 Package 和 CoreFinalize 目标。但是,您可以通过定义自己的 FullBuildDependsOn 项组来覆盖此设置。
我想在 psake 中做同样的事情 - 例如:
properties {
$FullBuildDependsOn = "Package", "CoreFinalize"
}
task default -depends FullBuild
# this won't work because $FullBuildDependsOn hasn't been defined yet - the "Task" function will see this as a null depends array
task FullBuild -depends $FullBuildDependsOn
我需要做什么来数据驱动 psake 中的任务依赖关系?
In MSBuild you can data drive target dependencies by passing a item group into a target, like so:
<ItemGroup>
<FullBuildDependsOn Include="Package;CoreFinalize"
Condition="@(FullBuildDependsOn) == ''" />
</ItemGroup>
<Target Name="FullBuild"
DependsOnTargets="@(FullBuildDependsOn)" />
If you don't override the FullBuildDependsOn
item group, the FullBuild target defaults to depending on the Package and CoreFinalize targets. However, you can override this by defining your own FullBuildDependsOn item group.
I'd like to do the same in psake - for example:
properties {
$FullBuildDependsOn = "Package", "CoreFinalize"
}
task default -depends FullBuild
# this won't work because $FullBuildDependsOn hasn't been defined yet - the "Task" function will see this as a null depends array
task FullBuild -depends $FullBuildDependsOn
What do I need to do to data drive the task dependencies in psake?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的。我明白你现在想要完成什么。您可以通过常规 PowerShell-fu 来完成此操作。
在 buildScript.ps1 中:
这里的关键是使用普通的 PowerShell 变量而不是使用 psake 属性。 HTH。
OK. I understand what you're trying to accomplish now. You can do this through regular PowerShell-fu.
In buildScript.ps1:
The key here is to use a normal PowerShell variable rather than using a psake property. HTH.
这不是我们在实现 psake 时考虑过的用例。更改 FullBuild 的依赖项列表对我来说似乎有点奇怪且无法维护。您可以通过传递要从命令行运行的任务列表来完成相同的操作。
或者我错过了什么?
That's not a use-case that we ever considered when implementing psake. Changing FullBuild's list of dependencies seems a bit odd and unmaintainable to me. You can accomplish the same thing by passing in a list of tasks to run from the command line.
Or am I missing something?