Reputation: 61
I have created a new Visual Studio template and am wanting one of the folders to rename to the project name automatically when it is created. I have tried editing the template file and project file as described in some material but this has not worked. Any ideas?
<Folder Name="Views" TargetFolderName="Views">
<Folder Name="Template" TargetFolderName="$safeprojectname$">
<ProjectItem ReplaceParameters="true" TargetFileName="Index.cshtml">Index.cshtml</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="Index.generated.cs">Index.generated.cs</ProjectItem>
</Folder>
</Folder>
This is what I have tried in the template file.
Upvotes: 1
Views: 561
Reputation: 61
I have managed to figure it out!... Instead of creating the "Template" folder I wanted to rename in the project, I deleted this and placed the files that were within that folder ("Index.cshtml" and "Index.generated.cs") in the root of the project.
After this I exported the project as a template. In the template file, I created the folders I wanted (with the names I wanted) by changing the target file name as below:
<ProjectItem ReplaceParameters="true" TargetFileName="Views\$safeprojectname$\Index.cshtml">Index.cshtml</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="Views\$safeprojectname$\Index.generated.cs">Index.generated.cs</ProjectItem>
Then in the project file I changed any references to the two files to look for "Views\$safeprojectname$\Index.cshtml" and "Views\$safeprojectname$\Index.generated.cs" as opposed to just looking for the files in the root.
Voila!
Upvotes: 2