谁能帮我弄清楚如何在ubuntu中使用"dotnet“来设置单元测试?现在dnx和dnu已经被dotnet取代了,我遇到了一些问题。
我有一个包含以下内容的project.json文件:
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": false
},
"dependencies": {
"Microsoft.NETCore.Runtime": "1.0.1-beta-*",
"xunit": "2.1.0-*",
"xunit.runner.dnx": "2.1.0-*"
},
"commands": {
"test": "xunit.runner.dnx"
},
"frameworks": {
"dnxcore50": { }
}
}当我运行这个命令时遇到了问题:
dotnet test下面是吐出来的:
dotnet-test Error: 0 : System.DllNotFoundException: Unable to load DLL 'api-ms-win-core-localization-l1-2-0.dll': The specified module could not be found.
(Exception from HRESULT: 0x8007007E)
at Interop.mincore.FormatMessage(Int32 dwFlags, IntPtr lpSource_mustBeNull, UInt32 dwMessageId, Int32 dwLanguageId, StringBuilder lpBuffer, Int32 nSize, IntPtr[] arguments)
at Interop.mincore.TryGetErrorMessage(Int32 errorCode, StringBuilder sb, String& errorMsg)
at Interop.mincore.GetMessage(Int32 errorCode)
at System.Diagnostics.Process.ResolvePath(String filename)
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at Microsoft.DotNet.Cli.Utils.Command.Execute()
at Microsoft.DotNet.Tools.Test.Program.RunConsole(ProjectContext projectContext, CommandLineApplication app, String testRunner)
at Microsoft.DotNet.Tools.Test.Program.<>c__DisplayClass0_0.<Main>b__0()任何帮助都将不胜感激。
发布于 2016-01-16 17:23:57
不幸的是,我通过google-fu和对dotnet代码的深入研究(通过github发现了问题),找到了原因。
结论:这个功能还没有实现,还有一个不同的bug (显然已经修复了,但不是在当前的发行版中),每当试图从一个找不到的路径运行程序时,它都会尝试pInvoke到Windows DLL中。
你可以在这里看到:https://github.com/dotnet/cli/issues/407 (阅读@piotrpMSFT的最后几篇文章)
最后,事实证明:
dotnet test如果未在project.json中指定"testRunner“,将尝试运行命令"dotnet-test-”。但是,如果project.json包含如下所示的testRunner:
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": false
},
"testRunner": "xunit",
"dependencies": {
"Microsoft.NETCore.Runtime": "1.0.1-beta-*",
},
"frameworks": {
"dnxcore50": { }
}
}然后,它将尝试运行程序dotnet-test-xunit (因为"testRunner“被设置为"xunit"),并将项目DLL作为参数传递。
来吧,微软的朋友们,帮帮我,这样我就可以开始编写带测试的C# NuGet包了。
https://stackoverflow.com/questions/34737821
复制相似问题