Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
运行存在于TFS源代码管理中的Powershell脚本_Tfs_Powershell 2.0_Tfsbuild - Fatal编程技术网

运行存在于TFS源代码管理中的Powershell脚本

运行存在于TFS源代码管理中的Powershell脚本,tfs,powershell-2.0,tfsbuild,Tfs,Powershell 2.0,Tfsbuild,我试图在构建过程中运行Powershell脚本,但我不知道如何访问签入源代码管理(TFS 2010)的ps1文件。存在一个类似的SO问题,但我不确定它是否正确: 我的TFS源代码管理设置如下: =项目 ==构建脚本 ===MyScript.ps1 ==代码 ==Dir1 ==MySolution.sln 我以为传递类似于SourcesDirectory+“\..\..\..\MyScript.ps1”(告诉Powershell脚本在哪里)的东西会有用,但我想我已经离开了某个地方 有人能帮我找出

我试图在构建过程中运行Powershell脚本,但我不知道如何访问签入源代码管理(TFS 2010)的ps1文件。存在一个类似的SO问题,但我不确定它是否正确:

我的TFS源代码管理设置如下:

=项目
==构建脚本
===MyScript.ps1
==代码
==Dir1
==MySolution.sln

我以为传递类似于
SourcesDirectory+“\..\..\..\MyScript.ps1”
(告诉Powershell脚本在哪里)的东西会有用,但我想我已经离开了某个地方


有人能帮我找出如何引用ps1文件并运行它吗?

您需要在生成定义中设置一个工作区,其中包括带有Powershell脚本的目录

因此,您的映射可能如下所示:

*Server*                    *Workspace*
$/Project/Code/Dir     -    $(SourcesDir)
您需要添加:

*Server*                    *Workspace*
$/Project/Code/Dir     -    $(SourcesDir)
$/Project/BuildScripts -    $(SourcesDir)/BuildScripts
然后,InvokeProcess可以将
Path.Combine(SourceDirectory,“BuildScripts”,“MyScript.ps1”)
传递到Powershell命令行


注意:您也可以将
$/Project/code/Dir
工作区设置为
$(SourcesDir)/code

是的,另一个答案看起来完全正确。@DaveShaw,我用我的源代码管理结构更新了我的问题,希望我的问题更清楚一些。是的,就是这样。。。我没有为BuildScripts目录设置正确的工作区。再次感谢!