question

MartinHan-6727 avatar image
0 Votes"
MartinHan-6727 asked AnnaXiu-MSFT commented

In item template, how to substitute part of text with project name?

I have an item template,
```
<v:View x:TypeArguments="local:$safeitemname$Model" x:Name="view"
x:Class="$rootnamespace$.$safeitemname$"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:v ="clr-namespace:$safeprojectname$.Visual"
xmlns:local="clr-namespace:$rootnamespace$"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
</v:View>
```
However in practice $safeprojectname$ was not replaced. After research I found its only available for project template.

I tried using the Wizard, however, I don't know how to get the project name with the given paramters of IWizard.RunStarted(Object, Dictionary<String,String>, WizardRunKind, Object[]) Method. It is posible to get it via IWizard.ProjectItemFinishedGenerating(ProjectItem), but this method is called after everything are done.

Anther thing I found perhaps useful is an answer in Stackoverflow, https://stackoverflow.com/a/42138852/12463119. Unfortunately I cannot understand it as I don't where where the 'dte' varible come from.

Please tell me how to let my template be able to capture the project name and automatically write into the generated file.


dotnet-csharpvs-extensions
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @MartinHan-6727 , about using the $safeprojectname$ parameter in item template, please directly report it in Visual Studio Developer Community page. Have a nice day!


0 Votes 0 ·

0 Answers