What do you do if the file in TFS is locked by someone else? - version-control

Someone left the organisation but before leaving, he locked all the files for an unknown reason.
How do you unlock them all so that the other developers can work?

For the following operation, you will need to be either a project administrator for the project you want to undo the check-in on or a Team Foundation Administrator if you want to do this across all projects.
If you still have the username of the person, you can simply do something like this:
Open up Visual Studio command prompt (Start -> Programs -> Microsoft Visual Studio 200X -> Visual Studio Tools -> Visual Studio 200X Command Prompt)
Run the following command:
tf lock /lock:none
/workspace:WorkspaceName;USERNAME
/recursive $/
To get the list of workspaces for a user, just run the following command from the same prompt:
tf workspaces /owner:username
For more commands, check tf /?

If the developer has left the organization, then the best thing to do is to delete their workspaces. This will unlock the files for you but also free up some resources on the server.
See the following blog post I did on the topic when it happened to me a few years ago.
http://www.woodwardweb.com/vsts/unlocking_files.html
You can either delete the workspace using the command line (tf.exe) or you can use the excellent TFS Sidekicks from Attrice.

This was the only way I resolved this, which involved deleting the user's workspace.
If the error message says "The item $/... is locked for check-out by someUser:1 in workspace someMachine123." then I use the command:
tf workspace /delete /server:http://machinename:8080/tfs/DefaultCollection someMachine123;someUser:1
There is just a single space between the collection URL and someMachine123;someUser:1.
Note that I payed attention to the fact that the error message mentioned the user as someUser:1, so I mimicked that in the command. It was not enough to just run the command with someUser only. I'm not sure what the :1 is all about but point being, mimick the error message.
Note the server has to be the fully qualified collection path, which you can find by going to Team Foundation Server Administration Console->Application Tier->Team Project Collections, the bottom pane will show a URL for the collection that is selected in the upper pane.
I also had a problem because I accidentally tried to use plural workspaces instead of just workspace because there is a similar command that is plural.

first you need to have the right to do this. If you have that the easiest is to use TFS sidekicks from attrice http://www.attrice.info/cm/tfs/

Here's an explanation of using TFS permissions.
Having the "Unlock other user's changes"
permission set to Allow is required to
remove a lock held by another user.

I needed to add /collection:collectionURL otherwise the workspace could not be found:
List item
tf loc /lock:none /workspace:WorkspaceName;UserName /collection:collectionURL

Have a system administrator reset that users password, log on as that user, unlock all files...
I would think this is the solution to almost all 'someone who is no longer at this organization' questions...

It is better to delete the workspace of that user from the server. example
tf workspace /delete /server:your_tfs_server workspace;username

Sometimes this is masking an different problem with a completely different application is locked by another user, but you cannot even create a New Folder for the new project you wish to merge into ( target won't allow the creation and incorrectly stating that someone has a file locked in their name) but then you dig deeper and another project is the culprit.
So a completely different project can be the problem with it having files locked by someone else.

Method that worked for me, my account has administrator permission on TFS and project :
In Visual studio 2015:
Go to Team Explorer
Click right on your solution and choose Open in source control
exporer
On left side click right on your solution
Choose Advanced
Choose Lock...
On left side click right on your solution
Choose Advanced
Choose Unlock (Now you can choose unlock)
Right now, every dev can easily commit his changes :)

by using TFS permissions,
Open up Visual Studio command prompt,Run the following command:
tf undo /workspace:workspaceName;DomainName\UserName $/file path in your solution

