Visual Studio 2019 XAML queue build to TFS 2015 failing - visual-studio-2019

The last developer had been deploying our Intranet MVC project from VS2019 for years, using a method of XAML queue build up to TFS2015.
However after a recent VS update to 16.10.3 (from 16.1.3) - the queue build is now failing (see attached pic). It can't find all the config files (even though I can see them in the solution explorer).
I'm yet to determine if it was the VS update that killed it, or some other MS monthly patching (possibly on the TFS server itself).
As I'm very inexperienced in .NET MVC coding (in fact in VS), can anyone spot an obvious reason this is failing?
Traditionally the VS queue build function would complete in <1min, then the zipped up package could be located on the TFS\drops folder, and imported into IIS on the web server.
I'm in the process of restoring the VM to a point prior to the VS update (~65 days ago), and to a time when the Intranet solution was last published successfully.

Method to copy local code to Devops:
http://raaviblog.com/how-to-push-project-code-from-local-machine-into-azure-devops-git-repo/
1. git init
2. git remote add origin <replace the URL of Azure Git Repo copied earlier>
*if you get an error "fatal: remote origin already exists" - you can run:
git remote set-url origin
.…then continue to step 3. This alternative command replaces Step 2.
3. git add .
4. git commit -m “New project added”
5. git push -u origin master

Related

Move code INTO Azure DevOps Repo FROM TFS WITHOUT losing TFS HISTORY

In our whole company we are the first one trying this.
We are trying to get the code from TFS into Azure DevOps.
Below is TFS details
TFS Server: companyTFS
TFS Project Collection: TechTeam.
TFS Project name: Main.
TFS Branch : Dev
Now I am trying to get code from TFS into Azure DevOps. We could have just copied the code from TFS folder into Azure DevOps folder but we do not want to lose the TFS history.
As described in below I installed Chocolatey and also installed gittfs.
https://blog.rsuter.com/migrate-a-tfs-repository-to-a-vsts-git-repository
When I give below command
git tfs clone http://companyTFS:8080/TechTeam/Main $/Main/Dev/Registration/FeeDetails . –ignore-branches –debug
I am getting below exception.
TF31002: Unable to connect to this Team Foundation Server: http://companyTFS:8080/TechTeam/Main.
Team Foundation Server Url: http://companyTFS:8080/TechTeam/Main.
Possible reasons for failure include:
- The name, port number, or protocol for the Team Foundation Server is incorrect.
- The Team Foundation Server is offline.
- The password has expired or is incorrect.
Technical information (for administrator):
The remote server returned an error: (404) Not Found.
The remote server returned an error: (404) Not Found.
I also tried this but did not work.
https://github.com/microsoft/azure-repos-vscode/issues/320#issuecomment-335573266
I am trying to find out whether my TFS server can do handshaking with external components.
I would be glad if someone can tell me what I am doing wrong.
At last after spending almost 4 days, I am able to move the code from TFS into Azure DevOps along with history. Please see below all the steps I did.
Install Chocolatey:
First we need to install Chocolatey. To make matters simple I created below two files in same folder.
FileName : installChocolatey.cmd
Content:
#echo off
SET DIR=%~dp0%
%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%DIR%install.ps1' %*"
SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
FileName: install.ps1
Content: Copy paste the content from here https://chocolatey.org/install.ps1
Open command prompt in admin mode and ran installChocolatey.cmd to install Chocolatey.
In command prompt give choco -v to see whether it is installed correctly.
Install git tfs:
Next, we need to install git tfs tool in order to do that give below command in command prompt and follow the instructions.
choco install gittfs
In my case it installed to C:\Tools\gittfs.
Open Environment Variables and make sure you add below (in my case )to PATH variable.
C:\Tools\gittfs
In command prompt give git tfs -version to see what version it installed.
Move code from TFS to Azure DevOps:
Azure DevOps Project Name: Experiment
Azure DevOps Repo Name: MyRepo
Azure DevOps Repo Name: Master and DEV
First, I clone this repo to my local. Made sure that I have all remoted branches onto my local.
In my local created a new branch name called TestBranch and pushed it to remote. So now MyRepo has 3 branches and TestBranch is my local working branch.
In command prompt, I went to folder where I mapped Azure DevOps repo. I gave below command to get TFS code with history.
git tfs clone http://companyTFS:8080/TechTeam $/Main/Dev/Registration/FeeDetails . –debug
This will take sometime and after that you can see that TFS code is downloaded to that folder.
In same command prompt,
give below command to make sure what is your working branch
git branch
Below command will create a branch
git checkout -b TempBranch
For below command get url of your target Azure DevOps repo.
Below command will set your remote Azure DevOps Repo as Repo where you want to target
git remote add origin https://xxx#dev.azure.com/xxx/Experiment/_git/MyRepo
Below will create new branch called TempBranch in your target repo in ADO. Here in Experiment project and MyRepo repo
git push --set-upstream origin TempBranch
Now all your code and history from TFS made its way into Azure DevOps into your Repo. You can use PULL Request feature to merge into other branches and so on.
Now lets say you want your Azure DevOps code structure to be different.
Go to folder where you downloaded code/history from TFS and create folder structure or changes the way you want
Giive below command one by one.
git add .
To see all your changes give below command
git status
To commit all your changes in local
git commit -m "[commit message goes here]"
Command to push the changes from local to remote
git push
The code will be in Experiment project MyRepo repo TempBranch branch

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.

