Skip to content

dotnet new template creates phantom ProjectName.App.sln in Recent Projects despite using custom .sln #9062

Open
@UseMuse

Description

@UseMuse

I created a template package project according to the instructions below
https://learn.microsoft.com/en-us/dotnet/core/tutorials/cli-templates-create-template-package

Using Microsoft.TemplateEngine.Authoring.Templates

The output structure should look like this:

working
AdatumCorporation.Utility.Templates.csproj (rename to MyCorp.Templates.csproj)
└───content
└───AngularMatWithAspCore
├───.template.config
│ ├───template.json
│ └───icon.png
├───ProjectNameApiCore
│ └───(project .csproj files, source code, etc.)
├───ProjectNameClient
│ └───(project .esproj files, source code, etc.)
└───ProjectName.App.sln

MyCorp.Templates.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <PackageId>MyCorp.Templates</PackageId>
    <PackageVersion>6.0.0</PackageVersion>
    <Title>MyCorp Templates</Title>
    <Authors>MyCorp Team</Authors>
    <Description>.net core 6 templates</Description>
    <PackageTags>angular;aspnetcore;material;template</PackageTags>
    <PackageType>Template</PackageType>
    <TargetFramework>net6.0</TargetFramework>
    <IncludeContentInPack>true</IncludeContentInPack>
    <IncludeBuildOutput>false</IncludeBuildOutput>
    <ContentTargetFolders>content</ContentTargetFolders>
    <NoWarn>$(NoWarn);NU5128</NoWarn>
    <NoDefaultExcludes>true</NoDefaultExcludes>
   <PackageReadmeFile>README.md</PackageReadmeFile>
  </PropertyGroup>

  <PropertyGroup>
    <LocalizeTemplates>false</LocalizeTemplates>
  </PropertyGroup>

  <ItemGroup>
	<PackageReference Include="Microsoft.TemplateEngine.Tasks" Version="*" PrivateAssets="all" IsImplicitlyDefined="true" />
  </ItemGroup>

  <ItemGroup>
    <Content Include="content\**\*" Exclude="content\**\bin\**;content\**\obj\**" />
    <Compile Remove="**\*" />
  </ItemGroup>

  <ItemGroup>
     <!-- tried removing that and that didn't solve the problem either -->
    <None Include="content\AngularMatWithAspCore\ProjectName.App.sln" />
    <None Include="README.md" Pack="true" PackagePath="" />
  </ItemGroup>

</Project>

template.json

{
  "$schema": "http://json.schemastore.org/template",
  "version": "6.0.0",
  "author": "MyCorp Team",
  "classifications": [
    "Web",
    "C#",
    "TypeScript",
    "Angular"
  ],
  "icon": "icon.png",
  "identity": "MyCorp.Templates.AngularMatWithAspCore",
  "name": "Angular Mat 15 and ASP.NET Core 6",
  "description": "A full-stack application with a front end Angular Mat 15 project and a backend ASP.NET Core 6 project",
  "shortName": "AngularMatWithAspCore",
  "tags": {
    "language": "C#, TypeScript",
    "type": "solution",
    "editorTreatAs": "solution"
  },
  "sourceName": "ProjectName",
  "preferNameDirectory": true,
  "guids": [
    "11111111-1111-1111-1111-111111111111",
    "22222222-2222-2222-2222-222222222222"
  ],
  "primaryOutputs": [
    {
      "path": "ProjectName.App.sln"
    }
  ],
  "forms": {
    "kebab": {
      "identifier": "kebabCase"
    },
    "snake": {
      "identifier": "replace",
      "pattern": "-",
      "replacement": "_"
    }
  },
  "symbols": {
    "HostIdentifier": {
      "type": "bind",
      "binding": "HostIdentifier"
    },
    "projectNameKebabCase": {
      "type": "derived",
      "valueSource": "name",
      "valueTransform": "kebab",
      "replaces": "projectNameKebabCase"
    },
    "projectNameSnakeCase": {
      "type": "derived",
      "valueSource": "projectNameKebabCase",
      "valueTransform": "snake",
      "replaces": "projectNameSnakeCase"
    },
    "HttpPortGenerated": {
      "type": "generated",
      "generator": "port",
      "replaces": "HttpPortGenerated"
    },
    "HttpsPortGenerated": {
      "type": "generated",
      "generator": "port",
      "parameters": {
        "low": 44300,
        "high": 44399
      },
      "replaces": "HttpsPortGenerated"
    },
    "clientPort": {
      "type": "parameter",
      "datatype": "integer",
      "defaultValue": "4200",
      "replaces": "{{clientPort}}",
      "description": "The port for the Angular client. Default 4200"
    },
    "apiPort": {
      "type": "parameter",
      "datatype": "integer",
      "defaultValue": "7100",
      "replaces": "{{apiPort}}",
      "description": "The port for the ASP.NET Core backend. Default 7100"
    }
  },
  "sources": [
    {
      "modifiers": [
        {
          "condition": "(HostIdentifier == \"dotnetcli\" || HostIdentifier == \"dotnetcli-preview\")",
          "rename": {
            "ProjectName.App.sln": "ProjectName.sln"
          }
        }
      ]
    }
  ]
}

I publish it to my bytesafe nuget, then install templates from there, create sln from microsoft visual studio since it displays it to me successfully

After creation everything is fine, except that in Recent microsoft visual studio ProjectName.App.sln is shown, it is also displayed in Recent Windows

physically this file does not exist, it is displayed in Recent and refers to the expected ProjectName.sln

I tried without specifying

"primaryOutputs": [
{
"path":"ProjectName.App.sln"
}

it didn't solve the problem

Image

Image

If I remove ProjectName.App.sln and everything connected with it and work only with ProjectName.App.sln, I get the same phantom sln

for example, I create according to the template with the name MyProject1, I get MyProject1.sln and phantom MyProject11.sln

How to fix this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions