Problem creating new Blazor Template in Visual Studio after Windows 11 upgrade


Update

I see what is happening, but I am not sure what the cause is or how to resolve it:

When I use a template that was previously ‘installed’ in Visual Studios before we upgraded to Windows 11 – that template still works perfectly.

However, when I install a new template into VS (even a template that was created prior to upgrading to windows 11 – but not installed in VS), then I get the error when creating a new project from the template.

What is happening is that the newly installed templates fail to create the sln project file. It’s missing.

There is not a lot if information on Google. I have done the following, without success:

Repair Visual Studios
Repair NET SDK
Re-create the template from the original project.

I created a project template in Blazor, using Visual Studio 2022, and export to the VS template folder. Pretty cut and dry.

Note: because we use dynamic project naming throughout the template, we make the following modification to the file: MyTemplate.vstemplate (in the newly exported template folder):

I replaced the following line:

<Project TargetFileName="template123.csproj" File="BZ1Template4.0.csproj" ReplaceParameters="true">

with this line:

<Project TargetFileName="$safeprojectname$.csproj" File="$safeprojectname$.csproj" ReplaceParameters="true">

This process has been working perfectly for over a year now. That was, until we recently upgraded to Windows 11.

Now, I have a problem where all previously created templates work, just as they did before Windows 11. However, any new versions of the template that I create, fail with the following error:

Could not find file ‘C:\Users\ME\AppData\Roaming\Microsoft\VisualStudio\17.0_4cb345df\ProjectTemplateCache\TemplateName.zip$safeprojectname$.csproj

I am lost on this issue. It may or may not be directly related to Windows 11, but I can say that it started at the time we upgraded to W 11.

Any help in resolving this issue would be greatly appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *