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

Create a net7.0 agent #1219

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 3 additions & 2 deletions NUnitConsole.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29728.190
# Visual Studio Version 17
VisualStudioVersion = 17.1.32228.430
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{49D441DF-39FD-4F4D-AECA-86CF8EFE23AF}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -20,6 +20,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
src\Directory.Build.props = src\Directory.Build.props
GitReleaseManager.yaml = GitReleaseManager.yaml
GitVersion.yml = GitVersion.yml
global.json = global.json
header-check.cake = header-check.cake
LICENSE.txt = LICENSE.txt
NetFXTests.nunit = NetFXTests.nunit
Expand Down
13 changes: 13 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ branches:
except:
- /^azure-/

install:
- ps: $urlNet70RC = "https://download.visualstudio.microsoft.com/download/pr/b3b5dce4-d810-4477-a8a3-97cbb0bdf3ea/91d0dd167239cfdfb48ae18166f444d4/dotnet-sdk-7.0.100-rc.1.22431.12-win-x64.zip"
- ps: echo "Download from $urlNet70RC"
- ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetsdk"
- ps: mkdir $env:DOTNET_INSTALL_DIR -Force | Out-Null
- ps: echo "Created directory $env:DOTNET_INSTALL_DIR"
- ps: echo "Starting download"
- ps: $tempFileNet70RC = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), [System.IO.Path]::GetRandomFileName())
- ps: (New-Object System.Net.WebClient).DownloadFile($urlNet70RC, $tempFileNet70RC)
- ps: Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory($tempFileNet70RC, $env:DOTNET_INSTALL_DIR)
- ps: echo "Download complete"
- ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"

build_script:
- ps: .\build.ps1 --target=Appveyor --configuration=Release

Expand Down
7 changes: 6 additions & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,13 @@ public void BuildSolution()
.WithProperty("TargetFramework", "netcoreapp2.1")
.WithProperty("PublishDir", BIN_DIR + "netcoreapp2.1"));

DisplayBanner("Publishing MOCK ASSEMBLY Project for NET7.0");
MSBuild(MOCK_ASSEMBLY_PROJECT, CreateMSBuildSettings("Publish")
.WithProperty("TargetFramework", "net7.0")
.WithProperty("PublishDir", BIN_DIR + "net7.0"));

