How do I add a source controlled (tfs) project to a solution and maintain binding? - asp.net-mvc

I would like to create three separate ASP.NET MVC solutions, all pointing to the same Model project. How do I keep changes made from one solution update the others?
Ex, is there is way in Visual Studio to "Add new project from Source Control" like you can with a whole solution?

So you are hoping to have 3 solutions that share a common project.
You can achieve this in 2 ways.
NuGet
Have the project in it's own solution and create a NuGet package of the output, your other solutions can then consume the NuGet Package.
Shared Project
A shared project is easy to do, just ensure that your shared project is available in the same workspace as your solutions.Do a get latest, You can then just right click on the solution and choose add existing project.
Any changes you make will need to be checked back into source control, these changes will then appear in each 'copy' of the project in each of the different solutions.
The shared project works fine, but you may have to make some considerations when you come to building the solutions, the main one being that if you only make a change to the shared project would you want all of the solutions that consume it to be built on check-in?

Related

How to share company wide settings across multiple team projects in TFS?

This is a problem we have been living with for a while already. Suppose that I have three files:
a FxCop ruleset, containing our basic Code Analysis rules
a Resharper .DotSettings file, with company defined naming conventions, for instance
a StyleCop.Settings file, with some of the default style cop settings disabled
How do I share these kinds of company wide settings files across multiple TFS Team Projects?
At the moment, we have these replicated in a Resources folder in each project, but this is quite a maintenance nightmare, since when we decide to update a few rules on any of these files, we have to update them in a lot of different places.
One approach I've seen is to create a team project specifically to store these files on TFS, for instance $/Core, and by some means share the files this way, either using workspace mappings or branching the project into the other projects.
I don't like this primarily because it requires manual intervention and hardcoded paths. Ideally, I'd like an approach that was not intrusive, i.e. a developer gets the project from source control and compiles without any problems. No need for separate mappings into specific forlders, setting environment variables, anything like that.
At the same time, I'd like to keep the history on these files, so it would be nice if they could still be source controlled. Since they are central to the company, it would be ideal to have limited permissions on them, and that each change was documented appropriately (changesets provide that).
Another approach that crossed my mind was to share these settings via company internal nuget packages. Say for instance that I do have this $/Core project, but instead of using workspace mapping or branching it inside the other projects, I publish a nuget package (or more than one even) containing the configuration files, and add these packages to each project that needs it. I can then use relative paths to the package folder when referencing them, and it would require no manual intervention on the developers part.
Although using nuget would probably work fine, this solution seems weird to me, since nuget packages are meant to be project specific, but this would be "whole team project" specific instead. Again, using this approach, I'd probably have to add the package to one of the projects inside one of the solutions inside each team project. This is actually quite similar to how test adapters are shared now. For instance, NUnit already support this approach. I feel I'd have to do something very similar to that if I went with an internal nuget package: each solution would have to load the package at least once.
Is there some other way to share these kinds of things across the whole company, while still maintaining them on source control? What if I loosened this constraint, and accepted that they don't need to be source controlled? Would it open up other options to share them?
If you go down the NuGet route, you could create Packages for your FXCOP and Resharper files, and then store them in a local feed.
For Stylecop you could use the existing NuGet Package for StyleCop.MSBuild and then repackage it with your own settings file.

Add existing project to solution "read only" in Visual Studio

Is it possible to add an existing project to a solution in "read-only" mode?
I got access to a big bunch of internal projects, from which I just need some functions for another solution. Since I'm new to the original solution I'd like to make sure I don't accidentally change any of the existing files and check them into the TFS.
The easiest way to do so, would be some sort of "Add existing project (read only)"-Function.
Is there any way to do so? Or are there any other ways to ensure I'm not accidentally changing any of the existing files?
I'm using MS Visual Studio 2013 Professional.
Copy the source controled version to a seperate folder, and then reference that one from you Solution. your not working with source controlled code then , so you can't break it!

TFS Linked Files Not Found

