dotnet / dotnet/templating

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

Open
#9,062 0 comments 0 reactions 0 assignees View on GitHub
triage:transfer-to-sdk
Dominant language
No language data
Stars
1.7k
Forks
399
Avg merge
3d 5h
Merged PRs (30d)
39

Description

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
```xml


MyCorp.Templates
6.0.0
MyCorp Templates
MyCorp Team
.net core 6 templates
angular;aspnetcore;material;template
Template
net6.0
true
false
content
$(NoWarn);NU5128
true
README.md


false










```

template.json
```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
```json
"primaryOutputs": [
{
"path":"ProjectName.App.sln"
}
```
it didn't solve the problem

![Image](https://github.com/user-attachments/assets/ed694388-ac4d-4e2c-bb3d-9eaa897a45db)

![Image](https://github.com/user-attachments/assets/cebc3996-62a0-4333-8d54-05378fbb2782)

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?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.