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

Remove old scripts; drop zip package; update docs #1583

Merged
merged 2 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 20 additions & 24 deletions BUILDING.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Building NUnit 3 Console and Engine

NUnit 3 consists of three separate layers: the Framework, the Engine and the Console Runner. This
repository contains the Engine and Console Runner. The source code is kept in the GitHub repository
at https://github.com/nunit/nunit-console. Source for the framework can be found
at https://github.com/nunit/nunit
NUnit 3 consists of three separate layers: the Framework, the Engine and the Console Runner. This repository contains the Engine and Console Runner. The source code is kept in the GitHub repository at https://github.com/nunit/nunit-console. Source for the framework can be found at https://github.com/nunit/nunit

Note that assemblies in one layer must not reference those in any other layer, except as follows:
* The console runner references the nunit.engine.api assembly, but not the nunit.engine assembly.
Expand All @@ -16,39 +13,38 @@ See also [Building and testing for Linux on a Windows machine](#building-and-tes
## Prerequisites

- Visual Studio 2022 or newer to build on Windows
- .NET 6.0.100 or newer
- .NET 8.0 or newer

## Solution Build

All projects are built together using a single Visual Studio solution NUnitConsole.sln, which may be
built with Visual Studio or on the command line using Cake. The projects all place their output in
a common bin directory.

The solution build is useful for verifying that everything builds correctly but doesn't create packages or run any tests. Developers working on this project are advised to run the build script periodically.

## Build Script

We use **Cake** (https://cakebuild.net) to build NUnit for distribution. The primary script that controls
building, running tests and packaging is build.cake. We modify build.cake when we need to add new
targets or change the way the build is done. Normally build.cake is not invoked directly but through
build.ps1 (on Windows) or build.sh (on Linux). These two scripts are provided by the Cake project
and ensure that Cake is properly installed before trying to run the cake script. This helps the
build to work on CI servers using newly created agents to run the build and we generally run it
the same way on our own machines.

Key arguments to build.cmd / build.ps1 / build.sh :
* --target=<task> The task to run (default is Build)
* --configuration=[Release|Debug] The configuration to use (default is Release)

The build.cake script contains a large number of interdependent tasks. The most
important top-level tasks to use are listed here:
We use **Cake** (https://cakebuild.net) to build NUnit for distribution. Our standard script targets are all wrapped in what **Cake** calls a recipe. `NUnit.Cake.Recpe` is currently used for building the runner, engine and a number of our extensions. To see all the various targets and options our recipe supports, enter `build --usage` at the command-line. **Note:** We cannot use `--help` because **Cake** uses that option for it's own help.

The primary script that sets our options for building, running tests and packaging is `build.cake`. To reduce the size of `build.cake`, our package test definitions are included from a separate file, `package-tests.cake`. There are two places in the script where we specify options.

```
* Build Builds everything. This is the default if no target is given.
* Test Runs all unit tests. Dependent on Build.
* Package Builds, Verifies and Tests all packages. Dependent on Build.
```
1. In the call to `BuildSettings.Initialize`, general options for he entire build are given. Eventually, we hope to add a help screen that explains the available options. At this time, you will need to examine the [source code](https://github.com/nunit/NUnit.Cake.Recipe/blob/main/recipe/build-settings.cake).
2. Our packages are all defined in `build.cake` by instantiating objects of type `NuGetPackage` or `ChocolateyPackage`. Once again, for documentation of available constructor arguments, you should examine the code for [NuGetPackage](https://github.com/nunit/NUnit.Cake.Recipe/blob/main/recipe/nuget-package.cake) and [ChocolatePackage](https://github.com/nunit/NUnit.Cake.Recipe/blob/main/recipe/chocolatey-package.cake).

The build is normally started by running `build` or `build.ps1` on Windows or `build.sh` on Linux. The three comands are functionally identical. They check that the necessary software is installed and then run `dotnet cake`. When running on a local machine where you know that everything is properly installed, you may use `dotnet cake` directly but it should not be used on uninitialized build agents.

For development purposes, the usual commands to run are...
* `build` alone, to simply compile everything.
* `build -t Test` to compile and run unit tests.
* `build -t Package` to compile, create packages and test them.
* `build -t Test -t Package` to compile, unit test and create and test packages.

### Building and testing for Linux on a Windows machine

> _**NOTE:** Instructions in this section have not yet been verified on the latest build of the console and engine.
If you find problems, please file an issue._

Most of the time, it's not necessary to build or run tests on platforms other than your primary
platform. The continuous integration which runs on every PR is enough to catch any problems.

Expand Down
16 changes: 0 additions & 16 deletions NUnitConsole.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
build.sh = build.sh
BUILDING.md = BUILDING.md
CHANGES.txt = CHANGES.txt
ci.cake = ci.cake
CONTRIBUTING.md = CONTRIBUTING.md
src\Directory.Build.props = src\Directory.Build.props
GitReleaseManager.yaml = GitReleaseManager.yaml
Expand All @@ -27,7 +26,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
NOTICES.txt = NOTICES.txt
NuGet.config = NuGet.config
nunit.ico = nunit.ico
old-build.cake = old-build.cake
package-tests.cake = package-tests.cake
README.md = README.md
VERSIONING.md = VERSIONING.md
Expand Down Expand Up @@ -126,19 +124,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "aspnetcore-test", "src\Test
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "windows-test", "src\TestData\windows-test\windows-test.csproj", "{5BD1B0BA-6DD3-4619-B5E0-4FFF19F941C2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cake", "cake", "{8D54099B-F770-47C7-91A0-8348FF271E2A}"
ProjectSection(SolutionItems) = preProject
cake\build-settings.cake = cake\build-settings.cake
cake\constants.cake = cake\constants.cake
cake\dotnet.cake = cake\dotnet.cake
cake\header-check.cake = cake\header-check.cake
cake\package-checks.cake = cake\package-checks.cake
cake\package-definitions.cake = cake\package-definitions.cake
cake\test-results.cake = cake\test-results.cake
cake\utilities.cake = cake\utilities.cake
cake\versioning.cake = cake\versioning.cake
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{B25157A1-B3CD-40FB-89F2-A7206C0B553A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{9375E2BF-5AF9-4773-A5D1-EA16D9006940}"
Expand Down Expand Up @@ -296,7 +281,6 @@ Global
{9667833E-A037-41C9-A3BC-D218903EF670} = {576DB1E6-C5EC-4FEF-A826-EC19D8BEE572}
{7CD5F602-368E-41E3-8C61-42093CB12D70} = {37D508B2-91E0-4B32-869B-DFF9E68EA213}
{5BD1B0BA-6DD3-4619-B5E0-4FFF19F941C2} = {37D508B2-91E0-4B32-869B-DFF9E68EA213}
{8D54099B-F770-47C7-91A0-8348FF271E2A} = {49D441DF-39FD-4F4D-AECA-86CF8EFE23AF}
{B25157A1-B3CD-40FB-89F2-A7206C0B553A} = {49D441DF-39FD-4F4D-AECA-86CF8EFE23AF}
{9375E2BF-5AF9-4773-A5D1-EA16D9006940} = {B25157A1-B3CD-40FB-89F2-A7206C0B553A}
{0F76DA4A-58B9-4B45-BEC5-259105570D11} = {49D441DF-39FD-4F4D-AECA-86CF8EFE23AF}
Expand Down
82 changes: 1 addition & 81 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -119,56 +119,6 @@ BuildSettings.Packages.AddRange(new PackageDefinition[] {
+ $"nunit-console-runner.{BuildSettings.PackageVersion}/tools/nunit4-console.exe"),
tests: StandardRunnerTests),

//NUnitConsoleZipPackage = new ZipPackage(
// id: "NUnit.Console",
// source: BuildSettings.ZipImageDirectory,
// checks: new PackageCheck[] {
// HasFiles("LICENSE.txt", "NOTICES.txt", "CHANGES.txt"),
// HasDirectory("bin/net462").WithFiles(
// "nunit4-console.exe", "nunit4-console.exe.config", "nunit4-console.pdb",
// "nunit.engine.dll", "nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll",
// "nunit.engine.pdb", "nunit.engine.core.pdb", "nunit.engine.api.pdb"),
// //HasDirectory("bin/net462/addins").WithFiles(
// // "nunit.core.dll", "nunit.core.interfaces.dll", "nunit.engine.api.dll",
// // "nunit.v2.driver.dll", "nunit-project-loader.dll", "nunit-v2-result-writer.dll",
// // "teamcity-event-listener.dll", "vs-project-loader.dll"),
// HasDirectory("bin/netcoreapp3.1").WithFiles(
// "nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll",
// "nunit.engine.core.pdb", "nunit.engine.api.pdb"),
// HasDirectory("bin/agents/net462").WithFiles(
// "nunit-agent-net462.exe", "nunit-agent-net462.exe.config",
// "nunit-agent-net462-x86.exe", "nunit-agent-net462-x86.exe.config",
// "nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll",
// "nunit-agent-net462.pdb", "nunit-agent-net462-x86.pdb", "nunit.engine.core.pdb", "nunit.engine.api.pdb"),
// HasDirectory("bin/agents/net6.0").WithFiles(
// "nunit-agent-net60.dll", "nunit-agent-net60.dll.config",
// "nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll",
// "Microsoft.Extensions.DependencyModel.dll",
// "nunit-agent-net60.pdb", "nunit.engine.core.pdb", "nunit.engine.api.pdb"),
// HasDirectory("bin/agents/net7.0").WithFiles(
// "nunit-agent-net70.dll", "nunit-agent-net70.dll.config",
// "nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll",
// "Microsoft.Extensions.DependencyModel.dll",
// "nunit-agent-net70.pdb", "nunit.engine.core.pdb", "nunit.engine.api.pdb"),
// HasDirectory("bin/agents/net8.0").WithFiles(
// "nunit-agent-net80.dll", "nunit-agent-net80.dll.config",
// "nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll",
// "Microsoft.Extensions.DependencyModel.dll",
// "nunit-agent-net80.pdb", "nunit.engine.core.pdb", "nunit.engine.api.pdb")
// },
// testRunner: new ConsoleRunnerSelfTester(BuildSettings.ZipTestDirectory
// + $"NUnit.Console.{BuildSettings.PackageVersion}/bin/net462/nunit4-console.exe"),
// tests: StandardRunnerTests,
// bundledExtensions: new [] {
// KnownExtensions.VSProjectLoader.NuGetPackage,
// KnownExtensions.NUnitProjectLoader.NuGetPackage,
// //KnownExtensions.NUnitV2Driver.NuGetPackage,
// KnownExtensions.NUnitV2ResultWriter.NuGetPackage,
// KnownExtensions.TeamCityEventListener.NuGetPackage
// }),

// NOTE: Packages below this point have no direct tests

NUnitEnginePackage = new NuGetPackage(
id: "NUnit.Engine",
source: BuildSettings.NuGetDirectory + "engine/nunit.engine.nuspec",
Expand Down Expand Up @@ -209,38 +159,8 @@ BuildSettings.Packages.AddRange(new PackageDefinition[] {
})
});

Task("BuildZipPackage")
.Does(() =>
{
NUnitConsoleZipPackage.BuildPackage();
});

Task("InstallZipPackage")
.Does(() =>
{
NUnitConsoleZipPackage.InstallPackage();
});

Task("VerifyZipPackage")
.Does(() =>
{
NUnitConsoleZipPackage.VerifyPackage();
});

Task("TestZipPackage")
.Does(() =>
{
NUnitConsoleZipPackage.RunPackageTests();
});

Task("TestNetCorePackage")
.Does(() =>
{
NUnitConsoleRunnerNetCorePackage.RunPackageTests();
});

//////////////////////////////////////////////////////////////////////
// TEST RUNNERS
// PACKAGE TEST RUNNER
//////////////////////////////////////////////////////////////////////

// Use the console runner we just built to run package tests
Expand Down
Loading
Loading