I have a core project and several sub projects. I link to files in the core project for the sub ones. I righted clicked my csproj and said existing file > add > link. Here is how my project looks:
Here is a picture of my Windows Explorer:
When I check in, I receive this error:
Could not find file C:\Users\joe_a84\Documents\JMASoftware\QuickBooks\Main\Source\Platform Support\NOP\Source\Versions\nop265\Nop265\Module\QuickBooksSettings.cs
The file does not exist there because it is linked. How can I tell TFS that it's a linked file?
There is the following question which states that symbolic links are not supported in TFS 2008 or TFS 2010. Symbolic links in TFS 2010 Source Control?
However, I did find the following ancient blog post which seems to show how to do it for TFS 2005: http://blogs.msdn.com/b/ericlee/archive/2006/07/20/sharing-files-in-team-foundation-server.aspx
That said I would highly recommend that you simply don't do this.
If you really need to share a file between projects then you should be using the branching functionality built into TFS. Typically you don't want just a single code file due to namespace and assembly generation concerns. It is much cleaner, and certainly easier to maintain, by having a separate project for those artifacts that are passed around. This way you either branch the entire assembly project; or just refer to it in it's normal place.
This is a local file level linking by another project. There is only one file at a specific subfolder. Other projects can link to the file via this approach. The problem with this approach is that from TFS viewpoint, you cannot tell if a file is shared by other projects. A good practice will be to keep such files in separate folder with name like Common or Shared etc.
People who have been using File linking across branches in Source Control would have to change their approach quite differently.
Linking between files in TFS is pretty simple. You just open the "Add existing item" dialog and search for the file you want to link in your local workspace. If you would click "Add" now Visual Studio would create a copy of the file in your projects directory. What you do instead is to choose the other option (you have a little drop down menu on the button) and add the item as a link. Thats it.
I faced the same problem. I just did undo on the file which was showing this error in the TFS Pending Changes window and checked-in. This undo did not remove the link that was added in the project. Make sure you do not undo the project file.

Source Code stucture within Team Foundation Server

I need to add some source code to TFS and having never used it before i would like to get some advice on the best way to structure it.
I have one solution 'GenericLibraries'. This is a set of class library projects which could be used by any application within the business.
I have 2 other solutions 'FormsApp1', 'FormsApp2'. Both of these solutions contain dll references
to the libraries compiled in the 'GenericLibraries' solution.
My question is how to best place this source code into TFS?
Does all the source code have to be placed into one TFS project because 'FormsApp1' and 'FormsApp2' contain references to assemblies in 'GenericLibraries' OR can i have 3 TFS projects? Or is there another standard way of doing this?
Ultimately i would like to have Continuous integration set up too, and both 'FormsApp1' , and 'FoprmsApp2' would always compile against the latest version of the assemblies in 'GenericLibraries'.
This is a single TFS Team Project, with a common library. Consider the following structure:
$/MyTeamProject/Dev/GenericLibraries
$/MyTeamProject/Dev/MyProduct/FormsApp1
$/MyTeamProject/Dev/MyProduct/FormsApp2

TFS 2008 and Common libraries folder structure

TFS 2008 and Common Libraries
I have created a Team Project called "Common Library" that will host code used in numerous different Team Projects throughout TFS. For sake of argument, lets say we have 2 distinct Librarys under the "Common Library" Team Projects, MailProject and LoggingProject. Other projects throughout TFS will be using the binary representation of these projects via branching and not the actual source code.
What is the best way to set up the folder structure for this Team Project? Do I add the project to the "Common Library" and simply "include" the bin/release folder as part of the project?
I have seen some examples of people creating a seperate "Deploy" folder. I assume this is synonamous with the bin/release folder?
We do not want the source code available in other solutions.
Currently, each project has the dll included in the project. Using a mailing module as an example, many projects need the ability to mail. The common module is very stable and mostly static.
However, what if there is a change in the mail module. It seems there would be a better way, than to check out each project and update the dll. Is it possible to allow TFS to grab the latest mail module any time a 'get latest' is called? Either explicitly or implicitly.
Unless you really require the source code for the libraries to be available in the other solutions my advice would be to include the binaries for the libraries in the projects that would use them not really having any explicit link between the two in TFS. Custom labelling of the library builds could be helpful to easily return and rebuild any chosen version of the shared libraries.
If the shared libraries require different versions for different projects then the obvious solution would to create a separate branch for every version of the libraries that need to be customised to a particular project.
TFS does not have a concept similar to SVN's 'externals' though - so if you include a branch from the shared libraries in a project and than branch that project it is very difficult to propagate changes correctly.
I suppose you could also use the Get task in the build and get the latest version of DDLs into the current project from another one, but verify if you can point of Workspace of another project (I have not tired it and MSDN is somewhat vague here). You might need to have a separate workspace for the shared project.
Yet another alternative would be to publish the DLLs for common components to a known location on every build of the shared libs and for individual builds to get whatever version is available from that common location (network share) even via the Copy task. This is simplistic and may cause problems with versioning of the common components but should work well enough in simple case.

Resources