Skip to content

Commit

Permalink
Merge pull request #1494 from nunit/net80-engine
Browse files Browse the repository at this point in the history
Fix packaging errors
  • Loading branch information
CharliePoole authored Oct 4, 2024
2 parents e662ebf + c21d773 commit 79cb823
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 18 deletions.
110 changes: 95 additions & 15 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,31 @@ BuildSettings.Initialize(

//////////////////////////////////////////////////////////////////////
// LISTS OF FILES USED IN CHECKING PACKAGES
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////

FilePath[] ConsoleFiles = {
"nunit3-console.dll", "nunit3-console.dll.config", "nunit3-console.exe", "nunit3-console.pdb",
"nunit3-console.deps.json", "nunit3-console.runtimeconfig.json", "nunit.console.nuget.addins" };
FilePath[] ENGINE_FILES = {
"nunit.engine.dll", "nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll" };
"nunit.engine.dll", "nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll" };
FilePath[] ENGINE_PDB_FILES = {
"nunit.engine.pdb", "nunit.engine.core.pdb", "nunit.engine.api.pdb"};
"nunit.engine.pdb", "nunit.engine.core.pdb", "nunit.engine.api.pdb"};
FilePath[] ENGINE_CORE_FILES = {
"nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll" };
"nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll" };
FilePath[] ENGINE_CORE_PDB_FILES = {
"nunit.engine.core.pdb", "nunit.engine.api.pdb"};
"nunit.engine.core.pdb", "nunit.engine.api.pdb"};
FilePath[] AGENT_FILES = {
"nunit-agent.exe", "nunit-agent.exe.config",
"nunit-agent-x86.exe", "nunit-agent-x86.exe.config",
"nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll"};
"nunit-agent.exe", "nunit-agent.exe.config",
"nunit-agent-x86.exe", "nunit-agent-x86.exe.config",
"nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll"};
FilePath[] AGENT_FILES_NETCORE = {
"nunit-agent.dll", "nunit-agent.dll.config",
"nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll",
"Microsoft.Extensions.DependencyModel.dll"};
"nunit-agent.dll", "nunit-agent.dll.config",
"nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll",
"Microsoft.Extensions.DependencyModel.dll"};
FilePath[] AGENT_PDB_FILES = {
"nunit-agent.pdb", "nunit-agent-x86.pdb", "nunit.engine.core.pdb", "nunit.engine.api.pdb"};
"nunit-agent.pdb", "nunit-agent-x86.pdb", "nunit.engine.core.pdb", "nunit.engine.api.pdb"};
FilePath[] AGENT_PDB_FILES_NETCORE = {
"nunit-agent.pdb", "nunit.engine.core.pdb", "nunit.engine.api.pdb"};
"nunit-agent.pdb", "nunit.engine.core.pdb", "nunit.engine.api.pdb"};

