I´m working in visual studio item template, but in my solution i have 6 projects and I want to include my item template all the projects. the item code project is this one:
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
<TemplateData>
<DefaultName>WebAPI.cs</DefaultName>
<Name>WebAPI</Name>
<Description><No description available></Description>
<ProjectType>CSharp</ProjectType>
<SortOrder>10</SortOrder>
<Icon>__TemplateIcon.png</Icon>
</TemplateData>
<TemplateContent>
<Folder Name="Base" TargetFolderName="Base">
<Folder Name="Interface" TargetFolderName="Interface">
<ProjectItem ReplaceParameters="true" TargetFileName="I$fileinputname$.cs">IPesquisarEstruturaSIIMN.cs</ProjectItem>
</Folder>
<ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$N.cs">PesquisarEstruturaSIIMN.cs</ProjectItem>
</Folder>
</TemplateContent>
</VSTemplate>
My Question is My problem is how can I change the project target of my item template?
The template definition applies for all of Visual Studio.
In order for Visual Studio to find it, copy the .vstemplate, PesquisarEstruturaSIIMN.cs, IPesquisarEstruturaSIIMN.cs, and __TemplateIcon.png files to a new folder under the Item Templates folder.
Ex: C:\Users\MyUser\Documents\Visual Studio 2013\Templates\ItemTemplates\MyTemplate
Then restart Visual Studio, right click on each project, select "Add", then "New Item." You should see your template as an option under Visual C# Items.
My solution is there : visual-studio-how-to-create-a-solution-template-with-multiple-projects
It´s more eficienty to use projet template one by one.
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="ProjectGroup">
<TemplateData>
<Name>CijunMVC</Name>
<Description>Cria um projeto MVC no padrão Cijun MVC</Description>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>
</ProjectSubType>
<SortOrder>1000</SortOrder>
<CreateNewFolder>true</CreateNewFolder>
<DefaultName>CijunMVC</DefaultName>
<ProvideDefaultName>true</ProvideDefaultName>
<LocationField>Enabled</LocationField>
<EnableLocationBrowseButton>true</EnableLocationBrowseButton>
<Icon>__TemplateIcon.png</Icon>
</TemplateData>
<TemplateContent>
<ProjectCollection>
<ProjectTemplateLink ProjectName="$projectname$_Entidade">
Cijun_Entidade\entidade.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$projectname$_Negocio">
Cijun_Negocio\Negocio.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$projectname$_Persistencia">
Cijun_Persistencia\Persistencia.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$projectname$_WebMVC">
CijunWebMVC\Web.vstemplate
</ProjectTemplateLink>
</ProjectCollection>
</TemplateContent>
</VSTemplate>
Related
|---test.csproj
|---FolderA---
|--- a.cs
|--- b.cs
|---FolderB---
I can write test.csproj file as follow to include all files in FolderA:
<Compile Include="FolderA\*.cs" />
But all files will be displayed at the root view of visual studio, what should I do if I
want to display them in FolderB?
<Folder Include="Class\">
<Compile Include="FolderA\*.cs" />
</Folder>
Code above not works.
I am generating the .net core as output project but in the vsix wizard it shows the .net framework drop down which is misleading the user.How to hide this drodown? Do we need to add any property/setting in the below vsTemplate? My VsTemplate looks like below.
VS template => Template Data code looks as below,
<?xml version="1.0" encoding="utf-8"?>
<VSTemplate Version="3.0.0" Type="Project" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" xmlns:sdk="http://schemas.microsoft.com/developer/vstemplate-sdkextension/2010">
<TemplateData>
<Name>Project Toolkit</Name>
<ProjectType>CSharp</ProjectType>
<LanguageTag>csharp</LanguageTag>
<SortOrder>1000</SortOrder>
<TemplateID>ddfd85f1-6ec9-4703-8b0c-19262fe6420c</TemplateID>
<CreateNewFolder>true</CreateNewFolder>
<DefaultName>MyTemplate</DefaultName>
<ProvideDefaultName>true</ProvideDefaultName>
</TemplateData>
<TemplateContent>
<Project TargetFileName="MyEmpty.csproj" File="MyEmpty.csproj" ReplaceParameters="true">
<Folder Name=".publish" TargetFolderName=".publish">
<ProjectItem ReplaceParameters="false" TargetFileName="color.png">color.png</ProjectItem>
<ProjectItem ReplaceParameters="false" TargetFileName="outline.png">outline.png</ProjectItem>
<ProjectItem ReplaceParameters="false" TargetFileName="development.json">development.json</ProjectItem>
<ProjectItem ReplaceParameters="false" TargetFileName="production.json">production.json</ProjectItem>
<ProjectItem ReplaceParameters="false" TargetFileName="README.md">README.md</ProjectItem>
<ProjectItem ReplaceParameters="false" TargetFileName="manifestFormat.json">manifestFormat.json</ProjectItem>
</Folder>
</Project>
</TemplateContent>
<WizardExtension>
<Assembly>MyWizard, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=f494b956b37a2c3b</Assembly>
<FullClassName>Me.WizardImplementation</FullClassName>
</WizardExtension>
</VSTemplate>
If you remove the RequiredFrameworkVersion element from your vstemplate that should remove the dropdown.
Given your example doesn't have these, I suspect the template you're referencing above, is not the template your testing. Be aware the VS caches project templates, so you may have to clean things up by ensuring your previous template(s) have been uninstalled, and the project and item template cache rebuilt by running devenv.exe from an elevated command prompt with the /InstallVSTemplates switch.
I have a project template that is generated through a wizard.
Now i want to add a new item template through the same wizard.
How can i invoke the wizard at the moment that i add the new item template.
Example:
[Add to Project Template]
[Wizard/Form]
[Add the new Item Template]
[Show the wizard Template]
[show the new Item/class]
Item Template Code:
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
<TemplateData>
<DefaultName>class1.cs</DefaultName>
<Name>Myproject class1</Name>
<Description>Myproject Class</Description>
<ProjectType>CSharp</ProjectType>
<SortOrder>10</SortOrder>
<Icon>Myprojectclass1.png</Icon>
</TemplateData>
<TemplateContent>
<References>
<Reference>
<Assembly>System</Assembly>
</Reference>
<Reference>
<Assembly>System.Linq</Assembly>
</Reference>
<Reference>
<Assembly>System.Threading.Tasks</Assembly>
</Reference>
</References>
<ProjectItem SubType="Code" TargetFileName="$fileinputname$.cs" ReplaceParameters="true">class1.cs</ProjectItem>
<CustomParameters>
<CustomParameter Name="$username$" Value="$safeitemrootname$"/>
<CustomParameter Name="$rootnamespace$" Value="$safeitemrootname$"/>
<CustomParameter Name="$registeredorganization$" Value="$safeitemrootname$"/>
</CustomParameters>
</TemplateContent>
<WizardExtension>
<Assembly>MyProjectWizard, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=f7a1fcb8d457e160</Assembly>
<FullClassName>MyProjectWizard.WizardImplementation</FullClassName>
</WizardExtension>
</VSTemplate>
I have already found the solution, there is no other way to call the template item without being key.snk.
Because when I call an itemtemplate I have to implement my item I chose the project created and the only way to do that is by key.snk.
If they have a different form please respond to this question, I want to know if there are more ways to call the Item template.
I have a solution which holds a VSIX project and an ItemTemplate Project. The item template has multiple files which are added when used. It looks like this:
<ProjectItem ReplaceParameters="true" TargetFileName="commands\$fileinputname$Command.cs">commands\TemplateCommand.txt</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="descriptions\$fileinputname$.xml">descriptions\Template.xml</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="ui\$fileinputname$Designer.cs">ui\TemplateDesigner.txt</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="ui\$fileinputname$DesignerDialog.cs">ui\TemplateDesignerDialog.txt</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="ui\$fileinputname$DesignerDialog.Designer.cs">ui\TemplateDesignerDialog.Designer.cs</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="userControls\UCTextBox_Label.cs">userControls\UCTextBox_Label.txt</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="userControls\UCTextBox_Label.Designer.cs">userControls\UCTextBox_Label.Designer.cs</ProjectItem>
This adds a Class file, an xml file, a Windows Form and a User Control. My froblem lies with the User Control. It is universally usable by all the items added by the template, so it only has to be created once. Is there a possibility of adding a logic to this file where it checks for the existence of this user control? Or is there a place for this somewhere else?
i.e. : If i'm adding 3 items using this template, i only want the User Control to be added once.
as explained here http://davidhayden.com/blog/dave/archive/2005/11/05/2556.aspx one can customize project item template.
But at the moment I just try to understand how it works. For example I unzipped the usercontrol file and in usercontrol.vstemplate I cannot see how mycontrol.designer.cs is dependant on mycontrol.cs as this appear in project file as:
<DependentUpon>mycontrol.cs</DependentUpon>
so any idea ?
Update: Could this dependency not specified somewhere in the project type template ? This would be more clever than relying on the IDE heuristic rule which is rather limited since it can only recognize .Designer.cs and not for example .MyCustom.cs.
usercontrol.vstemplate:
<?xml version="1.0" encoding="utf-8"?>
<VSTemplate Version="3.0.0" Type="Item" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name Package="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}" ID="2295" />
<Description Package="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}" ID="2296" />
<Icon Package="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}" ID="4532" />
<TemplateID>Microsoft.CSharp.WindowsFormsUserControl</TemplateID>
<ProjectType>CSharp</ProjectType>
<SortOrder>94</SortOrder>
<RequiredFrameworkVersion>2.0</RequiredFrameworkVersion>
<NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
<DefaultName>UserControl.cs</DefaultName>
</TemplateData>
<TemplateContent>
<References>
<Reference>
<Assembly>System</Assembly>
</Reference>
<Reference>
<Assembly>System.Data</Assembly>
</Reference>
<Reference>
<Assembly>System.Drawing</Assembly>
</Reference>
<Reference>
<Assembly>System.Windows.Forms</Assembly>
</Reference>
<Reference>
<Assembly>System.Xml</Assembly>
</Reference>
</References>
<ProjectItem ReplaceParameters="true" SubType="UserControl">UserControl.cs</ProjectItem>
<ProjectItem ReplaceParameters="true">UserControl.Designer.cs</ProjectItem>
</TemplateContent>
</VSTemplate>
The IDE is smart enough to figure this out by itself. Try this in a sample project: Project + Add New Item, Class, named it Foo.cs. Repeat, now name it Foo.Designer.cs. Note how it automatically becomes a sub-item of Foo.cs. The ".Designer" part of the name matters.
For types the IDE knows like Window it figures it out automatically.
But if you want to combine files that aren't known to the designer/use a different naming pattern for the files you have to manually add tags. I've tried this in a project and I concluded it just wasn't worth the effort, also because the IDE will only automatically rename dependent files it knows of (when you change the file name of the main file).