Solution Explorer opens in Folders view - visual-studio

Visual Studio 2017.
I have a project that have been working on for some months. Now all of a sudden whenever I open the solution, Solution Explorer will show it in Folders view. I have to click the following button and select the other option to show it in Solution view:
How do I restore it to the usual situation?

In My case,
I opened the folder where the actual files of the project are placed in file explorer.
And double click on the solution file(file with extention .sln).
It will be opened in the usual view(Solution View)

If you've copied a repo from github and created a solution, make sure you save once before switching to folder view. I forgot to save the newly created solution once, switched to folder view and as a result, could not get back to solution view. Very strange that my solution was somewhere in the void. I restarted VS 2017, recreated the solution and saved it.

By clicking on the same icon has worked for me though i found my whole solution got check out.So before clicking make a note which files are actually for checkout in TFs .

This was happening on one of my projects. I would change to Solution view, save/commit, but the next time I opened it, it was in Folder view again.
I don't know where the "last view" is stored, but apparently it's not in the .sln file.
I right-clicked on the solution and used Open in File Explorer, and opened the .sln file with VS Code and added a blank line at the bottom to "touch" the file. Then I reloaded and checked it in and it stuck.

Related

Solution Explorer not showing files after Get Latest

I am working with another dev and we're using TFS for source control. When he checks in a file or folder, I can see them with Source Control Explorer. I can do a Get Latest, and I can see that the file or folder is pulled down to my local file system.
However, if I flip over to my Solution Explorer, his new files or folders aren't appearing. I have clicked refresh, I have done a Get Latest from Solution Explorer, I have done a Get Specific Version from Solution Explorer.
Is there something I'm supposed to do to have them show up? Do I need to do an Add Existing Item every time he adds something to source control?
Thanks,
Chris
Adding files to source control is not the same thing with adding files to a project.
You are supposed to see the files on source control also.
To be able to see the files on solution explorer you need to add files to existing project by "Add Existing Item" option.

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.

visual studio keeps asking to save project file as

I am using VS 2010 and recently I moved some files around and changed paths etc.
The solution still compiles correctly and all files are able to be loaded/compiled without error however just about every time I go to compile after a change it gives me the save as dialog and asks me to save one of the projects, if I try to give it a new name or something the dialog does not exist nothing I do can make it exit apart from pressing cancel.
If I do a build straight after cancelling it works fine and I'm not presented with the save as dialog. I have verified that the project file is not read only.
Any ideas as to whats going on here.
The solution is stored in TFS 2008
You need to do 2 things
1- remove the read-only tick from the project folder
2- when a save-as window prompts at build, just overwrite the project
next time you build, the window won't pop up
You need to run VS as administrator. (right click on VS Icon- Run as administrator)
I solved the issue. When I try to save as this time it gives the error that file is being used by another process. Google Sync prevents to save so it opens save as dialog.
You should put your project under a folder not sync while working.
Are the bindings in TFS set up correctly with the new location? TFS will mark files as read only unless they get checked in. It might have been marked as such before you moved everything around, and now, isn't being checked out properly.
Also, try closing sync. files tools like google backup and sync.

Deleting a folder in TFS

I created a folder in a TFS Project under workspace "CPortalWS". I deleted the workspace, but now I would like to delete the folder in the project and the delete option is not available.
I've tried to create a new workspace mapped to the project but I still don't get the option to delete.
Is this a bug in TFS? How can I delete the folder?
Any help would be appreciated.
Deleting a folder in TFS is a little strange.
You have to:
Create a Workspace
Get the latest source for the folder (to your local machine)
Inside Source Explorer, delete the folder
Check in your changes (this is the step that deletes the folder in Source Control)
only note that delete is not an actual delete.
the folders/files are still there and kept in Version Control, for example for Undelete scenarios.
You can see them and avail the undelete function if you go to "Tools > Options > Source Control > Visual Studio Team Foundation Server" and check "Show deleted items in the Source Control Explorer" and then right-click on one of the deleted folders.
so, if you want real delete, where the folder/files actually go away you need to use the Destroy Command which is only available from the command line, see link below
http://msdn.microsoft.com/en-us/library/bb386005.aspx
When you delete in TFS, it does not remove it from TFS. It maintains a copy of the deleted files, even when you check in the deletion. This can cause some issues.
To permanently delete from TFS, you need to issue a tfs destroy command.
To do this:
Open a Visual Studio Command Prompt.
Issue the following command: tf destroy $/SourceLocation/Folder. Where $/SourceLocation/Folder is the Source location of the deleted folder in TFS.
Please note: This command will also delete the file(s) from disk.
I had a similar issue, where I had 1 folder which despite being deleted from Hard drive, was still showing as in Source Control (with a green + by the folder). It also showed me the content but if I tried to open any, an error message informed me the file wasn't there.
Clicking on any folder didn't show the delete button. I then realised that selecting a file did! If you don't have a file, create a text file and add it to the folder you want to delete (via Source Control). Click this file, note the delete shows. Select a folder and note that the delete disappears but only after half a second. This small delay is actually usable.
I clicked the file, so the delete button is enabled and hovered the mouse above the delete button. Using the keyboard, I did a CTRL + A and as soon as all files and folders were selected I clicked left mouse button. And it worked! Everything was removed, including (and this is the odd thing) the parent folder.
Create a Workspace; and get latest on the base folder; Dont forget to cloak the relevant folders. If you are going to delete the subfolders then cloak all and get latest on the base folder. So you save a lot of time in pulling files.

The project file has been moved renamed or is not on your computer