//////////////////////////////////////////////////////////////////////
// INDIVIDUAL PACKAGE DEFINITIONS
Expand Down Expand Up @@ -86,15 +89,24 @@ BuildSettings.Packages.AddRange(new PackageDefinition[] {
NUnitConsoleRunnerNetCorePackage = new DotNetToolPackage(
id: "NUnit.ConsoleRunner.NetCore",
source: BuildSettings.NuGetDirectory + "runners/nunit.console-runner.netcore.nuspec",
checks: new PackageCheck[] { HasFiles("nunit.exe") },
checks: new PackageCheck[]
{
HasFiles("nunit.exe"),
HasSomeDirectory(".store/nunit.consolerunner.netcore/**/tools/net6.0/any")
.WithFiles(ENGINE_FILES).AndFiles(ConsoleFiles).AndFile("Microsoft.Extensions.DependencyModel.dll")
},
testRunner: new ConsoleRunnerSelfTester(BuildSettings.NuGetTestDirectory
+ $"NUnit.ConsoleRunner.NetCore.{BuildSettings.PackageVersion}/nunit.exe"),
tests: NetCoreRunnerTests),

NUnitConsoleRunnerNet80Package = new DotNetToolPackage(
id: "NUnit.ConsoleRunner.Net80",
source: BuildSettings.NuGetDirectory + "runners/nunit.console-runner.net80.nuspec",
checks: new PackageCheck[] { HasFiles("nunit-net80.exe") },
checks: new PackageCheck[] {
HasFiles("nunit-net80.exe"),
HasSomeDirectory(".store/nunit.consolerunner.net80/**/tools/net8.0/any")
.WithFiles(ENGINE_FILES).AndFiles(ConsoleFiles).AndFile("Microsoft.Extensions.DependencyModel.dll")
},
testRunner: new ConsoleRunnerSelfTester(BuildSettings.NuGetTestDirectory
+ $"NUnit.ConsoleRunner.Net80.{BuildSettings.PackageVersion}/nunit-net80.exe"),
tests: NetCoreRunnerTests),
Expand Down Expand Up @@ -147,13 +159,19 @@ BuildSettings.Packages.AddRange(new PackageDefinition[] {
HasFiles("LICENSE.txt", "NOTICES.txt"),
HasDirectory("lib/net462").WithFiles(ENGINE_FILES),
HasDirectory("lib/netstandard2.0").WithFiles(ENGINE_FILES),
HasDirectory("lib/net6.0").WithFiles(ENGINE_FILES).AndFile("Microsoft.Extensions.DependencyModel.dll"),
HasDirectory("lib/net8.0").WithFiles(ENGINE_FILES).AndFile("Microsoft.Extensions.DependencyModel.dll"),
HasDirectory("contentFiles/any/lib/net462").WithFile("nunit.engine.nuget.addins"),
HasDirectory("contentFiles/any/lib/netstandard2.0").WithFile("nunit.engine.nuget.addins"),
HasDirectory("contentFiles/any/lib/net6.0").WithFile("nunit.engine.nuget.addins"),
HasDirectory("contentFiles/any/lib/net8.0").WithFile("nunit.engine.nuget.addins"),
HasDirectory("contentFiles/any/agents/net462").WithFiles(AGENT_FILES).AndFile("nunit.agent.addins")
},
symbols: new PackageCheck[] {
HasDirectory("lib/net462").WithFiles(ENGINE_PDB_FILES),
HasDirectory("lib/netstandard2.0").WithFiles(ENGINE_PDB_FILES),
HasDirectory("lib/net6.0").WithFiles(ENGINE_PDB_FILES),
HasDirectory("lib/net8.0").WithFiles(ENGINE_PDB_FILES),
HasDirectory("contentFiles/any/agents/net462").WithFiles(AGENT_PDB_FILES)
}),

Expand All @@ -171,6 +189,68 @@ BuildSettings.Packages.AddRange(new PackageDefinition[] {
})
});

// Adhoc code to check content of a dotnet standalone executable
// TODO: Incorporate this in the recipe itself

private static ExtendedDirectoryCheck HasSomeDirectory(string pattern) => new ExtendedDirectoryCheck(pattern);

public class ExtendedDirectoryCheck : PackageCheck
{
private string _directoryPattern;
private List<FilePath> _files = new List<FilePath>();

public ExtendedDirectoryCheck(string directoryPattern)
{
// Assume it has no wildcard - checked in ApplyTo method
_directoryPattern = directoryPattern;
}

public ExtendedDirectoryCheck WithFiles(params FilePath[] files)
{
_files.AddRange(files);
return this;
}

public ExtendedDirectoryCheck AndFiles(params FilePath[] files)
{
return WithFiles(files);
}

public ExtendedDirectoryCheck WithFile(FilePath file)
{
_files.Add(file);
return this;
}

public ExtendedDirectoryCheck AndFile(FilePath file)
{
return AndFiles(file);
}

public override bool ApplyTo(DirectoryPath testDirPath)
{
if (_directoryPattern.Contains('*') || _directoryPattern.Contains('?')) // Wildcard
{
var absDirPattern = testDirPath.Combine(_directoryPattern).ToString();
foreach (var dir in _context.GetDirectories(absDirPattern))
{
// Use first one found
return CheckFilesExist(_files.Select(file => dir.CombineWithFilePath(file)));
}
}
else // No wildcard
{
var absDirPath = testDirPath.Combine(_directoryPattern);
if (!CheckDirectoryExists(absDirPath))
return false;

return CheckFilesExist(_files.Select(file => absDirPath.CombineWithFilePath(file)));
}

return false;
}
}

