這種結構適用於我.NET核心1.0:
global.json
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003121"
}
}
的src /在MyLibrary/project.json
{
"dependencies": { },
"frameworks": {
"netstandard1.3": {
"dependencies": {
"NETStandard.Library": "1.6.0"
}
}
},
"version": "1.0.0"
}
測試/ MyLibrary.Test/project.json
{
"dependencies": {
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"MyLibrary": {
"target": "project",
"version": "1.0.0"
},
"xunit": "2.1.0"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dnxcore50",
"portable-net45+win8"
]
}
},
"testRunner": "xunit",
"version": "1.0.0"
}
使用此目錄和項目結構,Visual Studio Test Explorer和dotnet test
都可以運行,並且可以運行xUnit測試。
看到你的'project.json'和相關的代碼會很有幫助。我的猜測是你沒有正確引用你的測試項目中的主項目。你在project.json中使用'target:project'嗎? (請參閱我的答案中的示例) –