Is it possible to copy checked in files to a specific folder using a build definition or script? For example, if a check-in a file that is in a folder in TFS, on check-in can I copy that file to a server that has the same folder structure?
TFS
$/Website/files/index.html
Copy To
\ws-file01-dv\files\index.html
You could easily setup a TFS Build that is triggered on Check-In (CI Build) that simply does a Get Latest then copies the source to a file share.
You would have to modify the DefaultTemplate.xaml, by default it already downloads the source to the Build Agent Working Directory, you just need to add a Copy Folder activity that copies it to the target file share. If you've never customized a build workflow before I recommend reading the ALM Rangers Guidance to learn how: http://vsarbuildguide.codeplex.com/
Related
I have a solution which has several VC++ projects. I am trying to make TFS do weekly builds. I have set up TFS Build controller and agent. I created a build definition using DefaultTemplate.xaml file and I can successfully build some of the projects.
The problem is my projects depend on some libraries that are already checked in to debug/release folders. TFS is trying to put project outputs (dlls and exes) to $(SolutionDir)\Binaries directory. Since dependent libraries don't exist on this location, TFS build fails.
What I would like to do is use my own project output locations and somehow copy the output files to somewhere in server.
How can I do that?
Thanks
It's not recommended checking in the libraries to TFS, you can use Nuget to restore the packages.
For the build outputs, you can specify the drop folder in your build definition and copy the outputs to the drop folder.
You can also check in a script that copy the outputs, and specify a post-build script path in your XAML build definition. This script gathers some of the typical binary types from the typical locations and copies them to the folder from which TFBuild copies and drops to your staging location. Check more information about Run a script in your XAML build process at website:
https://msdn.microsoft.com/library/dn376353%28v=vs.120%29.aspx
I would suggest to edit your build definition. Under Process section, set MSBuild arguments to
/p:GenerateProjectSpecificOutputFolder=true
As follows:
I would like to add a custom build step to copy the executable from where it was built (in current active configuration, in current workspace, by currently logged in user) into a shared location.
Are there any predefined environment variables in VS (?) that would contain that information?
Or C# API to Visual Studio that would provide the same?
This might help:
https://msdn.microsoft.com/en-us/library/42x5kfw4.aspx
These did not help:
Visual Studio 2015 Extension - How to get workspace of current Solution
How to get the TFS workspace directory
VNext build
Seems you want to copy files from working folder on the agent computer.(The local path on the agent where your source code files are downloaded. For example: c:\agent\_work\1\s)
You can try to use Windows Machine File Copy task.
Source: You can use pre-defined system variables such as $(Build.Repository.LocalPath) (the working folder on the agent computer), which makes it easy to specify the location of the build
artifacts on the computer that hosts the automation agent.
Destination Folder: The folder on the Windows machine(s) to which the files will be copied. Example: C:\FabrikamFibre\Web
If your shared loaction is on the same machine. You can also try to use Copy Files.
XAML build
In XAML build, you can check in your script, and specify a post-build script path in your XAML build definition. This script gathers some of the typical binary types from the typical locations and copies them to the folder from which TFBuild copies and drops to your staging location. Check more information about Run a script in your XAML build process at website: https://msdn.microsoft.com/library/dn376353%28v=vs.120%29.aspx
My ultimate goal of this exercise is to update TFS code repository from the contents (i.e., files and folders) which are getting copied from another source.
Following is the exact scenario in my project:
There exists a code repository in VSTS Online
Have setup Jenkins on my local computer.
Configured Jenkins to create a workspace for TFS code.
Written powershell scripts in the build step to copy files from another source to the workspace folder configured for TFS.
Till this point everything is working fine. In the next step, I want to update TFS repository from whatever is there in the workspace.
Any idea of how I can achieve this?
Thanks,
Nirman
You can try to use tf command with a script during the build just like Stefan suggested.
If you want to use Windows Explorer to manage TFS version control files, you can also try to use Microsoft Visual Studio Team Foundation Server 2015 Power Tools. Which allow you to check-in and check-out through folders.
You need to: First, create a workspace folder, put your project in this folder.
Then use Windows Shell Extensions coming with TFSPowerTools2015 to check in/check out files in the local workspace folder.
I have a WCF project with a single .svc file and some .config files in it. I'm trying to create a build definition in TFS 2010 that will copy these files to an IIS folder on another machine.
I've done similar things with other MVC projects using the CopyDirectory task in the build XAML template. In those, I copy from the _PublishedWebsites folder to the IIS folder. However, with the WCF project, there is no _PublishedWebsites folder.
So I tried updating the MSBuild script for the WCF project to create a _PublishedWebsites folder and copy the files to it. This works when I build locally in Visual Studio 2010. But when it runs on the TFS build server, it doesn't quite work.
What I see there is that in "C:\Builds\1\PROJECT\PROJECT (Continuous Build)\Sources\PROJECT\bin\_PublishedWebsites", I can see all the files.
I'm guessing this "1 folder" is a temporary folder used for building...? I'm not sure what it's used for. But when I look at the actual drop location for the build, in "C:\Builds\PROJECT (Continuous Build)\PROJECT_BUILDNUMBER\", I see nothing except log files. None of the files from the "1 folder" are there.
Note that this same solution also has a WiX project to create a deployment package. That seems to build fine, and shows up in the drop location with no issue.
"1 folder" is a temporary folder used for building
Yes. "1" is number of build agent(service that actually executes builds activities) on your build machine.
But when I look at the actual drop location for the build, in "C:\Builds\PROJECT (Continuous Build)\PROJECT_BUILDNUMBER\", I see nothing except log files.
- Usually "Copy Files To Drop Location" flag is responsible for that.
I am working on an extension for visual studio to update a project.
The situation is a follows:
We create a new project from a template.
We put the solution in tfs
We change the project which was used to create the template. The project on the tfs server still needs te be updated.
We publish the project to a folder. I now want to update the files in the TFS repo with the current files in the publish folder
I thought of the following approach:
In the application we have all the project stored that are on the TFS server. When I want to update a specific project I select the project from the database. Next I load this project from the TFS server and create a new checkout for this project. So far so good. The problem arise when I copy the files from the published folder to the new checkout. Files that are already registered in the workspace get marked as changed but the files that are new are not added.
The only solution I can think of is to add all the files through the TFS SDK. But this seems pretty heavy to me.
So I got a couple of questions:
Is this the right approach to update
the project?
Is there any other way to add the files to the workspace instead of adding all files through the TFS SDK?
Thanks!
Don't do a blind copy of the files. Instead, have your program iterate through them one by one.
First, update your workspace with the latest from TFS.
Then, for each file in the source directory:
If the file exists in the target directory, "pend edit" the file, then copy it.
If the file does not exist, copy the file, then "pend add" the file.
When you've finished, check in all pending changes in the workspace.