From 5043381e42ecb4552824cf7f84dd22dcf34b4dec Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Mon, 20 Dec 2021 19:04:24 +0300 Subject: [PATCH] Revert to the old way of manually parsing xunit test csproj files --- nukebuild/Build.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/nukebuild/Build.cs b/nukebuild/Build.cs index eec21d4423..1c5bd0a447 100644 --- a/nukebuild/Build.cs +++ b/nukebuild/Build.cs @@ -203,10 +203,21 @@ partial class Build : NukeBuild void RunCoreTest(string projectName) { - Information($"Running tests from {projectName}"); - var project = Solution.GetProject(projectName).NotNull("project != null"); + if(!projectName.EndsWith(".csproj")) + 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 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 {xdoc.Root.Descendants("TargetFramework").First().Value}; - foreach (var fw in project.GetTargetFrameworks()) + foreach(var fw in frameworks) { if (fw.StartsWith("net4") && RuntimeInformation.IsOSPlatform(OSPlatform.Linux) @@ -219,7 +230,7 @@ partial class Build : NukeBuild Information($"Running for {projectName} ({fw}) ..."); DotNetTest(c => c - .SetProjectFile(project) + .SetProjectFile(projectName) .SetConfiguration(Parameters.Configuration) .SetFramework(fw) .EnableNoBuild()