0
我想找到一種方法來搭建一個新的ASP.NET核心網站,運行在完整的.NET框架(net461)幷包含一個單元測試項目。這是可行的嗎? dotnet new mvc
的所有選項似乎都不允許net461
作爲框架。 xunit
項目類型也是如此。腳手架ASP.NET核心與完整的框架和單元測試項目
我想找到一種方法來搭建一個新的ASP.NET核心網站,運行在完整的.NET框架(net461)幷包含一個單元測試項目。這是可行的嗎? dotnet new mvc
的所有選項似乎都不允許net461
作爲框架。 xunit
項目類型也是如此。腳手架ASP.NET核心與完整的框架和單元測試項目
構建您自己的包含兩個項目的模板。這非常簡單。在Visual Studio中創建和設置的幾個項目,並把.template.config\template.json
文件根目錄解決方案級別:
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"
}
然後與解決方案的路徑運行dotnet new --install
作爲參數:
dotnet new --install "D:\YourFullPath\DotNetTemplates"
模板fweb
已創建!轉到目標文件夾並嘗試從模板創建新的項目:
dotnet new fweb
它的完成。瞭解更多關於模板包裝(的NuGet)和名稱參數化的位置:
我在https://github.com/dotnet/dotnet有一個控制檯項目和單元測試項目的樣本-template採樣/樹/主/ 05-多項目 –