// TODO: May not be needed
foreach (var framework in new[] { "netcoreapp3.1", "net5.0" })
foreach (var framework in new[] { "netcoreapp3.1", "net5.0", "net7.0" })
{
DisplayBanner($"Publishing AGENT Project for {framework.ToUpper()}");
MSBuild(AGENT_PROJECT, CreateMSBuildSettings("Publish")
Expand Down
16 changes: 13 additions & 3 deletions cake/package-definitions.cake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public void InitializePackageDefinitions(ICakeContext context)
NetCore31Test,
Net50Test,
Net60Test,
// Net70Test,
NetCore21PlusNetCore31Test,
NetCore21PlusNetCore31PlusNet50PlusNet60Test,
Net40PlusNet60Test
Expand Down Expand Up @@ -71,15 +72,17 @@ public void InitializePackageDefinitions(ICakeContext context)
HasDirectory("tools/agents/net40").WithFiles(AGENT_FILES).AndFile("nunit.agent.addins"),
HasDirectory("tools/agents/netcoreapp3.1").WithFiles(AGENT_FILES_NETCORE).AndFile("nunit.agent.addins"),
HasDirectory("tools/agents/net5.0").WithFiles(AGENT_FILES_NETCORE).AndFile("nunit.agent.addins"),
HasDirectory("tools/agents/net6.0").WithFiles(AGENT_FILES_NETCORE).AndFile("nunit.agent.addins")
HasDirectory("tools/agents/net6.0").WithFiles(AGENT_FILES_NETCORE).AndFile("nunit.agent.addins"),
HasDirectory("tools/agents/net7.0").WithFiles(AGENT_FILES_NETCORE).AndFile("nunit.agent.addins")
},
symbols: new PackageCheck[] {
HasDirectory("tools").WithFiles(ENGINE_PDB_FILES).AndFile("nunit3-console.pdb"),
HasDirectory("tools/agents/net20").WithFiles(AGENT_PDB_FILES),
HasDirectory("tools/agents/net40").WithFiles(AGENT_PDB_FILES),
HasDirectory("tools/agents/netcoreapp3.1").WithFiles(AGENT_PDB_FILES_NETCORE),
HasDirectory("tools/agents/net5.0").WithFiles(AGENT_PDB_FILES_NETCORE),
HasDirectory("tools/agents/net6.0").WithFiles(AGENT_PDB_FILES_NETCORE)
HasDirectory("tools/agents/net6.0").WithFiles(AGENT_PDB_FILES_NETCORE),
HasDirectory("tools/agents/net7.0").WithFiles(AGENT_PDB_FILES_NETCORE)
},
executable: "tools/nunit3-console.exe",
tests: StandardRunnerTests),
Expand Down Expand Up @@ -110,7 +113,8 @@ public void InitializePackageDefinitions(ICakeContext context)
HasDirectory("tools/agents/net40").WithFiles(AGENT_FILES).AndFile("nunit.agent.addins"),
HasDirectory("tools/agents/netcoreapp3.1").WithFiles(AGENT_FILES_NETCORE).AndFile("nunit.agent.addins"),
HasDirectory("tools/agents/net5.0").WithFiles(AGENT_FILES_NETCORE).AndFile("nunit.agent.addins"),
HasDirectory("tools/agents/net6.0").WithFiles(AGENT_FILES_NETCORE).AndFile("nunit.agent.addins")
HasDirectory("tools/agents/net6.0").WithFiles(AGENT_FILES_NETCORE).AndFile("nunit.agent.addins"),
HasDirectory("tools/agents/net7.0").WithFiles(AGENT_FILES_NETCORE).AndFile("nunit.agent.addins")
},
executable: "tools/nunit3-console.exe",
tests: StandardRunnerTests),
Expand All @@ -123,6 +127,12 @@ public void InitializePackageDefinitions(ICakeContext context)
checks: new PackageCheck[] {
HasDirectory("NUnit.org").WithFiles("LICENSE.txt", "NOTICES.txt", "nunit.ico"),
HasDirectory("NUnit.org/nunit-console").WithFiles(CONSOLE_FILES).AndFiles(ENGINE_FILES).AndFile("nunit.bundle.addins"),
HasDirectory("NUnit.org/nunit-console/agents/net20").WithFiles("nunit-agent.exe", "nunit-agent.exe.config"),
HasDirectory("NUnit.org/nunit-console/agents/net40").WithFiles("nunit-agent.exe", "nunit-agent.exe.config"),
HasDirectory("NUnit.org/nunit-console/agents/netcoreapp3.1").WithFile("nunit-agent.dll"),
HasDirectory("NUnit.org/nunit-console/agents/net5.0").WithFile("nunit-agent.dll"),
HasDirectory("NUnit.org/nunit-console/agents/net6.0").WithFile("nunit-agent.dll"),
//HasDirectory("NUnit.org/nunit-console/agents/net7.0").WithFile("nunit-agent.dll"),
HasDirectory("Nunit.org/nunit-console/addins").WithFiles("nunit.core.dll", "nunit.core.interfaces.dll", "nunit.v2.driver.dll", "nunit-project-loader.dll", "vs-project-loader.dll", "nunit-v2-result-writer.dll", "teamcity-event-listener.dll")
},
executable: "NUnit.org/nunit-console/nunit3-console.exe",
Expand Down
6 changes: 6 additions & 0 deletions cake/package-tests.cake
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ static PackageTest Net60Test = new PackageTest(
"net6.0/mock-assembly.dll",
MockAssemblyExpectedResult(1));

static PackageTest Net70Test = new PackageTest(
"Net70Test",
"Run mock-assembly.dll under .NET 7.0",
"net7.0/mock-assembly.dll",
MockAssemblyExpectedResult(1));

