0

I'm trying to find a way to scaffold a new ASP.NET Core site that runs on the full .NET Framework (net461) and contains a unit test project. Is this doable? All of the options for dotnet new mvc don't seem to allow net461 as a framework. The same is true for the xunit project type.

Brian Vallelunga
  • 9,869
  • 15
  • 60
  • 87

1 Answers1

2

Build your own template which contains two projects. It's extremely easy. Create and setup several projects in Visual Studio and put .template.config\template.json file to the root solution level:

enter image description here

template.json contents:

{
    "classifications": [ "Web" ],
    "name": "ASP.NET Core project AND xUnit project both targeting .NET 461",
    "identity": "fweb", // Unique name for this template
    "shortName": "fweb", // Short name that can be used on the cli
    "tags": {
        "language": "C#" // Specify that this template is in C#.
    },
    "sourceName": "FullWebApp",
    "preferNameDirectory": "true"
}

Then run dotnet new --install with solution path as a parameter:

dotnet new --install "D:\YourFullPath\DotNetTemplates"

Template fweb has been created! Go to target folder and try to create new projects from template:

dotnet new fweb 

It's done. Read more about template packaging (NuGet) and name parametrization here:

How To Create A dotnet new Project Template In .NET Core

How to create your own templates for dotnet new

Ilya Chumakov
  • 23,161
  • 9
  • 86
  • 114