Create visual studio solution template - multiple projects - visual-studio

I'm stuck on this tutorial for creating a multi-project visual studio template. I'm specifically stuck on this line:
Select the files and folders to include in your template, right-click the selection, click Send To, and then click Compressed (zipped) Folder. The files and folders are compressed into a .zip file.
I did the following steps:
Create 2 projects. (MyProj.Web and MyProj.Service)
Reference MyProj.Service in MyProj.Web.
Export both. They are now in a .zip file.
What do I do from here?
My intentions are: Make solution folders where some dlls will be (DI, unit testing frameworks, etc). Have these dlls referenced. Reference projects in other projects. Rename part of the projects. For eg. the ability to replace {MyProj}.Service with NewName.Service

The other parts includes making the .vstemplate xml file and placing the zip in the ProjectTemplates.
Per the article:
Put the .zip template file in the Visual Studio project template
directory. By default, this directory is \My Documents\Visual Studio
2010\Templates\ProjectTemplates\
The Visual Studio template will then be available from File > New Project. If making a template for a single item, place it in the \ItemTemplates folder instead to make it available from the Add New Item context menu in Solution Explorer.

Related

Adding Existing folder(s) to a C++ Project in Visual Studio without creating a copy

I have a Visual Studio Solution containing multiple projects. (One Main Project and rest are used for testing the Main project)
Here, i have a shared folder within the solution which is used by all the projects within the solution.
I need to include the entire shared folder in my Main project instead of adding existed items.
I am using Visual Studio Professional 2015 and i could not find "Add Existing folder" option in Visual Studio.
Adding Existing items to a project will eliminate the folder structure in solution explorer which makes the usage more complex when included file count is huge.
I need to maintain a folder structure within the project.
Moving the shared folder within the project directory and using "Show All Files" option will avoid the issue(tried based on the answers in some links) but it is not accurate in my case as the folder is being used by different projects.
Do i have any way to add existing folder (Outside the Project within the solution) to a project and maintain a folder structure so that the solution explorer looks more readable?
I just found the solution to this issue.
We are suppose to create a Filter (Virtual Solution Folder) within the Project. Option for creating Filter is available on following below steps,
Select Visual Studio Project.
In Solution Explorer, Disable "Show All Files" option.
Note: When "Show All Files" option is enabled, your project will have an option to create a Folder instead of Filter.
Create a Filter/Virtual Solution folder. (Name could be same as the existing folder name outside the VS project in order to maintain readability)
Now, add required existing files to the Virtual Folder Solution from any location.
(Inside/Outside project location)
By following the above steps, one can add set of existing files to a virtual folder structure in Visual Studio Solution. This is equivalent to adding an Existing folder to a Project Solution without copying it.

How can I use files in one project to create a library in another project in Visual Studio?

I have a standalone project that contains some code I'd like to re-used. I created a library project in order to contain that code. There does not appear to be a way to move files from the one project to the other. (cut/paste in solution explorer did not work)
I then manually copied the files in Windows explorer (outside of VS) into the library's main "folder" but they didn't show up in solution explorer either.
Anyone know of a way to do this without having to manually create each file in the library and then copying/pasting the code into the files?
You need to copy the files and paste them into your solution/project folder(s). Once the files physically exist within your solution/project folder structure (Windows FileSystem / Explorer), then you right-click on your project within Visual Studio, select Add then Existing Item. Browse to the location of that file and open it. It will now exist within your project as a code file.
If you have two projects within the same solution, you can simply drag the file from one project to the other within Visual Studio Solution Explorer. That will create a copy of the class in the new project. You can then remove the old one and clean up any code references in the first project.

How can i load a template I have created in Visual Studio?

