My Scenario
- VS 17.8.7
- .NET 8
I have the following ASP.NET Core Hosted Blazor WASM project:
I am trying to export it as a multi-project template. To do this, I do the following:
- Find/Replace all instances of my current project name with
$ext_safeprojectname$. - Export each project as a Template individually.
- Extract the files from the resulting .zip folders and place in a new directory.
- Add a
MyTemplate.vstemplatefile to the root of the new folder.
Here is the resulting folder structure:
Here are the contents of the .vstemplate file:
<VSTemplate Version="2.0.0" Type="ProjectGroup"
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>My Wasm Template</Name>
<Description>...</Description>
<Icon>Icon.ico</Icon>
<ProjectType>CSharp</ProjectType>
</TemplateData>
<TemplateContent>
<ProjectCollection>
<ProjectTemplateLink ProjectName="$safeprojectname$.Client" CopyParameters="true">
MyWasmTemplate.Client\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$safeprojectname$.Server" CopyParameters="true">
MyWasmTemplate.Server\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$safeprojectname$.Data" CopyParameters="true">
MyWasmTemplate.Data\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$safeprojectname$.Shared" CopyParameters="true">
MyWasmTemplate.Shared\MyTemplate.vstemplate
</ProjectTemplateLink>
</ProjectCollection>
</TemplateContent>
</VSTemplate>
Result
When I create a new project using this template, the new project name correctly replaces most of the $ext_safeprojectname$ instances, except the following files in the client project:
_Imports.razor:
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.AspNetCore.Components.WebAssembly.Http
@using Microsoft.JSInterop
@using $ext_safeprojectname$.Client
@using $ext_safeprojectname$.Client.Layout
@using $ext_safeprojectname$.Shared
@using MudBlazor
MainLayout.razor:
...
<PageTitle>$ext_safeprojectname$</PageTitle>
...
<p class="text-nowrap">$ext_safeprojectname$</p>
...
and one other blazor component:
@page "/blogs"
@using $ext_safeprojectname$.Shared.Dtos
@inject HttpClient Http
Why are these template parameters not being replaced in these files? They're being replaced everywhere else properly, even within the client project.

