Add Helper Classes to Project By Default - visual-studio

Is there a way to have visual studio add my helper classes (preferably with the correct namespace) anytime I create a new project. For example all of the extension methods, conversions etc. Its a pain to add them every time I start a new project.
Thanks
I'm in VS2012

There are 2 ways:
create a project template
create a set of library
My preferred way is to create a set of library I reuse in all of my project.
I dividet it with different scope for different kind of projects:
MyLib.Core, MyLib.Web, MyLib.Winforms, MyLib.Nhibernate etc etc
I distribute them with nuget so I can easily handle update and versioning

Related

Create 2 projects with shared code in Visual Studio

I have a winforms project, which I want to change very few stuff, and compile as a different exe (for example the icon, title, and disable/enable some features).
How can I do that? I'd rather not create a second project, since I want changes to files of one, to be mirrored in the other.
The best way that I have figured, is to create a branch with some version control system, and selectively merge classes. This way you can integrate code changes from one project to the other.

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 project reference strategy in Visual Studio 2012

I have 5 basic projects that need to be part of multiple applications. WinForms, ASP.NET, WPF depending on the needs we have.
These Projects are:
Company.Business - Business Logic DLL
Company.Business.Model - Business Models
Company.Business.DAL - Various DALs
Company.Configuration.Classes - Classes that are used to initialize BOs
Company.Utilities - General Utilities
Now i am trying to decide how i should go about when i create new UI solutions?
1) Include the projects by Add->Existing project ?
2) Copy the compiled .dlls to each solution manually?
In case of option 2 where i should do the basic development for all the above? Probably a separate solution that includes them all? and in there i should start unit testing?
My take on this is that it depends on your needs and how mature the "basic" projects are.
Your needs
If you need to look at into the code of the "basic" projects while working on the using-projects, then I'd add them to the current solution with the add-existing project method. In situations with multiple added existing projects I make a solution folder called "referenced projects" and add them in this folder.
Maturity
If your "basic" projects are still being developed (perhaps side-by-side) with the using-projects I'd also would add them in the solution as described above.
But if you have no need to look at the code then you might as well include the compiled dll in your client-projects.
Harry

MvcScaffolding a new project and add it to the solution (Large Scale Generation)

If I want to Large Scale Generation and define
Application = Framework (binary core components) + Generated Code + Custom Code
How would I go about creating code generation framework using scaffolding to generate multiple projects and associated files from some metadata (let's say a DSL model defined in a solution folder)
I know that I can use MvcScaffolding powershell cmdlets to add files to the current on another project.
I need to know if I can add a new project (Class library, Web appication) to the current solution from some kind of project template, apply source transformation and possibly merge some custom data. That would allow additional files to be added and I would prefer that both creation of the project and adding some files initially be done in one powershell line based on some input parameters (let say the name of some DSL model, XSD schema, XML data)
Could I just create a new solution and invoke some scaffolders? Are there scaffolders at a solution level?
I would like to have a scaffodling framework resembling software factories (Web service software factory). Any samples, ideas, articles?
Thanks
Rad
I don't see any reason why not.
Your T4 templates can access EnvDTE and so do all sorts of fun VS automation, and of course the .ps1 powershell scripts can (I guess - I am no powershell guru) do pretty much anything you yourself can do on your box.
But out of interest why would you want to generate whole projects? i.e. are you sure that is time saving?

Visual Studio Solution Template - Link Source Control Projects

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!

Resources