travis for C#的问题

Travis CI now supports C#(测试中) . 尝试了8种不同的方法后,我无法找到解决问题的方法 .

我有一个ASP MVC项目,travis使用mono,我知道我不能在travis中构建这种项目

script:
    - xbuild project.sln

好吧没问题,但我想通过我的测试,我找到的最佳解决方案是:

language: csharp
solution: OptionType.sln
install:
  - sudo apt-get install mono-devel mono-gmcs nunit-console
script:
  - nunit-console MSPSpain.Tests/bin/Debug/MSPSpain.Tests.dll

但失败了.. https://travis-ci.org/MSPSpain/Website/builds/43711017

936ProcessModel: Default    DomainUsage: Single

937Execution Runtime: mono-4.0

938Missing method .ctor in     assembly /home/travis/build/MSPSpain/Website/MSPSpain.Tests/bin/Debug/MSPSpain.Tests.dll, type     Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute

939Can't find custom attr constructor     image: /home/travis/build/MSPSpain/Website/MSPSpain.Tests/bin/Debug/MSPSpain.Tests.dll mtoken:     0x0a000011

940Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.UnitTestFramework,     Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

941

942The command "nunit-console MSPSpain.Tests/bin/Debug/MSPSpain.Tests.dll" exited with 254.

我搜索了很多关于这一点,我找不到解决问题的最佳方法 .

回答(1)

3 years ago

您的测试使用MSTest并引用Microsoft.VisualStudio.QualityTools.UnitTestFramework程序集,该程序集通常由Visual Studio安装 .

Microsoft.VisualStudio.QualityTools.UnitTestFramework将不包含在Mono中 .

如果你想在Windows和Mono上运行测试,最简单的解决方案可能是switch to using NUnit instead of MSTest .

虽然可以在Windows上获得MSTest installed without Visual Studio,但我怀疑在非Windows操作系统上无法实现这一点 .