Use this solution as the very last resort.
I’m using TFS 2012. I went to the TFS database and ran the following queries. And it worked! Of course be very careful when messing with the database, take backups, etc.
The database is called Tfs_<<your_TFS_collection_name>>. Ignore the Tfs_Configuration MSSQL database. I'm not sure but if you don't have a Tfs_<<your_TFS_collection_name>> database, settings might be in the Tfs_DefaultCollection database. Locks are stored in tbl_PendingChange.LockStatus.
/*Find correct row*/
SELECT LockStatus, PendingChangeId, *
FROM tbl_PendingChange
WHERE TargetServerItem like '%<<fileName>>%'
/*Set lock status to NULL (mine was set to 2 initially)*/
UPDATE tbl_PendingChange SET LockStatus = NULL WHERE
TargetServerItem like '%<fileName>>%'
AND PendingChangeId = <<PendingChangeId from above>>

Related

How to fix msedgewebview2 error in VS2022 when admin?

I have installed the relatively fresh Visual Studio 2022 on a Windows installation. The work I do often requires administrative privileges (local IIS). To do this I have two users, one 'normal' account that is logged in to Windows and one administrator account. When starting VS2022 with the administrator account, an error keeps coming. It happens especially during debugging and it reads as follows:
Microsoft Edge can't read and write to its data directory:
C:\Users\<administrator_user>\AppData\Local\Temp\VSWebView2Cache\<guid>\EBWebView
What appears to happen is that Microsoft Edge WebView2 (msedgewebview2.exe) is running as the user that is logged in to Windows, while trying to write temporary files for the administrator user where it does not (and should not) have write or read access.
Here we can see the process details that says the application user is the logged in user and not the administrator:
Does anyone know how to fix this issue?
The error happen even when I run debugging on a .net 5 console application. In that particular situation I don't see why it needs to run anything in a WebView instance, but apparently some background process is running something anyway. Is this something that can be turned off?
My best solution so far is to create a shared folder.
I decided to make C:\Users\<administrator_user>\AppData\Local\Temp\VSWebView2Cache\ shared. The "VS" prefix indicates that this is a Visual Studio-specific folder, and I think it is acceptable that my normal user can have access to that folder as it seems to contain temporary Visual Studio files.
To do so I logged in to Windows with the administrator account.
I navigated to the folder and made it a shared folder. I added my no-admin user with "Read/Write" privileges.
I then tested by logging out of the admin account and into my no-admin account. There I first tried the full path in File Explorer and was granted access to the folder. I then tested with VS2022 and during debugging no error box appeared and files were generated in the folder.
If anyone finds a better approach, I'd really like to hear about it. Also if you have knowledge to why this approach is either good or bad, that would be highly appreciated as well.
I only had to create the folder "VSWebView2Cache" with my normal Windows account and after that it worked.

Removing references from renamed VSTS project (not TFS)

I had deleted a project from VSTS and would like to use the same name again for my project but when I try to create the project, I get this error:
All of the desktops that this message is referring to are gone e.g. old employees, virtual desktops, etc.
How do I get past this error? I'd hate to retire a project name because of old desktops or ex-employees that will never access this project again.
UPDATE:
When you know what you're doing, everything is easy and questions like mine are frowned upon, so much so that someone suggested this post should be closed. Very nice!
So, I'm told both TFS and VSTS work the same way and I should go learn what I need to learn from the other post. According to the linked post, I need to go run TF command which according to the answers is located in Visual Studio 20xx/Common7/IDE folder. I go there and TF.exe is NOT there. I then start searching my computer to locate this executable and my computer can't find it. I then Google it and here's what I see on Microsoft's documentation. What gives?????
Regarding VS2017, the Tf.exe is in C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer, you also can call TF command in Developer Command Prompt for VS 2017.
On the other hand, you also can remove workspaces through Visual Studio directly (Manage workspaces and check Show remote workspaces option)

Delete a Test Plan in VSTS / Test Manager

