我是一名 PHP 程序员,我通常不使用 Visual Studio,尤其不使用 Team Foundation Server,但我当前的工作要求我使用它。
我的问题是我需要创建一个自定义构建工作流程(.xaml 文件),它将我的最新源代码从项目的开发版本(TFS 中的源代码控制)复制(最好是压缩)到网络共享(\myserver\myshare\myproject )当我进入队列新版本时。
我尝试通过可视化编辑器,但没有得到任何积极的结果(我所想到的只是如何创建变量),我尝试手动编辑 .xaml 文件(文本编辑器),但它并没有让我很满意到目前为止...
它不需要了解解决方案或项目,它只需要将文件从TFS源代码管理中的项目文件夹复制到网络共享...
我需要一步一步,点击指导如何去做这件事,
提前致谢
使用的软件:Visual Studio 2010 Pro、Team Foundation Server 2010、VS.PHP 2.10.3
I am a PHP programmer, i usually don't work in Visual Studio especially not with Team Foundation Server, but my current job requires me to use it.
My problem is that i need to create a custom build workflow (.xaml file) that will copy (ideally zip) my latest sources from dev version (source control in TFS) of a project to a network share (\myserver\myshare\myproject) when i hit the Queue new build.
I tried through the visual editor bit i didn't have any positive results (all i have figured was how to make a variable), i tried to edit the .xaml file by hand (text editor) but it didn't get me very far...
It doesn't need to understand solutions or projects, it only needs to copy the files from the projects folder in TFS source control to a network share....
I need a step by step, click by click guide how to do it,
Thanks in advance
Software used: Visual Studio 2010 Pro, Team Foundation Server 2010, VS.PHP 2.10.3
发布评论
评论(5)
要进行复制,请添加
CopyDirectory
SyncWorkspace
活动(名为“获取工作空间”,位于 Process / Sequence / Run On Agent / Initialize Workspace 中)之后的活动,然后设置 源属性到SourcesDirectory
和 目标属性到您的网络共享,或者具有该值的变量(如果您愿意)。要压缩文件,您可能需要使用
InvokeProcess
活动,调用某种脚本并传入 SourcesDirectory 变量:作为示例,以下是使用 powershell 压缩文件。编辑:
要执行批处理文件,请从 Visual Studio 工具箱(特别是 Team Foundation“构建活动”选项卡)中获取 InvokeProcess 活动,并将其拖放到工作流中。单击该活动,按 F4 查看属性窗口,然后填写批处理文件的路径以及要传递给它的任何参数。遵循这些说明(如果活动未出现在您的工具箱中)。
To do the copying, add a
CopyDirectory
activity after theSyncWorkspace
activity (which is named "Get Workspace" and is located in Process / Sequence / Run On Agent / Initialize Workspace), then set the Source property toSourcesDirectory
and the Destination property to your network share, or a variable with that value if you prefer.To zip the files up, you will probably want to use an
InvokeProcess
activity, calling some kind of script and passing the SourcesDirectory variable in: as an example, this is how to zip files with powershell.Edit:
To execute a batch file, grab an InvokeProcess activity from the Visual Studio Toolbox, specifically the Team Foundation Build Activities tab, and drop it onto the workflow. Click the activity, press F4 to see the properties window, and fill in the path to your batch file and any arguments you want to pass to it. Follow these instructions if the activities don't appear in your toolbox.
简单的选择是仅使用标准构建模板运行,并使用放置文件夹所需的 UNC 路径配置构建定义。当构建完成时,这会将工作区中的所有源推送到该位置。然后您可以自己手动压缩它。如果您想自动压缩它,那么您就需要像其他人建议的那样自定义构建模板。
Easy option is to just run with the standard build template and configure the build definition with the required UNC path for the drop folder. This will push all the source from the workspace out to that location when the build completes. You can then manually zip it yourself. If you want to automatically zip it then you are getting into customizing the build template like the others have suggested.
在 Visual Studio 2010 中,使用“视图”>“工具箱可查看所有活动,然后拖放它们。其中一些还需要设置属性。
In visual studio 2010, use View > Toolbox to see all activities, and then drag and drop them. Some of them also have Properties to setup.
您将需要按照预期自定义工作流程,您可以看到以下链接,其中使用图像逐步描述如何自定义构建中的文件夹
http://lajak.wordpress.com/2011/05/07/customize-binaries-folder-in-tfs-team-build/
谢谢
M.Radwan
You will need to customize the workflow as you expect you can see the following link that describe step by step with images how to customize the folder in the build
http://lajak.wordpress.com/2011/05/07/customize-binaries-folder-in-tfs-team-build/
Thanks
M.Radwan
如果要在 TFS 服务器上执行脚本,可以采用不同的方法:
以上也可以通过各种工具或远程桌面远程运行。
如果您想自动在 TFS 服务器上运行脚本,也有很多选项。例如,您可以使用 AT 安排批处理作业(*.BAT 或 *.CMD)在特定时间运行。
如果您希望在将内容签入 TFS 或“构建”时运行部署脚本,则需要使用 MS 工作流基础。即使您实际上没有编译任何东西,它也被称为“构建”。这些构建脚本具有标准格式,其中将包括与真实编程语言相同的编译步骤。您可以安全地忽略这些步骤,让它们留在那里。
转到 TFS 中项目的 TFS 条目中的“构建”(我猜是网站?)。克隆现有版本之一并创建一个新版本。还为您的 PHP 部署过程创建一个新的 XAML 文件,否则如果其他人将您的 TFS 用于其他用途,您将破坏正常的构建。在构建过程 XAML 中,按照上面答案中的描述进行更改。在构建的属性对话框中,(这里有两个单独的词“构建”,您可以拥有许多遵循相同“构建过程”的选项。您可以使用相同的过程来部署许多不同的 PHP 站点,其中诸如目标文件夹将在您的各种构建的属性页面的“进程”选项卡中提供),在触发器下,将其设置为持续集成,这意味着您的新构建以及您的新自定义构建过程将在每次您运行时运行登记入住。
嘭,就这样。
if you want to execute a script on the TFS server there are different ways of doing so:
The above can also be run remotely via various tools or remote desktop.
If you want to automate a script to run on the TFS Server, there are a bunch of options as well. You can for instance us AT to schedule a batch job (*.BAT or *.CMD) to run on specific times.
if you want a deployment script to run when you check stuff into the TFS or when you "build" you need to use MS workflow foundation. It is called a "build" even if you are not actually compiling anything. These build scripts have a standard format, which will include compile steps as real programming languages have those. You can safely ignore those steps, just let them stay there.
Go under Builds in the TFS entry for your project in TFS (or website I guess?). Clone one of the existing builds and make a new one. Make a new XAML file for your PHP deployment process as well, cause otherwise you will destroy the normal build if other people are using your TFS for other things. In the build process XAML, make the changes as described in the answers above. In the property dialog for your build, (two separate words here, "build", you can have many of those that follow the same "build process". You could use the same process to deploy many different PHP sites, where things like the target folder will be supplied in the "Process" tab in the Property pages for your various Builds), under Trigger, set it as Continuous Integration, which means this new build of yours with this new custom build process of yours will run every time you check in.
BAM there you go.