为什么"dotnet test"在 ubuntu LTS 14.04 上失败?



有人能帮我弄清楚如何在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()

如有任何帮助,我们将不胜感激。

遗憾的是,我在谷歌上搜索了一些fu并通过dotnet代码(以及通过github发布的问题)后找到了原因。

最重要的是:该功能尚未实现,并且有一个不同的错误(显然已经修复,但在当前发行版中没有),每当试图从找不到的路径运行程序时,它都会试图将其插入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包了。

最新更新