static PackageTest Net50Test = new PackageTest(
"Net50Test",
"Run mock-assembly.dll under .NET 5.0",
Expand Down
4 changes: 4 additions & 0 deletions cake/versioning.cake
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public class BuildVersion

string branchName = _gitVersion.BranchName;

// Treat version3 branch as an alternate "main"
if (branchName == "version3")
label = "dev";

// We don't currently use this pattern, but check in case we do later.
if (branchName.StartsWith("feature/"))
branchName = branchName.Substring(8);
Expand Down
10 changes: 10 additions & 0 deletions choco/nunit-console-runner.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,15 @@
<file src = "$BIN_DIR$agents/net6.0/nunit.engine.core.dll" target="tools/agents/net6.0" />
<file src = "$BIN_DIR$agents/net6.0/testcentric.engine.metadata.dll" target="tools/agents/net6.0" />
<file src = "nunit.agent.addins" target = "tools/agents/net6.0" />

<file src = "$BIN_DIR$agents/net7.0/nunit-agent.dll" target="tools/agents/net7.0" />
<file src = "$BIN_DIR$agents/net7.0/nunit-agent.dll.config" target="tools/agents/net7.0" />
<file src = "$BIN_DIR$agents/net7.0/nunit-agent.deps.json" target="tools/agents/net7.0" />
<file src = "$BIN_DIR$agents/net7.0/nunit-agent.runtimeconfig.json" target="tools/agents/net7.0" />
<file src = "$BIN_DIR$agents/net7.0/nunit.engine.api.dll" target="tools/agents/net7.0" />
<file src = "$BIN_DIR$agents/net7.0/nunit.engine.api.xml" target="tools/agents/net7.0" />
<file src = "$BIN_DIR$agents/net7.0/nunit.engine.core.dll" target="tools/agents/net7.0" />
<file src = "$BIN_DIR$agents/net7.0/testcentric.engine.metadata.dll" target="tools/agents/net7.0" />
<file src = "nunit.agent.addins" target = "tools/agents/net7.0" />
</files>
</package>
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.101",
"rollForward": "patch"
"version": "7.0.100-rc.1.22431.12",
"rollForward": "feature"
}
}
30 changes: 30 additions & 0 deletions msi/nunit/engine-files.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<ComponentGroupRef Id="NETCORE31_AGENT" />
<ComponentGroupRef Id="NET50_AGENT" />
<ComponentGroupRef Id="NET60_AGENT" />
<ComponentGroupRef Id="NET70_AGENT" />
</ComponentGroup>
</Fragment>
<Fragment>
Expand Down Expand Up @@ -174,5 +175,34 @@
Source="$(var.InstallImage)bin/net6.0/testcentric.engine.metadata.dll" />
</Component>
</ComponentGroup>
<ComponentGroup Id="NET70_AGENT" Directory="NET70_AGENT_DIR">
<Component Id="NUNIT_AGENT_NET70" Location="local" Guid="5D10D513-F5C4-461F-B11C-D51C0CD14F89">
<File Id="nunit_agent_net70.exe"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/agents/net7.0/nunit-agent.dll" />
<File Id="nunit_agent_net70.deps.json"
Source="$(var.InstallImage)bin/agents/net7.0/nunit-agent.deps.json" />
<File Id="nunit_agent_net70.runtimeconfig.json"
Source="$(var.InstallImage)bin/agents/net7.0/nunit-agent.runtimeconfig.json" />
</Component>
<!-- Engine files are currently not built for .NET 7.0 so we use 6.0 -->
<Component Id="NUNIT_AGENT_NET70_ENGINE_API" Location="local" Guid="A1318B84-3E15-45A9-B49E-475ED06ADCCD">
<File Id="nunit.agent.net70.engine.api.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/net6.0/nunit.engine.api.dll" />
<File Id="nunit.agent.net70.engine.api.xml"
Source="$(var.InstallImage)bin/net6.0/nunit.engine.api.xml" />
</Component>
<Component Id="NUNIT_AGENT_NET70_ENGINE_CORE" Location="local" Guid="CBA7AA8D-B7D8-43F5-901A-2044DE1E07A7">
<File Id="nunit.agent.net70.engine.core.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/net6.0/nunit.engine.core.dll" />
</Component>
<Component Id="NUNIT_AGENT_NET70_ENGINE_METADATA" Location="local" Guid="1F887300-4C7A-4574-A1DD-D925228DA217">
<File Id="nunit.agent.net70.engine.metadata.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/net6.0/testcentric.engine.metadata.dll" />
</Component>
</ComponentGroup>
</Fragment>
</Include>
1 change: 1 addition & 0 deletions msi/nunit/runner-directories.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<Directory Id="NETCORE31_AGENT_DIR" Name="netcoreapp3.1" />
<Directory Id="NET50_AGENT_DIR" Name="net5.0" />
<Directory Id="NET60_AGENT_DIR" Name="net6.0" />
<Directory Id="NET70_AGENT_DIR" Name="net7.0" />
</Directory>
</Directory>
</DirectoryRef>
Expand Down
13 changes: 13 additions & 0 deletions nuget/runners/nunit.console-runner.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@
<file src="agents/net6.0/testcentric.engine.metadata.dll" target="tools/agents/net6.0" />
<file src="../../nuget/engine/nunit.agent.addins" target="tools/agents/net6.0"/>

