Browse Source

Revert to the old way of manually parsing xunit test csproj files

release/0.10.11
Nikita Tsukanov 5 years ago
parent
commit
5043381e42
  1. 19
      nukebuild/Build.cs

19
nukebuild/Build.cs

@ -203,10 +203,21 @@ partial class Build : NukeBuild
void RunCoreTest(string projectName) void RunCoreTest(string projectName)
{ {
Information($"Running tests from {projectName}"); if(!projectName.EndsWith(".csproj"))
var project = Solution.GetProject(projectName).NotNull("project != null"); projectName = System.IO.Path.Combine(projectName, System.IO.Path.GetFileName(projectName)+".csproj");
Information("Running tests from " + projectName);
XDocument xdoc;
using (var s = File.OpenRead(projectName))
xdoc = XDocument.Load(s);
List<string> frameworks = null;
var targets = xdoc.Root.Descendants("TargetFrameworks").FirstOrDefault();
if (targets != null)
frameworks = targets.Value.Split(';').Where(f => !string.IsNullOrWhiteSpace(f)).ToList();
else
frameworks = new List<string> {xdoc.Root.Descendants("TargetFramework").First().Value};
foreach (var fw in project.GetTargetFrameworks()) foreach(var fw in frameworks)
{ {
if (fw.StartsWith("net4") if (fw.StartsWith("net4")
&& RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
@ -219,7 +230,7 @@ partial class Build : NukeBuild
Information($"Running for {projectName} ({fw}) ..."); Information($"Running for {projectName} ({fw}) ...");
DotNetTest(c => c DotNetTest(c => c
.SetProjectFile(project) .SetProjectFile(projectName)
.SetConfiguration(Parameters.Configuration) .SetConfiguration(Parameters.Configuration)
.SetFramework(fw) .SetFramework(fw)
.EnableNoBuild() .EnableNoBuild()

Loading…
Cancel
Save