Is there a way to delete a Test Plan in Visual Studio Team Services or through Microsoft Test Manager for a project hosted on Visual Studio Team Services?
Delete buttons seems to be disabled and directly deleting the work item in VSTS is blocked:
The work item 1 cannot be deleted. Test Plan work items cannot be deleted. work items cannot be deleted.
Any other way to achieve this?
As Abhijit mentioned, you need to use witadmin destroywi command to delete the test plan. This command works for VSTS too. But you need to make sure your account has "Team Foundation Administrators" permission. You can use this command directly from "Developer Command Prompt for VS" which is installed with VS.
I was just trying to delete a test plan, and saw that, in the web access of the test plan, if you hover over the name of the plan in the tree view on the left, there's an "x" that appears, and lets you delete the test plan! No command line needed :)
If relevant, though - we have an internally-hosted TFS. But the "x" I found doesn't match what the MS documentation seems to suggest.
Screenshot of TFS Web Page
Deleting test plan in MTM 2010 is straight-forward (check the link below). While in MTM2012/2013 test plan can be deleted through developer command prompt.
In MTM2012/MTM2013, there is no direct way to delete a test plan. We
need delete the corresponding work item using TFS command line options
in command prompt in order to delete a test plan.
You can delete the test plan like this in Developer Command Prompt for
VS2013:
witadmin destroywi /collection:XXXX / id: the test plan’s id
You can find the solution here:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/1efe30e3-5a1f-4ca2-abac-52dbeb0d592c/microsoft-test-manager-2013-how-to-delete-a-test-plan?forum=vsmantest
If you followed the steps that are here and you still cannot delete test suites/plans etc., it means that your account subscription is Basic or Professional but not Enterprise which includes Test Manager as default. The thing is that in Basic subscriptions, you can create test suites but can't delete them (Annoying).
What you can do however is that you can get free trial for the Test Manager from here and then you will be able to delete them. I afraid there is no other way yet and you can vote the already existing feature request too if you want from here.
Yes. You can delete it via VSTS.
Just click on the ellipsis button (looks like 3 dots) on top right hand side and select “Permenantly delete”. It will prompt you to enter the test plan ID to confirm the delete. Note. Deleting the test plan will not delete any associated test cases. You will have to run the same process with the test cases. You will need administrative privileges in order to see the permanently delete option in the menu.
See: https://www.visualstudio.com/en-us/docs/work/backlogs/remove-delete-work-items#move-delete-permissions

Best option for check-in/out with small team using Visual Studio 2012?

