Templates  
Author Message
humble.apprentice





PostPosted: Visual C# IDE, Templates Top

Hey all!

I have created a template for a project of mine but when I see my output classes (the ones in the new project using the template I created), they keep the names from the original classes when I want them to have the name of the new project. Here is my code:

<VSTemplate Version="2.0.0" xmlns=" http://www.hide-link.com/ " Type="Project">

<TemplateData>

<Name>ServiceTemplate</Name>

<Description>Simple Windows service</Description>

<ProjectType>CSharp</ProjectType>

<ProjectSubType>

</ProjectSubType>

<SortOrder>1000</SortOrder>

<CreateNewFolder>true</CreateNewFolder>

<DefaultName>ServiceTemplate</DefaultName>

<ProvideDefaultName>true</ProvideDefaultName>

<LocationField>Enabled</LocationField>

<EnableLocationBrowseButton>true</EnableLocationBrowseButton>

<Icon>__TemplateIcon.ico</Icon>

</TemplateData>

<TemplateContent>

<Project TargetFileName="ServiceTemplate.csproj" File="ServiceTemplate.csproj" ReplaceParameters="true">

<ProjectItem ReplaceParameters="true" TargetFileName="Program.cs">Program.cs</ProjectItem>

<Folder Name="Properties" TargetFolderName="Properties">

<ProjectItem ReplaceParameters="true" TargetFileName="AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem>

</Folder>

<ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$_Installer.cs">ServiceTemplate_Installer.cs</ProjectItem>

<ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$_Installer.Designer.cs">ServiceTemplate_Installer.Designer.cs</ProjectItem>

<ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$_Service.cs">ServiceTemplate_Service.cs</ProjectItem>

<ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$_Service.Designer.cs">ServiceTemplate_Service.Designer.cs</ProjectItem>

</Project>

</TemplateContent>

</VSTemplate>

I am following what I read in these articles:

This is what I am trying to achieve. The project I am using as a template has four files, ServiceTemplate_Installer.cs, ServiceTemplate_Installer.Designer.cs, ServiceTemplate_Service.cs and ServiceTemplate_Service.Designer.cs. I export this project and generate a template. When I use the template, I would like to see ServiceTemplate replaced by the new project's name.

Any help is greatly appreciated!

Cheers,




Visual C#3  
 
 
Peter Ritchie





PostPosted: Visual C# IDE, Templates Top

The docs at http://msdn2.microsoft.com/en-gb/library/ms247115(VS.80).aspx seem to suggest that you can only use the replacement parameters to vary the extension (e.g. ProjectName.Designer.cs) Are you comfortable with something like "ProjectName.Installer.cs"

Another similar thread (asking about folders) has a response from MSFT that it can't currently be done with a template but can be done with a wizard (with example): http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=364826&SiteID=1 (i.e. performing a rename in one of the *FinishedGenerating methods).

 
 
Glenn Wilson





PostPosted: Visual C# IDE, Templates Top

This is a common problem, and you need to make sure you have installed it on Vista in the correct way.

Need to run a command prompmt under admin and runn all installs from there.

  1. Install VS C# Express
  2. Install VS C# Express Service Pack 1
  3. Install the VS Service Pack 1 update for Vista
  4. Install The XNA and GSE Systems.

This should get you going, as It has work several times for me and others.



 
 
Sniper167





PostPosted: Visual C# IDE, Templates Top

Whats the difference in running it using windows and running it using command prompt

 
 
Sniper167





PostPosted: Visual C# IDE, Templates Top

I need help running it in the command prompt... I don't know how to navigate to the directory and then run the setup file... :(

 
 
Sniper167





PostPosted: Visual C# IDE, Templates Top

Nevermind, I got it finally. Thanks for the help!