C# Files Are Missing In Custom .Net Standard Library Project Template - visual-studio-2017

I am trying to create a custom .net standard library project template. My custom project template contains some .cs (C# Files) files.
I have created a project template using Project => Export Template option in Visual Studio 2017. The exported zip file contains the .cs file. But when i try to create a new project using my custom .net standard library project template, .cs (C# files) files are missing in my newly created project.
Am i missing something or there a new way to create project template for .net standard library.
Thank you in advance.

Related

Visual Studio Custom Template Wont Save Folders Or Files

I have a file saved as a visual studio project the uses an opengl library. I plan to use that opengl library a lot in the future so I decided to save that project as a template. Unfortunately the template did not save any of the folders or the files within those folders (These files are necessary for the library to work). Does any body have any idea why and / or a possible fix? Thanks?

How to create "Multi Project Template With Custom Wizard" in Visual Studio 2017

I'm looking for help on making a multi project template (i.e. a deploy-able solution that contains multiple projects) with a custom wizard (to enable custom parameters to be entered).
I've followed "How to: Create Multi-Project Templates" to make the multi project template. This is working.
I've followed "How to: Use Wizards with Project Templates" to make my wizard in my VSIX files. This is working.
However, I can't get them to work together. I can either deploy my multi project template without a wizard OR I can get all of my individual project templates to show in the project gallery, via my VSIX file, with a working custom wizard.
Any ideas on how to combine the two methods?
I was able to adopt an answer from this blog.
The key is to package all of your exported projects (which come in ZIP which you have to extract) and your root .vstemplate file into a ZIP. This ZIP then needs to be an imported project template in your VSIX project.
Lastly, your wizard needs to be its own separate project you can reference in any of your individual project templates or in your VSIX. I had my wizard being created in my VSIX which just didn't seem to work.
As stated by Dan, you need to have your multi-project templates in a zip file.
However, you do not need to have the wizard code in a separate project, you can have it all in your VSIX project.
I your VSIX project, to add a reference to your .zip file, open your source.extension.vsixmanifest designer -> Assets -> New -> Select type Project Template and Source 'File on filesystem' and select your zip file.
Make sure to also add your VSIX project as Assembly if you haven't already: New -> Select type Assembly and Source 'a project in current solution' and select your VSIX project. (This is probably why it didn't work for Dan)
In your multi-template.vstemplate file you need to add a reference to the VSIX dll as described in "How to: Use Wizards with Project Templates" using <WizardExtension>
In addition you can also add a <CustomParameters> section inside <TemplateContent> if you want to set up default custom parameter values. See here for more info: "The registration elements for customizing the template wizard"
Example:
<CustomParameters>
<CustomParameter Name="$mycustomparameter1$" Value="value1"/>
<CustomParameter Name="$mycustomparameter2$" Value="value2"/>
</CustomParameters>

VS2017 multi project template with shared projects

I created a multi project template for use with VS2017, including a console application and two shared projects. I can see the template showing up, but whenever I try using it to create a new project I get an error stating that the "projitems"-file of the first shared project was not found in the path \AppData\Local\Temp\<seemingly randomly generated name>\<SharedProjectName>\<SharedProjectName>.projitems. After I dismiss the error the solution is still created, but only the shared projects are in there.
The situation is reproducable by using this template I uploaded to my OneDrive:
https://1drv.ms/u/s!At78FKXjEGEoh7F-vo5XppZBOImatA
And I created the template using this simple solution:
https://1drv.ms/u/s!At78FKXjEGEoh7F_QkSugfzie8I0mg
What I did is:
Exported each of the projects individually using "Project" -> "Export Template...".
Extracted the exported ZIP files to represent the desired folder structure. Each project got its own folder as you can see in the project template ZIP file.
Created a "vstemplate"-file with the help of MSDN, and included the three project files with their relevant paths.
Zipped the three folders and the new "vstemplate"-file up and moved it to the Visual Studio templates folder (Documents\Visual Studio 2017\Templates\ProjectTemplates\Visual C#).
What did I do wrong?

Visual Studio 2013 export Property Sheets to Template

I am Creating a C++ Project template and using the export template wizard to do it.
I had added a custom property sheet to my template project (the one which am going to export)
on successfully exporting my project template I created a new project using the template, but the project fails to load saying that it can't find the property sheet (it mentions the project directory path and says no such file exists).
I know the same question has been asked before : Exporting .props files in project template VS2012/13
But it has no answer for a year
I even tried including the property sheet as part of the project before exporting. still the same error
Please Help!
Edit:
I even tried manually putting the .props file into the zip archive it still shows the same error.
I think the new project gets loaded before the .props file gets added to the new project directory.
Note : Manually putting the .props file into the new project directory and then reloading the project works. but I don't want to copy paste it every time I create a new project from the template.

VS Extension which declares a new project template and locate the generated project in a specific location of an imported tree

I would like to create a Visual Studio extension.
I installed Visual Studio 2012 and Visual Studio SDK 2012.
Now, I want my extension to create a new project template, and then to enable the user to create a new project of the new generated type. i.e: I would like that once the user will open VS and will click on "add new project", he will have a new project type in the list of the regular templates. The template will be a standard C project, with some additinal dependencies, some changes in the.vcxproj file, in the compiling configurations and more.
In additinal, I want that on the project creation, my extension will import an existiong solution from my computer to be the current VS solution, and that the new project will be added to a specific folder in that solution.
Is there any way to write code which is doing the described above, on the creation of a new project of the new template? Do I have any event/other handler on the template code, or in the package code, which I can use?
I googled tons, but I really don't know what is the best way I can do it...
Thanks a lot!