[英]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.