TeamCity hangs when updating sources from TFS

I have configured TeamCity to work with our TFS repo. I have configured the VCS Root and used the "Test Connection" to ensure that the settings are all correct. When I run a build it gets to the "Updating sources" and just hangs there. Here's the build log.
[13:33:45]Collecting changes in 1 VCS root
[13:33:47]Clearing temporary directory: D:\TeamCity\buildAgent\temp\buildTmp
[13:33:47]Publishing internal artifacts
[13:33:48]Using vcs information from server. Reason: no revision information for build configuration "Build Development trunk" and checkout directory D:\TeamCity\buildAgent\work\db23c120e1319dcb on agent
[13:33:48]Clean build enabled: removing old files from D:\TeamCity\buildAgent\work\db23c120e1319dcb
[13:33:48]Checkout directory: D:\TeamCity\buildAgent\work\db23c120e1319dcb
[13:33:48]Updating sources: server side checkout (1m:21s)
[13:33:48][Updating sources] Will perform clean checkout
[13:33:48][Updating sources] Clean checkout reasons
[13:33:50][Updating sources] Building and caching clean patch for VCS root: Development trunk
The checkout folder is empty. Any ideas?
EDIT
I've written a Windows batch file that gets the code out from TFS rather than using TeamCity to do this. My batch file runs perfectly when run from the Windows command prompt but fails when run from TeamCity. I am using the fully qualified path to TF.EXE because TeamCity doesn't seem able to find TF.EXE (even though the path has been added to the PATH environment variable).
My batch file correctly configures the TFS workspace before trying to GET the source code. But it still fails.
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\tf.exe" workspaces /collection:http://code-srvr1:8080/tfs/DefaultCollection
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\tf.exe" workspaces /s:http://code-srvr1:8080/tfs/DefaultCollection
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\tf.exe" workfold //fails!!
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\tf.exe" get $/MSM\Development\Trunk /force /recursive //fails!!
The error I am getting is "Unable to determine the workspace. You may be able to correct this by running 'tf workspaces /collection:TeamProjectCollectionUrl'"
But as can be seen I am already specifying the workspace in the batch file.
Any ideas why these commands work from the Windows command line but fail from TeamCity? How do I get them to run from TeamCity?
The solution in my case was to upgrade my Team Foundation Client from 2012 to 2013. There are known timeout issues with the 2012 version and upgrading to 2013 has resolved these.
I had the same issue (TeamCity builds that fetched code from TFS would get stuck indefinitely at the Updating sources stage, blocking the agent).
The solution for me was to make sure that the TeamCity Build Agent ran under the same service account as the TeamCity Server. The server would be able to access the TFS project and instruct the agent to do a build, but the agent itself got stuck when it was not authorized.
When that account mismatch was fixed, it all started working as it should.
As a side note, when the parameter “teamcity.tfs.mode=java” is set, the TeamCity agent does not get stuck, but instead fails with an instructive error message (detailing the current service account name), if it runs under an unauthorized account.

Is source indexing for Git builds possible in TFS 2013?

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

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.

Resources