Visual Studio Solution/Project Path issues when remapping workspaces - visual-studio

This issue is quite hard to explain, so I may need to add more details based on questions you may have.
I'm using TFS and Visual Studio 2013 for dev.
I have the following branches:
Development Branches
- $/ProjectName/Development/Development
- $/ProjectName/Development/201406 June
- $/ProjectName/Development/201407 July
- $/ProjectName/Development/201408 August
I have the following workspace mapping:
$/ -> C:\Projects
When a new month starts, I create a branch in dev, e.g. 201408 August, and set up the following mapping (in addition to the above top level mapping)
$/ProjectName/Development/201408 August -> C:\Projects\ProjectName\Development\Development
This helps me easily change my work spaces and pick which branch I want to use without having to change a LOT of references and things in IIS. That all always point to C:\Projects\ProjectName\Development\Development no matter what branch I work on.
Now once I'm done with my development for the month, I make sure all work is checked in (I always check in AT LEAST once a day). I then remove the work space mapping, so that everything is mapped only by the top level mapping again. I then merge Development/2014 August to Development/Development.
Once I'm happy with any merging I need to do, I check in Development/Development and the job is done.
All this is exactly how I'd like it to work, but there is a snag.
For some reason, VS remembers that the projects resided in Development/201408 August, so when I open the Development/Development solution file, the project points to Development/201408 August.
I then remove the project(s), and add it from the correct location (Development/Development). If you then look at the properties, it's changed it again to Development/201408 August again, DOH!
I found someone with a similar issue, and they said to:
Remove the offending project(s)
Save the solution
Close Visual Studio
Delete the *.suo file next to your solution
Re-open VS
Re-Add the project(s)
Save the solution
And the it would be fixed. This is true, it sorts out the problem, but I'm hoping somebody can tell me why this happens, because I have over 35 projects in my solution, and I sure as hell can't do this every month, it takes forever and is extremely annoying.
I do make sure to get latest versions again after the work space mapping changes. I also tried Get specific with overwriting all files. Nothing seems to work...
Any ideas?
EDIT
Forgot to mention, openening the sln file as XML, the path to the project is actually CORRECT, but when viewing the properties on the project from within VS, it's incorrect.

Related

TFS re-add Visual Studio 2010 project

I have a project that is source controlled using TFS. I was doing some coding on my laptop when, unfortunately, my computer crashed and I ended up having to re-install Windows. I was afraid that all my code would be lost, but thankfully I was able to restore the code files.
My problem is that now I need to commit the changes to TFS. Currently the projects do not have any source bindings. I can't overwrite the current code base because there is work that has been done since my crash by other devs.
How can I add the changes I've made to TFS?
The way i've done something like this is kinda hackish, but what i usually do is get latest from TFS onto my laptop, and checkout all of the code from the project in question. Then i take the changed code and copy it over that folder, check it in. TFS should be smart enough to only really affect the actual code items that have been changed. You can see in the history the actual files that got changed to be sure.
If you know the exact files that you need to update, then that will make things much easier, because you can do the above steps, but then just check out the particular files you know of. You can do a compare between them and your new code to make sure that you don't overwrite anything your other programmers have done. Again, hackish, but i don't know of any streamlined way to do this.
You might want to make sure that you download the TFS visual studio extension, since that will give you rollback capability.

Removing soltuion items from TFS2010 and "action caused a check out of the file(s)..." message

My solution structure looks something like this:
MySolution
FirstProject
SecondProject
SolutionFolder1
SolutionFolder2
SolutionItem1.txt
SolutionItem2.txt
Then there are two workspaces with
this solution at the same version
used by two users on different
computers.
A solution item is removed in the first workspace and the change is checked in into TFS.
In the second workspace the latest version is get from the TFS (the workspace is without local modifications and no files are checked out). Visual Studio displays this message:
Your action caused a check out of the
file(s) C:\MySolution \MySolution.sln,
and a new version from source control
has been loaded in the development
environment.
Now, there are two items in pending changes in the second workspace: solution file is checked out and the solution item is deleted. After undoing these changes and getting latest version, they appear again. These conflicts are resolved only during checkin which is a little bit confusing.
Is there a way how to get rid of this TFS oddity? Thanks.
I cannot find any answer but there is a workaround. Solution probably is not the best place to store complex folder hierarchies with a lot of files. When these folders and files are moved to own VS project then everything works well.