//////////////////////////////////////////////////////////////////////
// TEST RUNNERS
//////////////////////////////////////////////////////////////////////
Expand Down
20 changes: 20 additions & 0 deletions nuget/engine/nunit.engine.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,26 @@
<file src="netstandard2.0/testcentric.engine.metadata.dll" target="lib/netstandard2.0" />
<file src="../../nuget/engine/nunit.engine.nuget.addins" target="contentFiles/any/lib/netstandard2.0"/>

<file src="net6.0/nunit.engine.dll" target="lib/net6.0" />
<file src="net6.0/nunit.engine.pdb" target="lib/net6.0" />
<file src="net6.0/nunit.engine.core.dll" target="lib/net6.0" />
<file src="net6.0/nunit.engine.core.pdb" target="lib/net6.0" />
<file src="net6.0/nunit.engine.api.dll" target="lib/net6.0" />
<file src="net6.0/nunit.engine.api.pdb" target="lib/net6.0" />
<file src="net6.0/testcentric.engine.metadata.dll" target="lib/net6.0" />
<file src="net6.0/Microsoft.Extensions.DependencyModel.dll" target="lib/net6.0" />
<file src="../../nuget/engine/nunit.engine.nuget.addins" target="contentFiles/any/lib/net6.0"/>

<file src="net8.0/nunit.engine.dll" target="lib/net8.0" />
<file src="net8.0/nunit.engine.pdb" target="lib/net8.0" />
<file src="net8.0/nunit.engine.core.dll" target="lib/net8.0" />
<file src="net8.0/nunit.engine.core.pdb" target="lib/net8.0" />
<file src="net8.0/nunit.engine.api.dll" target="lib/net8.0" />
<file src="net8.0/nunit.engine.api.pdb" target="lib/net8.0" />
<file src="net8.0/testcentric.engine.metadata.dll" target="lib/net8.0" />
<file src="net8.0/Microsoft.Extensions.DependencyModel.dll" target="lib/net8.0" />
<file src="../../nuget/engine/nunit.engine.nuget.addins" target="contentFiles/any/lib/net8.0"/>

<file src="../../nuget/engine/build/**/*" target="build" />
<file src="../../nunit_256.png" target="images" />
</files>
Expand Down
2 changes: 2 additions & 0 deletions src/NUnitEngine/nunit.engine.tests/Helpers/ShadowCopyUtils.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

#if NETFRAMEWORK
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -40,3 +41,4 @@ from assemblyName in assemblyNames
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

#if NETFRAMEWORK
using System;
using System.IO;
using NUnit.Engine.Tests.Helpers;
Expand Down Expand Up @@ -31,3 +32,4 @@ public void Dispose()
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

#if NETFRAMEWORK
using System;
using System.IO;
using NUnit.Framework;
Expand All @@ -25,3 +26,4 @@ public void Dispose()
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

#if NETFRAMEWORK
using System;
using System.IO;
using System.Threading;
Expand Down Expand Up @@ -39,3 +40,4 @@ public void Dispose()
}
}
}
#endif
4 changes: 2 additions & 2 deletions src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<RootNamespace>NUnit.Engine.Tests</RootNamespace>
<TargetFrameworks>net462;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.1;net6.0;net8.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\nunit.snk</AssemblyOriginatorKeyFile>
Expand All @@ -23,7 +23,7 @@
<PackageReference Include="NSubstitute" Version="2.0.3" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net462'">
<ItemGroup Condition="'$(TargetFramework)'!='netcoreapp3.1'">
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnitLite" Version="4.2.2" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
Expand Down
3 changes: 3 additions & 0 deletions src/NUnitEngine/nunit.engine/Runners/TestEventDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public void OnTestEvent(string report)
}
}

#if NET6_0 || NET8_0
[Obsolete]
#endif
public override object InitializeLifetimeService()
{
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/NUnitEngine/nunit.engine/nunit.engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<RootNamespace>NUnit.Engine</RootNamespace>
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net462;netstandard2.0;net6.0;net8.0</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\nunit.snk</AssemblyOriginatorKeyFile>
<DebugType>portable</DebugType>
Expand Down

0 comments on commit 79cb823

Please sign in to comment.