<file src="agents/net7.0/nunit-agent.dll" target="tools/agents/net7.0" />
<file src="agents/net7.0/nunit-agent.pdb" target="tools/agents/net7.0" />
<file src="agents/net7.0/nunit-agent.dll.config" target="tools/agents/net7.0" />
<file src="agents/net7.0/nunit-agent.deps.json" target="tools/agents/net7.0" />
<file src="agents/net7.0/nunit-agent.runtimeconfig.json" target="tools/agents/net7.0" />
<file src="agents/net7.0/nunit.engine.api.dll" target="tools/agents/net7.0" />
<file src="agents/net7.0/nunit.engine.api.pdb" target="tools/agents/net7.0" />
<file src="agents/net7.0/nunit.engine.api.xml" target="tools/agents/net7.0" />
<file src="agents/net7.0/nunit.engine.core.dll" target="tools/agents/net7.0" />
<file src="agents/net7.0/nunit.engine.core.pdb" target="tools/agents/net7.0" />
<file src="agents/net7.0/testcentric.engine.metadata.dll" target="tools/agents/net7.0" />
<file src="../../nuget/engine/nunit.agent.addins" target="tools/agents/net7.0"/>

<file src="net20/nunit3-console.exe" target="tools" />
<file src="net20/nunit3-console.pdb" target="tools" />
<file src="net20/nunit3-console.exe.config" target="tools" />
Expand Down
5 changes: 3 additions & 2 deletions src/NUnitConsole/nunit3-console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ public static int Main(string[] args)
if (Options.WorkDirectory != null)
engine.WorkDirectory = Options.WorkDirectory;

if (Options.InternalTraceLevel != null)
engine.InternalTraceLevel = (InternalTraceLevel)Enum.Parse(typeof(InternalTraceLevel), Options.InternalTraceLevel);
engine.InternalTraceLevel = Options.InternalTraceLevel != null
? (InternalTraceLevel)Enum.Parse(typeof(InternalTraceLevel), Options.InternalTraceLevel)
: InternalTraceLevel.Off;

try
{
Expand Down
2 changes: 1 addition & 1 deletion src/NUnitEngine/mock-assembly/mock-assembly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<RootNamespace>NUnit.Tests</RootNamespace>
<TargetFrameworks>net35;net40;netcoreapp2.1;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net35;net40;netcoreapp2.1;netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\nunit.snk</AssemblyOriginatorKeyFile>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
Expand Down
9 changes: 7 additions & 2 deletions src/NUnitEngine/nunit-agent/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public static void Main(string[] args)
}

var logName = $"nunit-agent_{pid}.log";
InternalTrace.Initialize(Path.Combine(workDirectory, logName), traceLevel);
log = InternalTrace.GetLogger(typeof(NUnitTestAgent));

log.Info("Agent process {0} starting", pid);
Expand All @@ -71,7 +70,13 @@ public static void Main(string[] args)

