Is source indexing for Git builds possible in TFS 2013? - tfs

According to this post from January, source indexing was "not supported in TFS Builds running against Git source control". Have any of the updates made this possible yet?

[disclosure - I work on the new build system]
git source indexing is available in the new 2015 build (note this is a completely new modern build system). It's in RC now and shipping soon.
More information available here:
http://aka.ms/vsopreview
specifically: https://msdn.microsoft.com/Library/vs/alm/Build/vs/define-build
Note that if you create a VS definition from the template in the new build system, git source indexing step is there by default.
It will embed a command line for 'tf git view' in the pdb. That command line is available in VS 2015 tf command line.
The task script is open sourced here: https://github.com/Microsoft/vso-agent-tasks/blob/master/Tasks/PublishSymbols/PublishSymbols.ps1

If anyone else comes here looking for a way to index source in a VSTS backed git repo, I modified a powershell script made for github to work with VSTS. The github link to the script in the accepted answer is dead and and pipelines didn't fit my use case. If you just want a script that runs independently of ADO, this might help.
https://github.com/ruckonator/Git-Source-Indexer/blob/master/git-sourceindexer.ps1

Related

can a TFS build task check out a specific commit from a repo instead of checking out complete repo

In our organization we have a requirement to have TFS build task should pull from a specific commit, given a stable commit id build task should check out that particular commit from repo, existing TFS repo build task only checks out latest from given branch, can you please advise if this problem is already solved.
Currently there is no option to do it out-of-the-box in TFS on-premise build pipeline.
You could choose to not sync sources, then the build will not download the repository, and in the beginning of the build add a Command Line task to download only the commit yo want.
About how to disable the get source step in vNext, please refer my reply in this link: Is it able to ignore/disable the first step Get source in vNext Build?
For which kind of git command should use, just the same as in Visual Studio: How do you get a specific version from Git in Visual Studio 2015?

How to integrate TFS in WebStorm?

I'm using Git with WebStorm's version control already, but have to use TFS version control. After some research fond this plugin but there is no tutorial that aiming to configure that plugin.
Can anyone guide me?
You can opt for using git tfs, locally you can still use Git and all of the advantages you're used to. And then push from git to TFVC. You'll need to install Team Explorer or the Team Explorer Cross Platform Commandline Tools.
Or you can use the native plugin for, thelatest version of the TFS / Azure DevOps (Server) plugin can be found on the Jetbrains site. It requires TFS 2015 or newer. You can use the plugin you found for older versions of TFS.
A good explanation to get started can be found here. The part to configure TFVC is replicated below.
Visual Studio Team Services plugin and TFVC
Before starting with TFVC, we need an external tool. The tool in question is TF command line tool. It ships with the Microsoft Team Explorer Everywhere 2015 and you can download it here.
The file we are interested in is TEE-CLC-14.0.3.zip. Download it and unzip it in a folder of your choice. You should end up with something similar to this.
Now, open the command prompt, move into the folder where you have extracted the TF command line tool and run the following:
tf eula /accept
If command succeeded and you haven’t received any error, you are good to go.
Now back to IDEA. Open the settings panel.
and move to Version Control -> TFVC pane. In the select path to executable field, enter the exact path to the tf.cmd command file located in TF command line tool folder.
Once done, press the test button and you should see the following message
Confirm all of the open windows and get back to the IDEA welcome page. Now you are ready to choose Team Services TFVC (Preview) version control.
At this point, same as for Git, you will be prompted about the connection towards your TFS. The following dialog will be shown.
Move to the Team Foundation Server tab and specify the address of your TFS server, then click connect. You will now be prompted for the credentials and if everything is ok, you will be shown the list of available TFVC repositories.
You can now create a new workspace directly from IDEA and start working with your TFVC repositories.

Commit file back to repository from build server in Visual Studio Team Services

