Visual Studio Solution Template - Link Source Control Projects - visual-studio

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!

Related

C# VisualStudio 2015 how to use code from existing solution in to the new solution

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

Is it possible to include by default project property sheets to new projects?

So that every time I create a project using the libraries I usually use I won't have to manually add the sheet.
You can do this, but I advise against it. Main reason being it will make your project files unusable on other machines unless you also force your solution on them. Second reason you cannot expect all your projects ever are going to use the same libraries/versions/configurations of those libraries so after a while it might become unmaintainable.
You are imo better of creating a small utility which copies a project from a template you create with all imports and then changes guid and project name. Or create a template for VS which does that.
Anyway: a possible solution is to add an msbuild file which imports all default property sheets you need into the $(VCTargetsPath)\Platforms\Win32\ImportBefore\ directory (create it if it doesn't exist). The file has to have a .targets extension. More info here for example.

Solution/MultiProject Template in VS2010

Looking to make a Solution/Multiproject Template.
While I'm aware a solution template does not exist, I've been researching/trying with some of success. (Link from here (http://stackoverflow.com/questions/2717110/how-to-create-a-solution-template-in-vs2010) have been a big help.
The only issue I'm facing is that, when creating a project from my template, the solution contains brand-new copies of all of the projects involved. What I require is that only ONE project is made as a fresh copy, and that the other projects in the template should reference already-existing projects.
I've made single project templates that hold the DLL references to other projects (which is fine, but it's not what I need.) I need a multi-project template where all but one project involved reference already existing projects...
How would I go about this?
edit:
I'm also finding that any dbml designer.cs that's added to a project are not included in the newly generated solution/projects. They are copied across, but I then have to manually include them in the project. Why is this, and how do I get araound it?
How about using the Feature Builder Power Tool? http://visualstudiogallery.msdn.microsoft.com/67b720f4-9a50-41cb-86a2-82e33b7c5fc4/
It should give you all the freedom to create whatever logic you want during solution setup...
So I couldn't find a workaround for this issue.
What I have managed to do though is make a decent enough template that should be run once, with all references (being relative) pointing to an outside lib folder.
This means I can use the template on a new machine, copy some dlls to a new lib folder, and then work away from there. Not an ideal solution, but it works...

Visual Studio solution structure using Codesmith frameworks (NetTiers / Plinqo)

I have been using the Codesmith framework NetTiers to generate a DAL etc., into a folder called, say, 'NetTiers', outside my main project's folder, and referencing the DLLs within that folder from my main project.
I've started using the Plinqo framework, and want to use the generated files from that framework within the same project as the one I'm using with NetTiers. (The reason I'm using both frameworks is that I want to get/learn the newer LINQ goodness from Plinqo, yet also have the familiar NetTiers code DAL, BLL syntax available, for compatibility.)
My question is: what's the best Visual Studio solution and file structure to use when using Codesmith templates like these? Should the frameworks' generated code be contained outside the main project and added as projects to the overall solution? Or should each template's generated code have its own solution? Should the generated files be within the main project's file structure?
I've tried combinations of each of these, and they each have their pros and cons. I'd like to know if there's a tried and tested pattern.
When it comes to .netTiers, I always compile the generated solution and add the assemblies as references to my project. This makes it much easier to upgrade/diff and regen.
However, there are going to be some cases where you would want to add your custom logic so keep this in mind.
Thanks
-Blake Niemyjski
I tend to just keep the .csp and the generated folder outside of my main app's folder. When adding a reference Visual Studio copies in the .DLLs from the built generated code. All of the generated projects sit under a main folder such as D:\CodeSmith Projects\
If you want to version control the .csp file it might be beneficial to move it in with the rest of your version controlled app files to tie it all together.
We put the generated projects inside our solution. In fact on my current project I generated the nettiers files to the location that I wanted the files to be, and Started adding my own project files to that...But we have always kept the files in the solution, that way if i need to add something to the code in the concrete classes I can do it without having to open a whole new project.
We have tried both scenarios. We settled for including the assemblies in a dependencies folder, which was shared by multiple projects.
We had problems with TFS when the projects were included in the solution. the downside, is that you can't so easily step into the .NetTiers generated code when debugging, though after a while you get used to this, and accept that whatever is in .NetTiers stays within .NetTiers!

Can I create "Solution" level items in a Visual Studio Project Template?

There's a lot of great information on MSDN dealing with creating Visual Studio templates. I've been specifically working through a Multi-Project Solution (http://msdn.microsoft.com/en-us/library/ms185308(VS.80,printer).aspx)
I have everything working in my template (4 projects + 2 Solution Folders - 1 for Tests, and 1 for Libraries that I'm referencing). I have no problem adding projects, or solution folders through the template, but I've hit a wall trying to add dll's and other resources that are not in a specific project, they are just solution level items.
Has anyone dealt with this before? Thanks,
I have been trying to do the same thing for a while now and have had no luck finding a native way to do it. The way I am doing it currently is having a custom project template that adds the items to the project and then through a VS Wizard associated with that template using convention to move the files to the solution level and removing them from the project level.
This hack might be 10 years late, but thought I'd add it anyway. Its less convoluted than creating a VS Wizard to drive the operation of adding solution level items.
Basically I add a dummy project to the multi-project solution template, named "_SharedFiles".
In the other projects that need links to any of these files, I update the [project].csproj to simply refer to the file in the shared files dummy project.
<Link Include="..\_SharedFiles\GlobalAssemblyInfo.cs" />

Resources