How to prevent "There appears to be a discrepancy between the solution's source control..." without changing the .sln file - visual-studio-2010

Note: I saw "There appears to be a discrepancy between the solution's source control ...." , but this doesn't apply, as I wish to fix this without changing the .sln file.
For some reason, any time I open a solution which has in the sln file:
SccTeamFoundationServer = http://servername:8080/tfs/defaultcollection
SccAuxPath* = http://servername:8080/tfs/defaultcollection
My copy of VSS insists on switching it to
SccTeamFoundationServer = http://servername:8080/tfs/
SccAuxPath* = http://servername:8080/tfs/
Saving these changes does fix everything for me, but everyone else using the same version control server is fine with the 1st version but not the second version. I wish for my computer's version control server/paths to be consistent with that of my coworkers.
Everyone is using Visual Studio 2010 with Visual Studio 2010 Team Explorer.

I had this problem with a Solution containing *.vcxproj project files, that were previously migrated from VS2008 to VS2010.
The path to TFS was defined in both the .sln file and the .vcxproj files.
The simplest fix was to update the *.vcxproj project files to use the SAK keyword.
ie update from the format:
<SccProjectName>$/MyProject/Directory/abc</SccProjectName>
<SccAuxPath>http://servername:8080/tfs/defaultcollection</SccAuxPath>
<SccLocalPath>.</SccLocalPath>
<SccProvider>{11111111-1111-1111-1111-111111111111}</SccProvider>
to
<SccProjectName>SAK</SccProjectName>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
<SccProvider>SAK</SccProvider>

Have you tried connecting to http://servername:8080/tfs/defaultcollection instead of http://servername:8080/tfs/ in your Team Explorer settings - Team Project Connection? Try to do that, let someone who have the http://servername:8080/tfs/ version check-in, remap your local instance then get latest.

I just had this exact problem. I finally solved the issue by disconnecting from TFS and reconnecting:
In Team Explorer (View-Team Explorer), right-click on your TFS server name and click 'Disconnect'. Then click Team-Connect to Team Foundation Server...
I did not have any pending changes when I did this. I would check in your code or at least shelve your changes before doing this to decrease the chance of losing work.
The computer that this happened on had been working fine for over a year, but I guess Visual Studio somehow cached the name as http://servername:8080/tfs/ instead of http://servername:8080/tfs/defaultcollection and disconnecting and reconnecting to TFS reset VS to the correct path of http://servername:8080/tfs/defaultcollection. On my server (and I would guess on everyone's) http://servername:8080/tfs/ and http://servername:8080/tfs/defaultcollection point to the same thing. Raymund's solution didn't work for me - I had the same problem that Brian had with it.

