简体   繁体   English

具有完整框架和单元测试项目的Scaffold ASP.NET Core

[英]Scaffold ASP.NET Core with Full Framework and Unit Test Projects

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. 我正在尝试找到一种方法来搭建一个新的ASP.NET Core站点,该站点在完整的.NET Framework(net461)上运行并包含一个单元测试项目。 Is this doable? 这可行吗? All of the options for dotnet new mvc don't seem to allow net461 as a framework. dotnet new mvc所有选项似乎都不允许net461作为框架。 The same is true for the xunit project type. xunit项目类型也是如此。

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: 在Visual Studio中创建和设置几个项目,然后将.template.config\\template.json文件放到根解决方案级别:

在此处输入图片说明

template.json contents: template.json内容:

{
    "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

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

Template fweb has been created! 模板fweb已创建! 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: 在此处阅读有关模板包装(NuGet)和名称参数化的更多信息:

How To Create A dotnet new Project Template In .NET Core 如何在.NET Core中创建dotnet新项目模板

How to create your own templates for dotnet new 如何为dotnet new创建自己的模板

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 VS 2017 中针对完整的 .net 框架 asp.net 核心项目运行 XUnit 2.2.0 单元测试时出现 System.BadImageFormatException - System.BadImageFormatException when running XUnit 2.2.0 unit test in VS 2017 against a full .net framework asp.net core project Asp.Net核心和脚手架 - Asp.Net Core and Scaffold 用于面向完整框架的项目的asp.net core 2.0 docker映像 - asp.net core 2.0 docker image for projects targeting full framework 用于ASP.Net Core和Full Framework项目的bootstrap.sass nuget软件包的不同安装 - Different installation for bootstrap.sass nuget package for ASP.Net Core and Full framework projects 如何对ASP.NET核心Web应用程序(.Net Framework)进行单元测试? - How do you unit test ASP.NET Core Web Application (.Net Framework)? 具有完整框架的ASP NET Core 2 - ASP NET Core 2 with Full Framework 选择完整的.NET框架和.NET Core作为ASP.NET Core目标? - Choosing between full .NET framework and .NET Core as ASP.NET Core target? ASP.NET项目的单元测试框架 - unit testing frameworks for ASP.NET projects 在ASP.NET Core中支撑现有数据库(Scaffold-DbContext) - Scaffolding existing databases in ASP.NET Core (Scaffold-DbContext) 无法在 ASP.NET 6 核 Web ZDB974238714CA8DE634A7CE1D0 中搭建 controller 脚手架 - Not able to scaffold a controller in ASP.NET 6 Core Web API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM