I am creating a new project in c# visual studio 2015. I want to use some codes from couple of existing solutions. How to approach this situation in a best way?
I have never worked on multiple solutions in VS2015 before.
Appreciate some inputs.
I am trying to follow the below link:
https://blogs.msdn.microsoft.com/habibh/2009/06/25/walkthrough-adding-an-existing-visual-studio-solution-to-another-solution/
Thanks
A solution is made up of one or more projects. You should aim to structure your code in to projects that each provide a set of cohesive functionality, which can then be re-used in multiple scenarios.
All you then have to do in your new solution is to say Add -> Existing Project ... and browse to it.
If you're not quite structured enough for that at this point then you can always create a new project, and within the project say Add -> Existing Item and include existing individual files, but if you're doing that then I would recommend selecting the Include As Link checkbox in the browse dialog, so that you are not making a copy, just referring to the original file.
in a solution you can add many project. Just add old projects to new solution
Our projects in our company are all built based off a thing we call a 'Project Scaffold'. It's got all the base required code for all sites, basic folder structure and all other things similar to that.
At the moment, we have a repository for this 'Project Scaffold' and each time we want to create a new project, we copy this project into a new folder, and rename all occurrences of the name 'ProjectScaffold' within the project. As you can tell, this is quite time consuming and can sometimes cause errors if we miss out a single occurrence of 'ProjectScaffold'.
This project will need to have all the default dependencies which is why having a full project that we copy is working for us at the moment.
I have looked into the possibility of creating a visual studio template but I can't seem to find a good way of accomplishing it.
We have been thinking if there was a way to possibly implement it through a NuGet Package, however I feel as if this would be either extremely difficult or impossible.
If possible, it would also be something that would be usable in Visual Studio 2011
Simply File-->Export Template :)
You can then customize the generated zip file to suit your needs.
More on this on the Creating Project and Item templates on msdn
My team is creating some standard VS solution templates. We have a well-defined project structure, resources, etc. that we need to use every time we start a new project and this is the perfect solution. The basics work nicely.
However, as well as defining folder structure (etc.) it would be nice to be able to import a number of projects from VSS/TFS. We have a number of shared assemblies that will be used by all projects and it would be awesome to add a reference to these projects when creating a new project via our template. Can anyone tell me if this is possible and, if so, how it can be achieved?
I think there are 3 types of items you might want to templatize (is that a word?).
New Solution
New Project added to a solution
New item added to a project
I'm not sure whether its possible to add existing projects to the solution that is created when a project template is run. http://msdn.microsoft.com/en-us/library/ms185308.aspx shows how to create multiple project templates. You may have to either manually add them to the solution or create a script that modifies the .sln file to do that part.
Adding an assembly reference to either a project or item template is easily doable. The project template is pretty simple since you just need to modify your .vstemplate file for the project template(s). See http://msdn.microsoft.com/en-us/library/ms171405.aspx for reference.
Adding a new assembly reference when you add a new item from a template is a bit harder but can also be done. See http://msdn.microsoft.com/en-us/library/ms185290.aspx for more.
Have fun!
Being new to VS, how may I think of these two concepts, what is the difference?
I find some missing information in the other answers (at least for people who come from other IDEs like, say, Eclipse) . To say that a solution is a container for projects is only part of the thing. The conceptual feature of a VS project (what determines its 'granularity') is that one project produces one output: typically an executable or a library (dll). So, if you are going to code three executables that uses related code, you'll create one solution and at least three projects - probably more.
A solution is a container for projects, and tracks dependencies between projects.
Just to come up with a metaphor..
A solution is like a house, a project like a room. Each room provides a piece of functionality whereas the house, a container of rooms, provides the means to link the rooms together and organize them appropriately.
Kind of corny but I made it up on the fly, so bear with me :)
It doesn't help that Visual Studio seems to make things more confusing. "New Project" actually creates a new SOLUTION containing a project. "Open Project" actually opens a solution containing one (or many) project. (The file menu says "Open Project/Solution" but it really is opening solutions. There is no "Close Project" only "Close Solution" which is accurate.
So, in VS you are always working within a solution. Many solutions contain only one project and newer developers are likely to think of them as the same thing. However you can add other projects into a solution.
In case anyone decides to scroll down this far... I thought the MS docs did a pretty good job at describing the differences. I've copy pasted (and rephrased) the relevant bits here:
When you create an app, application, website, Web App, script, plug-in, etc in Visual Studio, you start with a project. In a logical sense, a project contains of all the source code files, icons, images, data files and anything else that will be compiled into an executable program or web site, or else is needed in order to perform the compilation. A project also contains all the compiler settings and other configuration files that might be needed by various services or components that your program will communicate with.
You don't have to use solutions or projects if you don't want to. You can simply open the files in Visual Studio and start editing your code.
In a literal sense, a project is an XML file (.vbproj, .csproj, .vcxproj) that defines a virtual folder hierarchy along with paths to all the items it "contains" and all the build settings.
In Visual Studio, the project file is used by Solution Explorer to display the project contents and settings. When you compile your project, the MSBuild engine consumes the project file to create the executable. You can also customize projects to product other kinds of output.
A project is contained, in a logical sense and in the file system, within a solution, which may contain one or more projects, along with build information, Visual Studio window settings, and any miscellaneous files that aren't associated with any project. In a literal sense, the solution is a text file with its own unique format; it is generally not intended to be edited by hand.
A solution has an associated .suo file that stores settings, preferences and configuration information for each user that has worked on the project.
A Solution can have many Projects.
The Solution can also handle managing the dependencies between its different Projects...making sure that each Project gets Built in the appropriate order for the final Solution to work.
A project contains executable and library files that make up an application or component of an application.
A solution is a placeholder for logically related projects that make up an application. For example, you could have separate projects for your application's GUI, database access layer, and so on. The projects would be specific divisions for your program's functionality, and the solution would be the umbrella unifying all of them under one application.
A solution is a readable text file whose extension is .sln and having a structured content that describes the projects that it contains. A project is a readable XML formatted text file whose extension is .vcxproj and having a structured content according to its XML schema, and whose primary purpose is to contain the listing of source codes filenames and their dependencies or references to other project's source codes as well.
Solutions are containers for projects - you can also use them to organize items that are used across different related project (shared dll's and such).
Solutions are containers used by Visual Studio to organize one or more related projects. When you open a solution in Visual Studio, it will automatically load all the projects it contains.
When you create a new project in Visual Studio, it automatically creates a solution to house the project if there's not a solution already open.
You can set dependencies of projects on other projects in the solution. The dependent project is build after the project it is depending on is built.
For more details refer - https://learn.microsoft.com/en-us/visualstudio/ide/quickstart-projects-solutions
If you are from an Eclipse background you would probably go to build path of a project and add a dependency on other project or add an external jar. In VS you can do that in a single container called solution where all related projects are grouped together.
Eg. Let's say you are build and android and iOS app in xamrin, there would be some common code and resources that could go in a separate project and then your android and iOS projects can depend on this common code project. Also you could have projects to test these projects etc.
In the past I have created ItemTemplates for classes that I regularly use in VS2008. I want to create a template for a solution that will have two projects, a Web Site and a Class library.
I have not been able to find any clear instructions on how to do it. I am not sure if it can be done. Does anyone have any links to a possible solution.
Thanks
There are detailed instructions on MSDN for creating custom project templates in VS2008.
-Edit-
There is no such thing as a "Solution Template." There are Item Templates (for new files), and Project Templates. However, I think what you may be looking to do is to create a specific type of Project Template called a Multi-Project Template.