0

I am creating a solution template (containing 4 projects) for Visual Studio 2022 using a template.json file:

{
  "$schema": "http://json.schemastore.org/template",
  "author": "Me",
  "classifications": [ "Web", "Solution", "Web API" ],
  "defaultName": "WebTemplate",
  "icon":"icon.png",
  "identity": "vanguardWebApiTemplate",
  "name": "Vanguard Web Api Template",
  "shortName": "vanguardWebApiTemplate",
  "sourceName": "Vanguard.WebApiTemplate",
  "preferNameDirectory": true,
  "tags": {
    "language": "C#",
    "type": "solution"
  },
  "guids": [
    "E17122AE-2E52-459D-885A-EDBE3BD43B34",
    "D99C062B-E50F-4F47-A055-7D1005C039A1",
    "340C19B1-D448-435D-A46E-E6C907921EE8",
    "92812E59-FD1F-4C70-B949-4224849DC6D1"
  ],
  "symbols": {
      "ServiceName": {
          "type": "parameter",
          "dataType": "string",
          "replaces": "ServiceName",
          "description": "The PascalCase name of the service.",
          "isRequired": "true",
      }
  }
}

I can successfully install the Visual Studio template with Powershell

dotnet new --install C:\<path to template>\Vanguard.WebApiTemplate\

When I create a new solution using my template, Visual Studio 2022 hangs during the Creating Project... dialog and eventually crashes. However, it does create all the files I expect to be contained in the template, but it creates two different copies of the .sln file (notice the different file size).

Duplicate Solution File

Any ideas why Visual Studio hangs/crashes and why two different .sln files are generated?

2
  • There is one , after "isRequired": "true". Does the problem happen every time? Commented Feb 27, 2024 at 7:58
  • I believe the issue is related to uninstalling and re-installing the template. I run: dotnet new --uninstall C:\<path to template>\Vanguard.WebApiTemplate\ and then delete my %USERPROFILE%/.templateengine directory but when I go to re-install the template, using a new name, the old name still shows up. It seems like Visual Studio is doing some broken caching Commented Feb 27, 2024 at 17:25

2 Answers 2

0

Did dotnet new --uninstall return successful?

Here is a thread describing where to find the cache.

%appdata%\Microsoft\VisualStudio<the version of visual studio, 16.0_4810b0af, 17.0_e97c61af, etc>\ItemTemplatesCache and ProjectTemplatesCache

%LOCALAPPDATA%\Microsoft\VisualStudio<the version of visual studio, 16., 17., etc>

In those directories, locate and delete InstalledTemplates.json.

Try deleting the cache.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes the dotnet new --uninstall returns successfully. I deleted the caches at these locations, as well as the %USERPROFILE%\.templateengine folder. After re-installing my template I am still experiencing the same problem where VS hangs and creates 2 .sln files.
I think anti-virus software is interfering with Visual Studio's ability to create the solution... I'm investigating
0

Turns out the problem was caused by ReSharper. I disabled it and now Visual Studio can create my multi-project solution.

See this related post: https://stackoverflow.com/a/46319242/14134046

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.