Using Visual Studio you can solve this problem by unbinding and binding the solution and/or projects. Try this:
Open the problem solution in VS (did this in VS2013 just now)
Commit anything you need to commit (let's keep it simple - nothing to merge/checkin)
If there are any pending changes then undo all pending changes to all the projects in that solution and any changes to the solution itself
Go to File -> Source Control -> Advanced -> Change Source Control
Select the problem projects and click "Unbind"
Click OK and close the window (THIS IS IMPORTANT - if you don't click OK VS doesn't update the solution properly)
Go to File -> Source Control -> Advanced -> Change Source Control
Select all the projects you unbound in #5 and click "Bind"
Click OK and close the window
Check in your Solution & Project changes
Close the solution and open it back up and everything should be fine now

Also try opening the .sln file from Source Control Explorer, I think that may have been what solved the issue for me.

Related

VS2017 15.7.5 doesn't automatically check out files

I've recently noticed that when I go to make a change which needs a file to be changed, VS2017 (Professional) has started to produce a popup saying:
The file <filename>, which you attempted to edit, is read-only on disk.
Would you like to make the file writeable or edit it anyway?
If I cancel this, I get a message:
The file '<filename>' needs to be checked out before it can be edited.
The file was not checked out automatically because you have disabled automatic checkout
when files are edited in the Source Control options page.
The Source_Control->Plug-in_Selection is set to Visual Studio Team Foundation Server; I haven't changed the Options under Source_Control->Environment; both Saving and Editing are set to Check out automatically.
As far as I know, apart from recently updating from 15.7.4 to 15.7.5, I haven't changed any settings. Is there some setting elsewhere which affects this?
Note, my installation of VS2017 Pro Preview, 15.8.0 preview 5.0, does the same thing and running VS2017 as Administrator does not fix it.
Update:
Visual Studio 2015 has no problem checking out the same files in the same local workspace. That is, if I open a solution in VS2017, edit a file and go to save it, I get the above messages. If I then cancel the edits and try the same thing on the same file in VS2015, the file gets checked out. Hence the problem is with VS2017 and not the files themselves.
OK. After further searching I found a pointer to the answer in this answer. Somehow, my VS2017 instances have gone offline from the TFS server. The menu option File->Source_Control->Advanced->Go_Online sorted things out.
My solution had become unbound from the source control server.
To resolve I used menu options File->Source Control->Advanced->Change source control... Select project or solution without Server Name or Server Binding. Click Bind.

Why can't Visual Studio 2013 determine the workspace for my solution?

Earlier today the TFS server where I work went down. As a result, when I tried going into visual studio 2013 to work on a project that managed though TFS Visual Studio detected that TFS was inaccessible and accessed the solution in offline mode. Later on in the morning the server was rebooted and was online and operational. However, when I try to go online with the solution I get the error message stating "Unable to determine the workspace for this solution". So I went ahead and verified that the workspace is correct with all the bindings from the associated source control folder to that of my local folders. So to try and fix the issue I did the following steps:
I completely disassociated the solution from source control even though its offline.
Rebinded the solution to source control. At this point all locks were visible on the solution and the files that were checked out.
I got the latest version for the project and and updated my local solution.
Rebinding the solution worked to fix my initial issue. However, every time I exit visual studio 2013 and go back into the solution it loses all the bindings and it's unable to determine the workspace for the solution. Has anyone ran into this before? Is there something that I am overlooking? Any help will be greatly appreciated.
Please Note, I have read though some of the posts already on stack-overflow and I have not found one that addresses the issue with Visual Studio losing the bindings on each start-up.
Quit Visual Studio.
There is a Registry-Entry
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\TeamFoundation\Instances\\[[NameYourOfTFSServerHere]]\Collections\\[[NameOfYourProjectCollectionHere]]
Change Reg_Dword Offline from 1 to 0
Delete the .suo file of the Solution
Reopen your Solution should fix it.
Make sure "show hidden files" is enabled, then delete the .suo file in the solution's folder (while VS is closed, of course)
Quit all Visual Studio instances and delete TFS cache at "c:\Users\\AppData\Local\Microsoft\Team Foundation\5.0\Cache"

Visual Studio “Go to definition” disabled or gray out

Visual Studio's Go To Definition is disabled and F12 doesn't work. Other commands like Alt-F12 may continue working.
Close the solution.
Delete the intellisense database file for the solution: [solution].ncb or [solution].suo
Reopen the solution.
Optional: Rebuild the solution.
Note that this can also be as a result of disabling database for C++/C#.
In Tools - Options, type "IntelliSense" into the search box, and click on C/C++ - Advanced. In the Browsing/Navigation section, change Disable Database to False, if it is not so already.
After re-enabling, close and reopen to force rebuild.
NOTE: IntelliSense will produce large files on disk (*.sdf and ipch) that should be excluded from Git, for example.
I know the solution has been resolved. However, I encountered the exact same problem. I searched internet. None of the trick works including this one.
Eventually, I figured out. I right clicked on the file that had the problem. I included the file in the project. Isn't that obvious. Actually not, the file has been included for a week. I have been working on that file more than 7 hours a day for the whole week. Up till yesterday 6:20 pm.
Oh, I could not compile correctly this morning. There were tons of syntax error message yesterday. This morning, I was able to compile. Strange. right? Then my go to definition was gone.
Took me a while to find out cs and designer.cs were certainly excluded, but aspx file was.
I solved the problem. Did my figure slip? I don't know.
That is one thing people check. Either yourself, someone else, or system accidentally exclude the cs files without the knowledge. I know it is strange, but it solved the problem. There are weird scenarios in Visual studio. People can present 200 solutions. They work for 99% of time, but not our cases. I just bring one more scenario
I encountered this in Visual Studio 2010.
For me, this solution did the trick
Close all the files.
Reopen the files.
and you are good to go.
This also happens, if Visual Studio has files opened, which are not in the current Solution.
I don't know how I got to this state, where files of a different solution where open as I didn't open them manually, but a quick check of the file path showed that those weren't files of the opened solution.
Therefore, "Go to Definition" was disabled.
I found that I had to remove my TFS mapping:
VS 2010 > open Team Explorer > Drill into the team project > double click source control > right click on the team project in the left pane and do "Remove Mapping" > after everything was removed I manually went to the local folder and deleted any lingering files > back in source control explorer I re-mapped to the same local folder and re-pulled all the code. Now the "go to definition" works again.
Not sure why I had to do this...
Check dll in references which is yellow. Remove it and add again.
I've just had this happen with a CMake-based C++ project in Visual Studio 2019. Everything was fine yesterday, then when I opened it up today all the Go To Definition/Declaration etc options were greyed out everywhere in every file in the project, even for things defined within the same file (and the syntax highlighting didn't look right either). It did work if I opened one of the .cpp files separately on its own (without loading the Project/Solution).
I tried various things including the answers here and telling it to generate the CMake cache again, but what finally fixed it was actually deleting the CMake cache. The Delete Cache option didn't seem to work (all the files were still there on disk, and there was some sort of failure message in the Output window) so I just deleted the entire "out" directory from the project directory (well, moved it somewhere outside of the project, just in case). Loaded up Visual Studio again, it rebuilt the cache again automatically and IntelliSense immediately started working again! I just had to wait 5 minutes for it to compile everything again when I wanted to run the project.
Maybe it wasn't necessary to remove the entire "out" directory, but when I clicked "Open in Explorer" under the "CMake Cache" menu it opened the actual build directory (which was the only thing in the "out" directory anyway) so I assumed the entire thing was related to the cache and was getting too fed up with it to try to narrow it down further. It's probably only certain files within that directory really.
Tried all the above solutions in my VS2019, nothing worked for me. Than I've noticed an update sign on the bottom Right corner. After updating the VS all options were restored.
Simple just check your bottom left corner of Visual Studio if Restricted turn it as a trusted and your problem will solve.
In my case due to my project is mapped with TFS so I am unable to go to definition also my project files showing read only when opening from Solution. So I have move to my root folder mapped with TFS and then right-clicked on folder > Go to properties > Attributes section was Read-Only I have unchecked it and clicked Apply. Reopen visual studio. Everything is now working fine.
I faced the same Issue in my Visual Studio 2019 version.I followed the below Steps:
Go to references folder in the solution.
Click on Manage Nuget packages.
Click on Browse.
Search for 'Microsoft.Net.Compilers'.
Click on Update.
This Worked for me.
In my case, another Visual Stuidio was opened (not closed succsessfully). Close all examples of VS, then re open solution.
Just open the Solution using Windows Explorer, instead of opening it from inside VS...

The Open from Source Control operation ... then Visual Studio opens up latest from source safe

When I open a project in Visual Studio I get the following dialog box message:
The Open from Source Control operation is still in progress but you can start working now. The rest of the projects will be retrieved asynchinously.
Then it gets the latest from soruce safe, overwriting what ever I had. How do I stop VS2010 / source safe from doing this
It's probably that you enabled "Get everything when a solution or project is opened" at Visual Studio Tools->Options->Source Control->Evironment. If so, uncheck it and then try again.
I stoped visual from doing this by deleting *.vssscc and mssccprj.scc
I faced the same issue today and when nothing else worked I simply removed source control related lines from solution file of my project. In my case it was a section in .sln file starting with line
GlobalSection(SourceCodeControl) = preSolution
Note: once you do this you have to manually connect with your relevant versioning system.

How to work offline with TFS

Our TFS server has some temporary connectivity issues right now, and as such VS has gone unresponsive, leaving 50+ developers unable to work!
Is it possible to switch TFS into an offline mode in the event of such an issue?
See this reference for information on how to bind/unbind your solution or project from source control. NOTE: this doesn't apply if you are using GIT and may not apply to versions later than VS2008.
Quoting from the reference:
To disconnect a solution or project
from source control
In Visual Studio, open Solution
Explorer and select the item(s) to
disconnect.
On the File menu, click Source
Control, then Change Source Control.
In the Change Source Control dialog
box, click Disconnect.
Click OK.
The 'Go Offline' extension adds a button to the Source Control menu.
https://visualstudiogallery.msdn.microsoft.com/6e54271c-2c4e-4911-a1b4-a65a588ae138
plundberg: The "disconnect" button is only available for the TFS provider starting in VS 2008. Even then, I'm not sure if it's officially supported. The recommended way to use the Go Offline feature is to [re]open the solution.
Martin Pritchard: if you get stuck mid-operation, you can force VS to timeout by pulling the network plug (literally) or running ipconfig /release.
Once you're marked offline, here's a step by step guide to working in that mode: http://teamfoundation.blogspot.com/2007/12/offline-and-back-again-in-vs2008.html
More detailed info on tweaking the behind-the-scenes behavior:
http://blogs.msdn.com/benryan/archive/2007/12/12/when-and-how-does-my-solution-go-offline.aspx
http://blogs.msdn.com/benryan/archive/2007/12/12/how-to-make-tfs-offline-strictly-solution-based.aspx
There are couple of little visual studio extensions for this purpose:
For VS2010 & TFS 2010, try this
For VS2012 & TFS 2010, use this
In case of TFS 2012, looks like there is no need for 'Go offline' extensions. I read something about a new feature called local workspace for the similar purpose.
Alternatively I had good success with Git-TF. All the goodness of git and when you are ready, you can push it to TFS.
Depending on which tool windows you have open, VS may or may not try to hit the team server automatically when it starts up.
For best results try this:
Close all instances of visual studio
Open an empty visual studio (no project/solution)
See which windows are opened by default, if source control explorer or team explorer or any other windows that use team are opened (and activated) by default, close them or switch them to a background tab.
Close visual studio
You should notice now that you can start visual studio without it trying to hit the TFS server.
I know its just an aside to your problem, but I hope you find this helpful!
If you have a solution open, and TFS is down, you might have trouble going into offline mode. If you close and reopen your solution, a nice little dialog will appear asking you if you want to Go Offline.
Alternatively if you don't want to close/reopen the solution, (as suggested by Bernie) you can install the TFS Go-Offline plugin, then click:
TEAM -> Go Offline
Simply, change the root folder name for your solution in your local machine, it will disconnect automatically.
I just wanted to include a link to a resolution to an issue I was having with VS2008 and TFS08.
I accidently opened my solution without being connected to my network and was not able to get it "back the way it was" and had to rebind every time I openned.
I found the solution here;
http://www.fkollmann.de/v2/post/Visual-Studio-2008-refuses-to-bind-to-TFS-or-to-open-solution-source-controlled.aspx
Basically, you need to open the "Connect to Team Foundation Server" and then "Servers..." once there, Delete/Remove your server and re-add it. This fixed my issue.
If the code has already been checked out by the user that if offline and they have the latest version on their local hd, then they just need to browse to the solution location and open the solution by double clicking sln file. The solution will open in disconnected mode.

Resources