Skip to content

Commit

Permalink
Revert to the old way of manually parsing xunit test csproj files
Browse files Browse the repository at this point in the history
  • Loading branch information
kekekeks committed Dec 20, 2021
1 parent 25602ca commit 5043381
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions nukebuild/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,21 @@ await ObservablesForEventGenerator.ExtractEventsFromAssemblies(

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<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")
&& RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
Expand All @@ -219,7 +230,7 @@ void RunCoreTest(string projectName)
Information($"Running for {projectName} ({fw}) ...");

DotNetTest(c => c
.SetProjectFile(project)
.SetProjectFile(projectName)
.SetConfiguration(Parameters.Configuration)
.SetFramework(fw)
.EnableNoBuild()
Expand Down

0 comments on commit 5043381

Please sign in to comment.