I get this error when I try to load a VS 2008 project from TFS source control:
The project file has been moved, renamed or is not on your computer
After I click OK the project says "unavailable".
What is the problem? How do I resolve this? I never had this problem before. Some blogs said to delete the .suo file but I can't locate the .suo file. I deleted the entire project on my local computer so that the next time it opens it will create a new one, but I still get same error.
What typically helps to fix it is deleting the Solution User Options aka "SUO".
VS up to 2013
In the older VS it is stored as a "hidden" SolutionName.suo in the same folder as the main .sln file.
VS2015 or later
In VS2015 the same data was moved to a "hidden" .vs folder under the same folder as the main .sln file.
I just ran into this issue using VS 2013 after renaming a project. Stanley's answer guided me to the solution:
Close VS - delete .suo file - start VS again.
Delete the .suo file in a special way.
Don't have the solution open when you delete the hidden .suo file.
Restart VisualStudio.
Open solution and Add project without error message.
TFS works like most source control packages: It remembers what it has put on your computer so that when you "Get Latest" it only has to get the chnages since your last "Get" instead of having to get absolutely everything.
This has one caveat: If you delete or rename the local files on your disk, TFS won't know that you have done this, and it will still think they are where it left them.
If you then "Get Latest" it will not bother to update the missing files.
You are then likely to get all kinds of "missing file" errors, from TFS and any other tools that look for the files.
To get around it, you need to:
If you think you might have any changes in there that you don't want to lose, copy the source folder on your PC as a back up just in case!
Right click on the project (in Solution Explorer) or folder (in Source Control)
Choose "Get Specific Version" from the context menu
Choose to get the "Latest Version" and tick the option that says (something like) "force get of files already in your workspace", which tells TFS to forget about what it "knows" and get all the files again anyway.
If you have any locally-changed (writable) files, then be careful. There is a second option that will overwrite these, losing your changes. But you have the backup, so you should be safe. It's generally better to tick this option as well to make sure that all your source code is completely up to date. (But obviously only if you don't mind losing any local changes!)
When you OK, this will forcibly get all the files in the project to your local drive, and should correct the problem.
Easiest option worked out for me is:
Right click the project & Remove the "not loaded" or "unavailable" project
Right click the solution & Add "Existing Project"
Though it's well known VS defect, definately we can handle it!
Open the solution file in edit mode
Modify the relative path to match the modified/moved physical path ..
SccProjectUniqueName1 = Source\\Order\\Order.csproj
SccProjectName1 = Order.ApplicationService
SccLocalPath1 = Order.ApplicationService
Also, makesure of correct relative path for the referring project(s)
Project("{asdasd-301F-11D3-BF4B-asdasd}") = "Order",
"Source\Order\Order.csproj", "{E25641BC-C990-40E2-8876-08AE8728F763}"
EndProject
Try opening the .csproj or .vbproj instead of the .sln. What has probably happened is the .sln (solution) file has a absolute file reference (instead of a relative path) to the compoenent project(s). You may need to re-create the .sln, or hand-edit it.
In my case, deleting the .suo file was insufficient. I discovered that my workspace configuration had an error. I discovered and resolved the problem with these steps:
In Team Explorer, "Manage Workspaces..."
Click "Edit..."
Correct the value under "Local Folder"
Finally, delete the affected .suo files per the accepted answer.
I found it easiest to create a new Solution sln file.
Clear out your workspace mappings (File -> Source Control -> Workspaces). Edit the workspace and either clear out all the mappings (more repercussion) or find the one that's associated to this server path. Then open Source Control Explorer and remap. Double click the SLN in Source Control explorer and it should get latest. Not entirely sure what has happened or what state you managed to get into, but with this should get you moving again.
I ran into this issue and was able to resolve it by obtaining the .rptproj files from a co-worker and copying them into my local directory. The project was then able to re-load.
I spent a lot of time for trying solve this problem. I did these steps : rename project, rename namespaces, rename project folder, edit .sln file, edit hidden .suo file. Project loaded but it was unrecognizable for TFS! Finally I found this guide.
If you're using Resharper and TFVC is your version control, follow these steps :
Right-click the project in Solution Explorer, select Rename, and enter the new name
Right-click the project again and select Properties. Change the "Assembly name" and "Default namespace" on the Application tab.
Right-click the project again and select Refactor -> Adjust Namespaces. Accept the changes.
Change the AssemblyTitle and AssemblyProduct in Properties/AssemblyInfo.cs
Delete bin and obj directories in Windows Explorer
Open the Source Control Explorer and rename the project's directory. This will close the solution. Let it be closed.
Open the SLN file (with a text editor such as Notepad++) and change the path to the project (there should be multiple places).
Open the Solution again. Clean and Rebuild the project.
Right click on the unavailable project and edit the project file ... chances are, you will find a hardcoded file path or a virtual one that does not match where you checked the project out to.
Kindness,
Dan
Solution for this
Again rename the project folder
Set specific version & force get in TFS
remove read only & hidden option in the latest folder (not the rename one)
Now you can open the project without any issues
Sometimes, even though you changed .sln and .csproj path, and manually rename, you might forget to check the folder name that contains the project.
It happened to me too. Apparently the csproj files were not checked in when I had created them in my old computer, and so when I downloaded the project from TFS in my new computer, the files were not there.
After checking them in using my old computer and getting them from TFS in the new computer, I succeeded in reloading the project.
In my case, because I modified .csproj file, it changed to .csproj.user .
I remove .user from the end of the file.

Resources