I have a small team of web developers who work together on up to 50 external sites. I am trying to find a better solution to using Dreamweaver's check-in check-out for managing source. We have just started using Visual Studio 2012 here and there and I am curious if TFS is the way to go for us. No one here has ever used versioning or any type of source control before, so I am looking for something similar to what they are used to.
If it matters at all, our sites are all hosted on a Windows 2008 R2 server, and largely written in C#.
I think TFS is a good option to consider. As several people have commented, it will be a jump from what you are your team are used to in Dreamweaver, but I personally feel if you are serious about managing your intellectual property, you will invest in some sort of version control system. With that said, there will be a learning curve regardless whether you are your team select TFS, SVN, Git, etc.
Assuming you do go with TFS, you do get the added benefit of everything else that comes with TFS - it's not just about version control. This includes work item tracking, automated builds/deployments, reports, a simple SharePoint site, etc.
With TFS you get the benefit of all of these features, combined into a single product. You can accomplish a similar setup using open source products as well, but would require you to piece the products together.
I'd use the integrated Subversion client in Dreamweaver, which does the basic stuff very nicely and doesn't require the tedious navigation process that will lead to your team bypassing the system. Only problem, DW does not support the latest versions of SVN so you need to pick up an SVN server that is compatible. Try this:
Setting Up Version Control for Dreamweaver CS6 on Windows
Any previous attempts to get version control working may well have created some .svn folders and files on your PC. You MUST remove ALL of these and UNINSTALL ALL OTHER VARIETIES of Subversion software from your PC before you start.
Go to the VisualSVN Server website and download an archived standard version of their software, version 2.1.16 . Don’t be tempted to grab a later version, because this will install SVN 1.7 or 1.8 and neither will work with Dreamweaver.
http://www.visualsvn.com/server/changes/
Trying to get DW working direct to a local folder using the file:// protocol probably won’t work and is also known to put data at risk. You need the server. I chose to install the VisualSVN server with the default settings, other than opting to use Windows logins and go with HTTP, not HTTPS. I decided to have the repositories live on an internal SSD drive, but any local drive will do. When creating a folder for your repositories to live in, use a name that is pretty general e.g. ourcorepositories . I used lower case for everything.
Right click on ‘Repositories’ to create a new one. Give it a name without any spaces or special characters e.g. mynewprojectrepo and check to ‘Create default structure’ . Before you OK, note the Repository URL and copy it into Notepad or a similar plain text editor so you can refer to it later during 6 below. It will be something like
http://OFFICEDESKTOP/svn/mynewprojectrepo
Notice that the capitalised part of the URL is the name of your computer. Click OK and you now have a repository for your project.
5. Boot DW and go to your project. If you don’t have a project yet, create one and stick some dummy files and folders in it. Go to Site menu>>Manage sites… and 2-click your project. Select Version Control.
6. Set Access to be ‘Subversion’ (no other choices exist), Protocol to be HTTP and for the Server Address enter the name of your computer in lower case e.g.
officedesktop
For the Repository Path enter (e.g., using current example from 4. Above)
/svn/mynewprojectrepo
The Server Port should be 80 . For the Username enter your Windows user name, in lower case. Enter your Windows password for the Password. This is the name and password combo that you use to log in to your PC . Click the Test button and you should get a success message. If not, the best advice is to delete any .svn files and repositories you have created and start again. Be sure not to add any slashes or omit any; the above works. Before you click Save, click the link to the Adobe Subversion resources and bookmark it in your browser. There is a lot of useful background information there. Click Save, click Done.
7. Go to your DW project and open up Local View. All of your site’s files and folders will have a green + sign beside the icon. Right-click on the site folder and click ‘Version control>>Commit” . It is a very good idea to leave comments whenever you change anything, so leave a Commit Message along the lines of “The initial commit for My New Project” and click to Commit. If you have a lot of files to go to the repository, they’ll take some time to upload. As they upload, the green + signs disappear to show that you local version is in synch with the repo.
8. Okay, that’s it, you have Version Control in Dreamweaver CS6. It may also work in CS5 and 5.5. Check out those Adobe resources for some good insights on workflow. I can’t help with any other ways to implement version control, but I can maybe save you time by saying that DW doesn’t integrate with Git and that the basic, but integrated, Subversion client in Dreamweaver is way better than having no version control. For coverage against physical disaster, I’d also add in a scheduled daily backup of your entire repositories folder to some cloud storage.
Apologies for any errors. I’d recheck all of the steps, but A) I think they’ll get you up and running and B) it’s easier to do the install and set up the first time than the second time (all those .svn files and folders to get rid of).

Unable to add Solution to TFS 2010 due to existing (invisible)binding

I have a smallish utility library I made that I had created in TFS Beta 2 to test out TFS. I now have TFS rc1 installed(and Beta 2 uninstalled) and am trying to add my Solution to TFS.
I get an error saying that it is already bound to my old TFS, which was on a different system then this one. Strangely, when I go into Source Control and look at the bindings it says there aren't any. Also, I manually deleted the .vss and .vsc files and it still does it.
Ideas? I looked through the numerous other SO topics related to this but unless I missed one none of them are dealing with my issue.
Ideas?
Grab the TFS Sidekicks from Attrice. They have a workspace sidekick, you can pretty quickly find your old machine and unbind/delete that workspace from TFS.
Once you install:
VS Menu Bar
Tools
Team Foundation Sidekicks
Workspace Sidekick
Owner will defult to you, just clear machine name
Search
Select old workspace, click the red X to delete
I had old server entries too and I fixed it by using the workspace sidekick mentioned here and then using the command line to get the rest that the tool couldn't find.