Search code examples
c#.netvisual-studiotemplates

Visual Studio Template Creating Multiple Solution Files


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?


Solution

  • 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