What TFS folder should the solution file be bound to? - visual-studio

I'm using Visual Studio 2013 Pro, update 4, and TFS for version control. I'm not having a good time.
VS keeps insisting on checking out the solution file when I open my (multi-project) solution. It also gives an error "Unspecified Error" (thanks) for every project in the solution.
I had a hunch that the source control bindings were wrong, and indeed many of the posts online suggest unbinding and re-binding. However, the problem seems to re-appear every time I close and restart VS.
One thing that strikes me is that the solution file appears to be bound to the folder for one of my projects. If I un-bind and re-bind, then it gets re-bound to the top-level folder as I'd expect. But then when I re-start VS, it snaps back to the original binding.
Before I go chasing other potential problems, I'd just like to clear up whether it's normal for the solution file to be bound to one of the project folders (even though the file is physically located one level above all the project folders)?

Whenever I find messed up bindings I always follow the same process:
Close VS
Open the SLN file in Notepad.
Remove the GlobalSection (sometimes more than 1) that contains all the SCC elements
Check the csproj file has the 4 <Scc**> elements with a value SAK. If not update all 4 to be SAK (see below).
Open the SLN file in VS.
Select the Solution at the top of Solution Explorer
File, Source Control, Advanced, Change Source Control
Find the Solution in the list and select it.
Click the "Bind" button.
This usually sorts it for me when you re-open it, everything is OK.
The <Scc**> elements should look like this:
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>

Related

Strange nodes in Visual Studio Solution Explorer project tree. How do I get rid of them.?

I have a large solution with many .NET 6.0, C# projects. One of them (a Prism module, one of 11) has a couple of odd tree nodes that appear in Solution Explorer. I cannot get rid of them nor figure out why they are there. One corresponds to a disk folder, one does not. They are circled in red below
The obj tree node obviously corresponds to an actual folder on disk. But the same "obj" folder lives underneath most of the projects, yet only shows up for this one module.
I've tried a few things to get rid of it
I cannot delete the folder in the solution explorer.
When I delete the folder on disk, the node disappears for a second but then the folder gets recreated automatically and it reappears.
When I right click on the folder it in the Solution explorer, the only Git option I get for it is to add it to source control which is the opposite of what I want
I have verified that it the folder does not exist in my Git repo so I didn't accidentally check it in.
The Imports tree node makes even less sense There's no folder for it on disk. It seems to refer to items in .NET that my app is using.
I cannot find any entry in the solution's .gitignore file that refers to either "Imports" or "obj" by name (except a line excluding "*.obj"). I see nothing in the raw project file -- which is identical to many others that would explain this any of this. I have gone through it line by line comparing to others.
I am using VS 2022 but I know I saw this with VS2019 as well
Any ideas how to make these things go away...?
Toggle the "Show all files" button.
The button applies to each project separately, so that would explain why you see "obj" folders in some places and not others. For those projects that have "show all files" toggled on, you'll see the files and folders that live under a project on your hard drive but that are not actually part of the project. For those project that have "show all files" toggled off, you won't see such files in the Explorer.
Unfortunately I do not know anything about Prism, but I imagine the same sort of thing is happening for the Imports. Or Imports could be more like References in a C# project and they will just always show.

Remove TFS Bindings without a hack

I have a 2013 Visual Studio Web Project which was in source control. It has been detached for some time and now I want to move it to a completely new TFS server but when I do it errors and complains expecting certain folders to exist. I think this is due to the TFS bindings.
Now I have seen lots of posts about how to edit the solution file to remove the bindings, plus a few other steps but I'm wondering if there is a menu item which you can click to remove the bindings so I can point at a different TFS server? I am hoping I don't need to edit solution file.
I am not simply being lazy - but I want a defacto way of doing this correctly in one go, not hack here and hack there. Hacking a solution file from someone's advice is not the same as clicking a 'Microsoft' menu item.
Quite easy, you just need to follow my steps and you will get it worked.
Open your solution, for now its under source control with your old
TFS server.
Move to File -> Source Control -> Change Source Control , on the
pop-up window click the unbind, you can unbind all of the
solution or a specific project. Will get a below screenshot.
You can check the solution in solution explorer, there is no lock
icon which means not in source control any more.
However, this isn't over. Since your solution file is still in the
workspace which associate with the old TFS server. So if you want to
add the solution to new source control right now, you will get an
error:
" The item 'ConsoleApplication1.sln' is already under source control
at the selected location xxx"....
You have to copy this solution to a different place out of your
workspace. And change the connection of TFS to the new TFS
server(which you want to add source control with).
Finally, open the solution from local folder(new copied). Right
click the solution in solution explorer select "Add solution to
source control" and choose the location you want add to.

VS2010 - Open a solution, file in this sln will open too