After creating a solution for a project, I exported it as a template. Now after exporting it automatically adds the template to my IDE and creates a ZIP file with all the project files and a .vstemplate extension file.
Now i am on another computer with visual studio and i wish to load this template and save it in the IDE, but i cannot find this option anywhere. The temporary solution i have is to open an empty web application and copy all the contents of the ZIP file not including the .vstemplate file. So my question is how can i load this template into my IDE?
When opening the vstemplate file in Visual Studio all i get is a text editor and XML data.
I am using Visual studio 2013 with Update 4.
Once you've exported your template, copy the entire ZIP file that was created to the folder C:\Users\[User Name]\Documents\Visual Studio 2013\Templates\ProjectTemplates. (You might want to use one of the provided subdirectories to keep your template organized.)
Restart Visual Studio, and then use the search bar in the New Project dialog to help you find the project template you just added.
For the record, it looks like using templates changes with VS2017. Your project template provider will have to publish via a new build mechanic, and it'll be a bit different than just dumping a .zip into a user folder:
Using Project/Item Templates:
https://learn.microsoft.com/en-us/visualstudio/extensibility/upgrading-custom-project-and-item-templates-for-visual-studio-2017
Create Project/Item Template:
https://learn.microsoft.com/en-us/visualstudio/extensibility/creating-custom-project-and-item-templates

creating custom templates in visual studio & resharper

I would like to create custom templates for c# files, unit test classes, .aspx.cs etc so that common items to all files are included once they are created eg file headers. I am working with visual studio 2010 and resharper 6. What is the easiest way to create these files and is it possible to be able to share them a team of developers easily? Appreciate any assistance or information as to how I might achieve this.
Visual Studio templates are simple enough to create - you can distribute them to your colleagues to setup in the same location on their computers (or even create an installer, if you want to makes things even easier).
See Creating Project and Item Templates and the Introduction to Visual Studio Templates on MSDN.
Contents of a Template
All project and item templates, whether installed together with Visual Studio or created by you, function by using the same principles and have similar contents. All templates contain the following items:
The files to be created when the template is used. This includes source code files, embedded resources, project files, and so on.
One .vstemplate file. This file contains the metadata that provides Visual Studio the information it needs to display the template in the New Project and Add New Item dialog boxes and create a project or item from the template. For more information about .vstemplate files, see Visual Studio Template Metadata Files.
When these files are compressed into a .zip file and put in the correct folder, Visual Studio automatically displays them in the My Templates section of the New Project and Add New Item dialog boxes. For more information about template folders, see How to: Locate and Organize Project and Item Templates.
You should open Templates Explorer from ReSharper | Templates Explorer. Then select the File Templates tab. There are default templates that comes with ReSharper. You can examine them and see how you can write your own. Here's the documentation and there's a question for useful examples.

Visual Studio - How to change a project's folder name and solution name without breaking the solution

I am creating a project based off an old project because it has a lot of the functionality that I am required to use.
I want to rename all the directories and solution names to have the name of the new project. Under Documents\Visual Studio 2008\Projects I was able to change the initial directory and solution file names, but not the name of the subdirectory which houses the bin, obj, and properties folders. When I change the name of that subdirectory, none of the files will open when I open up the solution.
How can I change the project's folder name inside Visual Studio 2008 so that it will load all the files as part of the solution and still work?
You could open the SLN file in any text editor (Notepad, etc.) and simply change the project path there.
This is what I did:
Change project and solution name in Visual Studio
Close the project and open the folder containing the project (The Visual studio solution name is already changed).
Change the old project folder names to the new project name
Open the .sln file and the change the project folder names manually from old to new folder names.
Save the .sln file in the text editor
Open the project again with Visual Studio and the solution is ready to modify
I found that these instructions were not enough. I also had to search through the code files for models, controllers, and views as well as the AppStart files to change the namespace.
Since I was copying my project not just renaming it, I also had to go into the applicationhost.config for IIS express and recreate the bindings using different port numbers and change the physical directory as well.
go to my start-documents-iisExpress-config and then right click on applicationhost and select open with visual studio 2013 for web
you will get into applicationhost.config window in the visual studio
and now in the region chsnge the physical path to the path where your project is placed

Resources