Home > Back-end >  Blazor project template - some namespaces doesn't rename
Blazor project template - some namespaces doesn't rename

Time:04-30

I am trying to make a Blazor project template. When i try to create a project from that template, all namespaces change properly to the project name, except for that in _Imports.razor and in the @using statement in the razor component. There are still the same namespaces as in the template.

CodePudding user response:

Here is one of my typical _Imports.razor files in a template

@using System.Net.Http
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using $ext_projectname$
@using $ext_projectname$.Core

and the relevant section in the vstemplate file:

    <TemplateContent>
        <Project TargetFileName="Blazr.Demo.UI.csproj" File="Blazr.Demo.UI.csproj" ReplaceParameters="true">
      .......
            <ProjectItem ReplaceParameters="true" TargetFileName="_Imports.razor">_Imports.razor</ProjectItem>
            <ProjectItem ReplaceParameters="true" TargetFileName="program.cs">program.cs</ProjectItem>
        </Project>
    </TemplateContent>

If you want the context, you can see the whole template here: https://github.com/ShaunCurtis/Blazr.Demo.Template

  • Related