Make Visual Studio auto reload solution when project files change

On the current project I am working on, there is, at the moment, a large churn of code, which means updating from source control can mean at times many csproj file changes. As we all know, VS2010 doesn't have a "Reload all" button, but you must reload each project and confirm each reload.
Is there a method where either the project is auto-reloaded or the IDE can detect this and ask for a solution reload?
Finally found a solution:
http://lostechies.com/jimmybogard/2011/01/27/reloading-all-projects-with-vscommands/
Quoting from the site:
Quite often I’ll find myself working
in situations where multiple projects
have changed, and Visual Studio asks
to reload them, one at a time. This
happens when I’m working a lot with
source control, and doing things like
switching branches, performing merges,
or just integrating upstream changes.
I have to click “Reload” a million
times for each project that changed on
disk, and it’s quite annoying. On top
of that, VS forgets which files I have
open, so every file that I was working
on gets closed.
I may be the last VS user to find out
about this, but a free lite version of
the VSCommands plugin is available on
the Visual Studio Gallery that does
just what I need – reload all changed
projects at once, preserving which
files I had open:
It's a pain, but the best option I've found is to Close the solution before Getting the latest source code.
If there are more than two changed projects, it is faster to manually unload&reload the entire solution than it is to Get and wait for it to unload&reload the affected projects only - reloading projects is achingly slow (even disregarding having to click the OK button for every project that changed).
(In my mind the real question is: Why does it ask that question at all??? If you Get the latest source code, there is absolutely no sane reason why you would want to only use part of it. It's like a petrol station attendant saying "You've bought some fuel. Would you like me to now actually put it in your car, or shall I just pour it out on the ground?")
Well, that doesn't work if your references paths changed in the csproj file and your using something like the sysinternals junction tool to change a symlink. E.g. tool switches D:\Projects symlink from D:\Baselines\1.0\Prjects to D:\Baselines\2.0\Projects , and because someone changed the folder structure between 1.0 and 2.0, your .csproj file suddenly points the dll path from ....\References\some.dll to ....\References\3rd-Party\some.dll . I know that is a special case, but happens (e.g. in my company).
There is an alternative solution though, one which I highly recommend as it has other benefits, too: the not-so-well-known VS 2010 Extension Solution Load Manager. It defers loading of Projects to the background, or until manually loaded, improving solution load time a lot for large solution files. It has this "reload solution" button in it's menu (unfortunatlely there seems to be no shortcut) which then reloads all solutions from scratch, skipping/backgroundloading the solutions you set. A Microsoft guy commented on his blog that they wanted to include something similar into VS 2010, but the feature didn't quite make it.
Sure, it may take longer then "just" one click and updating 100 documents, but it solved my problem of (relative) reference path changes, and gives a nice speed boost every time I open an at least medium sized solution.
Edit as of Oct 2013
VS2012 includes this functionality by default. At least the async loading stuff. The "don't load at all" functionality is unfortunately only possible by using manual "unload project" in VS2012. But as pr-project memory consumption did go down with VS2012, it's not that big of a deal anymore.
If you have checked the option "detect when file is changed outside the environment" in the "Documents" section of options, projects and files are reloaded when changed. It works for me when switching branches in git.

TFS 2008 erratically showing past builds

We do use TFS to do automatic build and tests with our checkins.
Today we verified old builds we have done last week. We were seeking one specific : 2010/10/27 (5). For some kind of reason it was not showing when we opened TFS/Project/Builds in visual studio (or the build tab in TFS Web).
Here is a screenshot that shows what we saw:
(Bigger screenshot here : http://i55.tinypic.com/35lt1z6.png )
For some reason some builds are jumping, tho I can attest that each builds are iterating and on the 27th there was a 5th build.
Is there something that can prevent TFS from showing complete builds history ?
Did you check the retention policy? It removes builds when there are more then N builds.
Look at the Date Filter drop down at the upper right corner of your screen shot which is currently set for last 7 days.
It may sound obvious, but if you didn't lock the build, then it's also pretty easy to press delete on it (although hopefully the confirmation dialog would save you).
If the build's drop folder is still in your file system, then pretty much all the information on the build is still safe, even if the build has been dropped from your TFS database.
(The only problem I've seen with TFS (2005/2008/2010) is that even if you delete builds, they still show up in the WorkItem user interface so testers have to try to choose the build name from a nearly infinite list - so of course they type something sort-of-like the build number into the field. Sigh)

Visual Studio, svn and merging .csproj and .sln files

Anyone had any success getting SVN to merge Visual Studio project (.csproj) or solution (.sln) files that have been edited by two users? Example
User A checks out project
User B checks out same project
User A adds a file
User A commits changes
User B adds a file
User B commits changes
Seems to me that at step (6), svn, Tortoise, Ankh or whatever should detect a conflict and either merge the two project files automatically or, more likely, prompt User B to resolve the conflict. Currently, we're seeing changes made by User A obliterated when User B checks in, resulting in bad builds, deploys, etc missing features that had been added before the last checkin.
Since the project files are XML, why is this an issue? Am I missing something here? I've searched the archives here and googled to I can't google no more, but haven't come up with a good solution.
How do you think you trick SVN into performing step #6? It seems you misunderstood what goes wrong. SVN will never ever commit from a working copy that's not up to date, so step #6 won't work without user B previously updating and merging user A's changes. Honestly. Try it.
I guess what happens instead is this:
A checks out project.
B checks out same project.
A adds a file.
A commits changes.
B adds a file, but forgets to save the project/solution.
B tries to commit changes and gets a message he should update first.
B updates.
B switches back to VS. VS tells him the project/solution changed on disk and asks whether he wants to a) reload from disk and lose his changes b) override the version on disk.
B doesn't understand, doesn't try to understand, considers his changes valuable, and picks b), overriding the changes on disk.
B still doesn't try to understand and thus does not diff the version he has on disk with the last committed one and thus misses that he overrode A's changes.
B Checks in, overriding A's changes.
I've seen this happening once in a while, usually with a user B who does not really understand SVN's (or CVS', FTM) workflow.
So here's a few hints:
Don't update unless you have saved everything ("File"->"Save All"; for me, that's Ctrl+Shift+S). In case you have made that mistake and you're stuck, do override the changes on disk and then merge the lost changes manually. (It might also work to update the project/solution file back to version N-1, and then to HEAD again, in order to have SVN perform the merge.)
Don't commit without checking which files you changed and having a quick look at the diffs to see whether the changes are what you expect.
Commit early, commit often. The more developers work on the same code base, the more likely you get conflicts. The longer you change your working copy without updating, the more likely you get conflicts. Since the number of developers usually is out of your hands, the update frequency is the one thing you can use to reduce the probability of conflicts.
I second sbi's answer. One possible solution is to always update from within Visual Studio, at least if you use VisualSVN (I'm not sure how AnkhSVN copes with this situation).
VisualSVN will block visual studio during the update operation, and make sure any changed projects are automatically reloaded, so users can not ignore the external changes.
A rather radical but efficient solution is to use a tool to generate those solution files from a meta-definition and then putting only the meta-definition under source control, not Visual Studio project files (which are a nightmare to merge).
In my team we use MPC to do this. We have:
a bunch of .mpc files for project descriptions,
a .mwc file for workspace / solution description,
a small .cmd to generate Visual Studio files.
Since they are all hand-edited text files, we no longer have problems with Visual Studio mixing up everything.
The drawbacks are an extra-tool and the need to regenerate the solution files when files are added or removed but there are some additional benefits too:
project configurations are centralized: for instance, changing a compilation flag is done in a single place instead of on a per-project basis,
this can accomodate multiple build systems (we currently use Visual 2003 and 2005 but this also works with gcc and others).
From my experience, althgough setting up the tool can be a bit painful (but it all depends on the size and complexity of your project), this is clearly worth it.
Note that MPC isn't the only tool for this purpose. Others exist, such as CMake.
You can also try to reduce conflicts by ensuring that your project files don't list every individual file inside the project. This will avoid the project file from being changed in first place when a user adds a file.
You're free to use wildcards inside a project file: see MSDN
Example:
<ItemGroup>
<Compile Include="Src\**\*.cs" />
[...]
</ItemGroup>
It is sad that Visual Studio doesn't encourage this kind of project setup and instead opts for listing individual files.
This is very tedious and tiresome so you just have to plow through it. You will sometimes keep the local working copy since it has all of your custom projects added. However, in other cases you will want to merge in all new items from the Base solution so you end up with everything from both solution files. For readability it is best to place all base product additions before customization additions.
Do not worry that the first portion of the GUID is identical for projects, but it is the last portion that will be unique.
Fissh

Resources