Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up Build.cs #2093

Merged
merged 16 commits into from Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions .nuke/build.schema.json
Expand Up @@ -79,7 +79,9 @@
"Restore",
"SpellCheck",
"TestFrameworks",
"UnitTests"
"UnitTests",
"UnitTestsWin",
"UnitTestsXPlat"
]
}
},
Expand All @@ -104,7 +106,9 @@
"Restore",
"SpellCheck",
"TestFrameworks",
"UnitTests"
"UnitTests",
"UnitTestsWin",
"UnitTestsXPlat"
]
}
},
Expand Down
59 changes: 37 additions & 22 deletions Build/Build.cs
Expand Up @@ -145,32 +145,37 @@ class Build : NukeBuild
cc => cc.SetProjectFile(Solution.Specs.Approval_Tests)));
});

Target UnitTests => _ => _
Project[] Projects => new[]
{
Solution.Specs.FluentAssertions_Specs,
Solution.Specs.FluentAssertions_Equivalency_Specs
};

Target UnitTestsNetFramework => _ => _
jnyrup marked this conversation as resolved.
Show resolved Hide resolved
.Unlisted()
.DependsOn(Compile)
.OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)
.OnlyWhenDynamic(() => EnvironmentInfo.IsWin && (RunAllTargets || HasSourceChanges))
.Executes(() =>
{
Project[] projects = new[]
{
Solution.Specs.FluentAssertions_Specs,
Solution.Specs.FluentAssertions_Equivalency_Specs
};

if (EnvironmentInfo.IsWin)
Xunit2(s =>
{
Xunit2(s =>
{
IEnumerable<string> testAssemblies = projects
.SelectMany(project => GlobFiles(project.Directory, "bin/Debug/net47/*.Specs.dll"));
IEnumerable<string> testAssemblies = Projects
.SelectMany(project => GlobFiles(project.Directory, "bin/Debug/net47/*.Specs.dll"));

Assert.NotEmpty(testAssemblies.ToList());
Assert.NotEmpty(testAssemblies.ToList());

return s
.SetFramework("net47")
.AddTargetAssemblies(testAssemblies);
});
}
return s
.SetFramework("net47")
.AddTargetAssemblies(testAssemblies);
});
});

Target UnitTestsNetCore => _ => _
.Unlisted()
.DependsOn(Compile)
.OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)
.Executes(() =>
{
DotNetTest(s => s
.SetConfiguration("Debug")
jnyrup marked this conversation as resolved.
Show resolved Hide resolved
.SetProcessEnvironmentVariable("DOTNET_CLI_UI_LANGUAGE", "en-US")
Expand All @@ -181,7 +186,7 @@ class Build : NukeBuild
"DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.DoesNotReturnAttribute",
"DoesNotReturnAttribute")
.CombineWith(
projects,
Projects,
(_, project) => _
.SetProjectFile(project)
.CombineWith(
Expand All @@ -192,8 +197,17 @@ class Build : NukeBuild
);
});

Target UnitTests => _ => _
.DependsOn(
UnitTestsNetFramework,
UnitTestsNetCore
);

Target CodeCoverage => _ => _
.DependsOn(TestFrameworks, UnitTests)
.DependsOn(
TestFrameworks,
UnitTests
)
.OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)
.Executes(() =>
{
Expand Down Expand Up @@ -254,7 +268,8 @@ class Build : NukeBuild
TestFrameworks,
UnitTests,
CodeCoverage,
CalculateNugetVersion)
CalculateNugetVersion
)
.OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)
.Produces(ArtifactsDirectory / "*.nupkg")
IT-VBFK marked this conversation as resolved.
Show resolved Hide resolved
.Executes(() =>
Expand Down