LocateAgencyProcess(agencyPid);

#if NETCOREAPP3_1
#if NET7_0
log.Info($"Running .NET 7.0 agent under {RuntimeInformation.FrameworkDescription}");
#elif NET6_0
log.Info($"Running .NET 6.0 agent under {RuntimeInformation.FrameworkDescription}");
#elif NET5_0
log.Info($"Running .NET 5.0 agent under {RuntimeInformation.FrameworkDescription}");
#elif NETCOREAPP3_1
log.Info($"Running .NET Core 3.1 agent under {RuntimeInformation.FrameworkDescription}");
#elif NET40
log.Info($"Running .NET 4.0 agent under {RuntimeFramework.CurrentFramework.DisplayName}");
Expand Down
2 changes: 1 addition & 1 deletion src/NUnitEngine/nunit-agent/nunit-agent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<RootNamespace>nunit.agent</RootNamespace>
<TargetFrameworks>net20;net40;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net20;net40;netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>..\..\..\nunit.ico</ApplicationIcon>
<GenerateSupportedRuntime>false</GenerateSupportedRuntime>
Expand Down
2 changes: 2 additions & 0 deletions src/NUnitEngine/nunit.engine.core/RuntimeFramework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ private Version GetClrVersionForFramework(Version frameworkVersion)
return new Version(5, 0, 1);
case 6:
return new Version(6, 0, 0);
case 7:
return new Version(7, 0, 0);
}
break;
}
Expand Down
15 changes: 6 additions & 9 deletions src/NUnitEngine/nunit.engine/Services/AgentProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public AgentProcess(TestAgency agency, TestPackage package, Guid agentId)
StartInfo.FileName = RuntimeFramework.MonoExePath;
string monoOptions = "--runtime=v" + TargetRuntime.ClrVersion.ToString(3);
monoOptions += " --debug";
StartInfo.Arguments = string.Format("{0} \"{1}\" {2}", monoOptions, AgentExePath, AgentArgs);
StartInfo.Arguments = $"{monoOptions} \"{AgentExePath}\" {AgentArgs}";
}
else if (TargetRuntime.Runtime == RuntimeType.Net)
{
Expand All @@ -64,7 +64,7 @@ public AgentProcess(TestAgency agency, TestPackage package, Guid agentId)
else if (TargetRuntime.Runtime == RuntimeType.NetCore)
{
StartInfo.FileName = "dotnet";
StartInfo.Arguments = $"{AgentExePath} {AgentArgs}";
StartInfo.Arguments = $"\"{AgentExePath}\" {AgentArgs}";
StartInfo.LoadUserProfile = loadUserProfile;

// TODO: Remove the windows limitation and the use of a hard-coded path.
Expand Down Expand Up @@ -116,27 +116,24 @@ public static string GetTestAgentExePath(RuntimeFramework targetRuntime, bool re

string runtimeDir;
string agentName;
string agentExtension;
int major = targetRuntime.FrameworkVersion.Major;
switch (targetRuntime.Runtime)
{
case RuntimeType.Net:
case RuntimeType.Mono:
runtimeDir = major >= 4 ? "net40" : "net20";
agentName = requires32Bit ? "nunit-agent-x86" : "nunit-agent";
agentExtension = ".exe";
agentName = requires32Bit ? "nunit-agent-x86.exe" : "nunit-agent.exe";
break;
case RuntimeType.NetCore:
runtimeDir = major >= 6 ? "net6.0" : major == 5 ? "net5.0" : "netcoreapp3.1";
agentName = "nunit-agent";
agentExtension = ".dll";
runtimeDir = major >= 7 ? "net7.0" : major == 6 ? "net6.0" : major == 5 ? "net5.0" : "netcoreapp3.1";
agentName = "nunit-agent.dll";
break;
default:
log.Error($"Unknown runtime type: {targetRuntime.Runtime}");
return null;
}

return Path.Combine(Path.Combine(agentsDir, runtimeDir), agentName + agentExtension);
return Path.Combine(Path.Combine(agentsDir, runtimeDir), agentName);
}
}
}
Expand Down