I'm currently setting up continuous integration using TFS/Visual Studio Team Services (was VS Online), and I'm using the Team Foundation Build 2015 tasks. So not the XAML builds.
I'm using it to build a Xamarin Android project, but that's pretty irreverent I guess,
The process should be like this:
After a check-in:
TFS should download the sources
TFS should increment the version number within AndroidManifest.xml
I've managed to do this by making a PowerShell script for this.
After the AndroidManifest.xml file is modified, it should be committed back into the TFS repository
Then the rest, build deploy into hockeyapp etc
The first steps are all configured, but I'm struggling with the commit part. How do I get TFS to commit the file? I don't really see any task suitable for it. I've tried using the Copy and Publish Build Artifacts Utility - But that did not seem to work, and I'm not even sure if that's the right utility
I'm using the default hosted build agent btw. Any help would be appreciated
Warning
I do want to point out that checking in changes as part of the build can lead to some features of VSTS/TFS not working. Association of work items to the checkin, sources and symbol generation, tractability from changes to build to release and integration with Test Manager, remote debugging, will likely not yield the expected results because the Changeset/commit recorded in te build may not match the actual sources. This may lead to unexpected funny behavior.
Also, if any new changes have already been committed/checked-in after the build has started, the version number may be updated in Source Control for code that was not actually released under that version.
So: First of all, it's considered a bad practice to change the sources from the build process.
Alternatives
There are better ways of doing it, one is to use the build version (Build_BuildNumber or Build_BuildID variables). Alternatively you an use a task like GitVersion to generate the semantic version based on the branch and tag in your git repository. That way your build will generate the correct version number and will increment the revision in case the same sources are built multiple times.
I understand, but I still want to check in my code as part of the build
If these things don't work for you and you still want to check in the changes as part of the build, you can either use the TFVC Build Tasks if you're using TFVC or use the Git Build Tools to add the remote to the local repository and then use the git commandline tools to commit and push the changes back to the repository.
These extensions require TFS Update 2 to install. But you can push the individual build tasks using the tfx commandlien tool. For the TFVC tasks the process is explained here.
On mac
On the mac it's going to be harder since you're using TFVC. My TFVC tasks leverage the TFS Client Object Model and Powershell to communicate to the TFS Server. The tf.exe tool doesn't even work on windows when you're in the context of a build, which is why I need to call into the VersionControlServer object directly. Given I'm dependent on these technologies, the tasks won't run on a Mac or Linux agent.
You could try to see whether the Team explorer Everywhere X-platform commandline works from the build agent (using a shell script). I have no way to test this on an actual Mac.
Given the cross platform nature of your project I'd recommend to move to Git, it integrates into XCode and Android Studio, making it easier to do a native UI or build on top of native libraries.
Alternative 2
You could setup a build which does the required changes to the code and then checks in the modified code. Then have a (CI) build run the Android and the Mac builds using the modified code.

Integrate crucible with tfs

I use TFS with Jira to managment my team tasks.
I want to integrate a Code Review tool at development process.
When i try to use crucible i reveal that it not support TFS.
I want to know if , there is a good and credible solution for this ,to enable me use crucible with TFS.
additional , if there are another suggests for code reiview tool for VS and JIRA.
Thank!
Some time ago we decided to run Crucible on our project. Our project uses TFS 2012. We use one branch in TFS called 'dev' as a trunk, i.e. branch where developers make commits and where raw code located. Second branch where release code located called 'main'
Our workflow for peer review was:
Make some changes and shelve code
Send email to reviewer
Reviewer doing review in some custom tool and send email with notification that he is done
Commit code into 'dev' branch on TFS
Wait while build-server makes successful build
Commit to 'main' branch where production code resides
Our goal was to improve step 2 and 3. Crucible is great tool, but it doesn't support TFS out of the box, thus we decided to use some TFS bridge. Actually, there are two main options either using tfs->svn or tfs->git. Finally, we decided to use tfs->git bridge, because creating branches in git extremely cheap and it might have been helpful (it did), because we was thinking use branches in git for out shelvesets in TFS. Finally we made our mind to use git.
So far I know only 2 options to convert TFS into git:
git tf - this one works on Linux and recommended by Microsoft
git tfs - this one works only under Windows, but we choose this one, because of large set of commands
We need to convert TFS branch into Git repo and maintain our git repository in fresh state. We don't work with git to push new changes back into TFS, we need git repo only for Crucible.
There are steps we made to achieve the goal:
1. Firstly, we cloned our TFS "dev" branch into "dev" repo. We needed only this one branch, and we haven't any back merges from "main" branch. We have tried to do this with clone command, but without any luck:
git tfs clone http://tfs:8080/tfs/DefaultCollection $/SOME_PATH/dev
This command cloning full history from TFS, but it seems our TFS branch quite large and at some time git-tfs crashed with System.OutOfMemoryException exception. Another time, we failed with exception that max limit of path was exceeded, we found workaround by mapping workspace dir into as short path as possible as follows:
git config --global git-tfs.workspace-dir e:\ws
When we failed with clone command, we went to use quick-clone command. This one cloning starting from any time in history, from any changeset.
git tfs quick-clone -c545532 http://tfs:8080/tfs/DefaultCollection $/SOME_PATH/dev
Option -c545532 here is the number of changeset to starting copying from. Once per year we update all our source files with new header, thus we just to copy from beginning of current year. In that way we should have all necessary history to make branches from shelvesets.
If you hadn't used -c argument here, you would have haven't any history at all, because quick-clone copies just history if you asking for it.
Once repository was cloned, we had written "script" and put it into task scheduler to run every 5 min. What script is doing is just checking for new commits in TFS and creates new branches on our git repository. Again, we use git-tfs here. To get all new commits we call pull command:
git tfs pull
To unshelve TFS shelveset into particular git branch we use unshelve command:
git tfs unshelve -user=TFSDOMAIN\Username "Shelveset Name Here" Branch_Shelveset_Name_Here
This last command creates branch 'Branch_Shelveset_Name_Here' in git from shelveset 'Shelveset Name Here' in TFS. A shelveset's name can contains spaces and some escape chars, so our "script" clean up such cases. As I said, creating branches very cheap on git, thus we haven't any problems with this. If something was pushed into git repo we call crucible API to refresh it.
BTW: To make git repo visible in network I just installed SCM-Server. Crucible was installed and configured to use our domain username/password, thus we get email notification as well. As result we drastically improved step 2 and 3 from our workflow and it works for few months and we are happy with it.
Our workflow became:
Make some changes and shelve code
Wait for our shelveset in crucible (about 6-8 min), create review
Reviewer doing review in crucible
Commit code into 'dev' branch on TFS
Wait while build-server makes successful build
Commit to 'main' branch where production code resides
While working with this I noticed few issues:
Issue1: If you added new file into project and shelved it, you would not see it in git repo, because git-tfs can't find parent commit for it. I'm not sure is it bug of this tool or not, but simplest workaround for this, is having at least one file in shelveset with existing parent. For example, you have added 2 new files and want to send it for review. Instead of creating shelveset with these files, just touch any file which already in git repo (make it pending in Visual Studio), finally you will be able create shelveset with three files (2 new files [add] and 1 for edit [edit]). In that case everything works and git-tfs can unshelve TFS' shelveset into git branch., i.e. we can see it in crucible.
Issue2: One day our HEAD in git repo became detached from "master" branch. Once that happened crucible didn't see new changesets. I have fixed it with command:
git rebase HEAD master
I have created picture how this everything works on our project, may be it could be helpful:
You can integrate Mira and TFS with TaskTop and then use the code review tools built into Visual Studio.
Code Review added in Visual Studio 2012
TaskTop integration with TFS & Jira
These I think are your best options.

