tridy
tridy

Reputation: 1272

Nuke Build with xUnit and .net 6.0

I was wondering if it is possible to make nuke build work with xUnit under .net 6.0

after installing the package nuke :add-package xunit.runner.console and using from a Test Target by XunitTasks.Xunit2(assemblies); I get the following exception:

System.ArgumentException: Package executable xunit.console.exe [xunit.runner.console] requires a framework:
 - net452
 - net46
 - net461
 - net462
 - net47
 - net471
 - net472
   at Nuke.Common.Assert.True(Boolean condition, String message, String argumentExpression) in /_/source/Nuke.Common/Assert.cs:line 34

will xunit.runner.console be updated to net6.0? Are there any workarounds?

Thanks!

Upvotes: 0

Views: 714

Answers (1)

tridy
tridy

Reputation: 1272

I think I have figured it out.

assuming the test project names end with *.Tests:

...

Target Test => _ => _
  .DependsOn(Compile)
  .Executes(() =>
  {
    var projects = Solution.GetProjects("*.Tests");
    
    foreach (var project in projects)
    {
        DotNetTest(_ => _
                .SetProjectFile(project.Path)
                .SetConfiguration(Configuration)
                .EnableNoBuild()
        );
    }
  });

so instead of using the xUnit tool explicitly, DotNetTest function executes the same tools (xUnit, NUnit, MSTest, etc.) as if the solution/project runs it by itself, and most likely it does not matter which version of .net is used.

Upvotes: 0

Related Questions