i created a little application (win forms) thats create a solution, adds a project and some files to the project. By clicking a button, the new solution should open by the installed vs2010 express. Thats works fine, everything is ok. My question, is there a way to open a specific file in the solution when the hole solution was loaded? For a better understanding, the user (of my application) creates a sln with 3 files (a.cs, b.cs and c.cs). He selects b.cs (in my application), and opens the sln. In the editor in vs, the preselected b.cs should be open.
I've tried to create a sou - file, but i think thats not the right way...
Is there a way to do this?!
Thx and regards
Sascha
Visual Studio remembers the files you had open when you last closed the solution, along with other things like breakpoints, by using the SUO file. You can check this with a simple experiment: close your solution with just a single file opened inside it (a.cs, for example), manually delete the SUO file (don't worry, VS recreates it if it doesn't exists) and when you open the solution again you'll see you won't have any file opened, and you'd lost any breakpoints you had.
So the obvious thing to do here would be to manipulate the SUO, storing on it the file selected by the user and then opening VS from your tool. The only thing I've found on the documentation is the IVsPersistSolutionOpts but I don't have any direct experience with it.
Also check this CodeProject article: while its main focus is to add a Tool Window to Visual Studio, it also uses IVsPersistSolutionOpts.

Word files disappear from "Solution Items" in VS2010

I've run into a problem with VS2010 (it also exists in the latest version, SP1 (10.0.40219.1)):
Add an existing Word file to the "Solution Items" and check this new file in.
Check the file out for editing
Double click on the file and edit it in Word (just make some minor changes)
Save the file (CTRL-S)
Now the file is removed from the "Solution Items" in Visual Studio (you may have to repeat the editing and saving a couple of times)
Update: I'm using Visual SourceSafe 2005.
Despite my research efforts I haven't really found anything on this issue apart from this Microsoft page, and I'd like to know whether there is a way to prevent this problem from happening.
Any ideas are more than welcome, thanks in advance.
G.
After further investigation I think I found the reason behind this behaviour and a workaround.
Please also note that the behaviour described in the original question only occurs for files that are added directly underneath a solution or to a folder that is directly underneath a solution.
The reason
I'm not sure whether the following is 100% correct, but the main point is how Word (and probably other MS Office apps as well) saves an existing file:
Save the current version of the file to a temporary file
Rename the original file so it can be used later in case something goes wrong
Copy the temporary file to the location of the original file, using the original file's name
Delete the original file (that was renamed in step 2)
Visual Studio picks up that the file doesn't exist (for a very short time though) and removes it from its tree and the .sln file. This can also be reproduced by manually adding any kind of file, checking it out (if not checked out), renaming it to a different name and then back to its original name => file is no longer shown in Visual Studio.
The workaround
I've created an empty project template following the steps on Microsoft's site. I also set the output to "Class Library" so that the project would compile even if no static main method exists. This template can be used to add a "Documentation" project to an existing solution. Underneath this project you can add files and edit them as you wish, as Visual Studio behaves differently and does not remove the file when it is saved in this constellation.
Obviously this approach is still not very satisfying or elegant, but I hope that it may be helpful for others who might run into the same problem.
G.
I've run into the same issue. I simply undo changes for the solution after I've closed the document file and the solution files will be as they originally were before your document changes.

Visual Studio open files question

Is it possible to open a project in Visual Studio 2008 without opening all the files that were previously opened last time I had the project open. I have a habit of keeping many files open as I am working on them, so next time I open the project, it (very slowly) loads up a bunch of files into the editor that I may not even need open. I have searched through the settings and cannot find anything to stop this behavior.
Simply delete the .suo file.
It contains the list of open files.
A bit of research turns up the fact that you can do it with a macro:
Create a new macro (or use an existing one). You should see a module called EnvironmentEvents in Macro Explorer. (For details, see here.)
Open the EnvironmentEvents module.
Put in this code:
Public Sub CloseDocsOnExit() Handles SolutionEvents.BeforeClosing
DTE.ExecuteCommand("Window.CloseAllDocuments")
End Sub
Save and Build the macro.
Open a whole bunch of documents in your solution, then close Visual Studio.
Yay! No more open documents!
(Note: Despite that it says SolutionEvents, it also works if you're working on a project that doesn't have a solution.)
I never realized how much that annoyed me as well! I haven't been able to find a setting, but in Options > Environment > Keyboard you can bind a shortcut to Window.CloseAllDocuments. ALT+X was unbound for me so I just used that. I'm interested if there's some hidden setting to automatically do this on solution exit though (or load).
Edit: Totally read the question wrong at first - ignore my first (now gone) answer. :)
I changed the keyboard mapping for CTRL-SHIFT-C from bringing up the Class View to closing all document windows - something I use several orders of magnitude more often - and then I just clear my workspace before closing a solution.
Try the following:
Close the program after closing all files.
Make a copy of [whatever].suo
Open the solution again, open some files, and exit.
Copy (don't move) the old .suo file over the one that was just generated.
Make the .suo file read only.
If you have a repository you might want to check that file in.
I suggest this because I was having the reverse problem, where it wasn't opening my old files automatically, and the cause was a .suo file that had been checked into the repository and was (for some reason) not being overwritten by Studio. The file wasn't even write protected.
I was hoping for something a little more automatic. VS will create a new .suo file every time the project is saved. So I would have to delete that file every time I open the project. I also don't want to have to remember to close all the files before closing VS.
Other IDEs that I have used have similar functionality, but also make it rather simple to turn on/off.
Thanks for your help.
Or you can close all open document from the Window menu before closing VS.
In Visual Studio 6.0 (VC++), the procedure is slightly different.
Delete the .ncb file (located normally in the same place as your .dsp or .dsw files).
The only way works for me is : change the project location and again reopen the solutions form there. :)

Resources