TFS shelveset migration from one branch to another

I have to migrate the shelveset created in one branch say "development" to another say "release".
so that I can directly merge the shelveset then to release which was created for development branch.
the command I have used is:
tfpt unshelve "shelveset name" /migrate /source:"$...development" /target:"$...Release"
it is showing this error:
unable to determine the workspace
Your location from where you launch the command must be from within your workspace.
E.g. c:\workspaces\project\development if that's where your source is located.
I guess you question is: How can I get the job done without this error occurring?.
In that case, make sure both branches are mapped to your local system and a latest version of your source code in you did a get-latest-version.
That should prevent the error from happening, because the paths then both contain information about the workspace used for the mapping.
I ran into the same issue today.
After checking the items below I got it working:
Have only one Powertools installed.
Run the command from a Developer Command Prompt
Run the command from the folder that is mapped to your target workspace.
I had to uninstall v. 2010 so only v. 2012 remained. The version numbers doesn't seem to reference your TFS version.
To check if you are at the correct folder, you can run tf workspace.
In the window that pops up find the workspace that you want to target and check in column Local Folder. Make sure you are in that folder.
I spent good amount of time to get this done and I had few issues to overcome and one of these in fact was
unable to determine the workspace
This particular issue was solved by running the command from source branch root folder. This is contrary to some answers here and on SO in general where they say to use "target" branch - no, use "source":
cd [your !!source!! branch root]
tfpt unshelve /migrate /source:"$/MyCollection/Development/Maint1.1" /target:"$/MyCollection/Development/Maint1.2" "myShelveset;UserName"
Second issue appeared after this. Seem that it couldn't connect to TFS server. what I realized, I have multiple VS installed and connected to different TFS servers. I was using VS12 and I had workspace and server connection. But I didn't realize that same connection needs to be replicated in VS13 for TFPT2013 to work. It connects to same server and workspace.
I also tried doing it using TFPT2015 but I installed it and it didn't install TFPT.exe hence it was useless. So I tried from TFPT2013 to TFS2015 and it worked for this particular command. I wonder, why not, if VS12/13 works fine against TFS2015?
To summarize
Use CMD or DevCMD - doesn't matter
run from source branch root folder
verify Team Explorer Server connection
TF Power Tools 2013 work against TFS v15, at least migrate option works
My first answer explains how to have this done properly using TFPT. In this answer, I want to explain how to do it without TFPT.
Every developer should have multiple workspaces. Because we work on multiple issues simultaneously and we don't want to mix it up. so, you work on one issue in WS1 and another issue in WS2. So, if you unshelve your shelveset in a different workspace, this will do that as well. Because your shelveset can't point to 2 different locations in the same workspace. But in different workspace it will unshelve to a location mapped in that workspace.
I ran into the same problem as Boris Callens. I had installed the TF Power Tools for VS2012 and VS2013. When runing the tfpt.exe command in command promt I always had the error message "unable to determine the workspace". This is because I was using the VS 2012 power tools with TFS 2013. So I had to change the Path to the Power Tools in the System Environment Variable "TFSPowerToolDir" to point to the Power Tools for VS2013.
You can find the version number running: tfpt.exe /?
TF Power Tools version

Resources