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

Added net core support #75

Merged
merged 6 commits into from
Nov 23, 2020
Merged

Conversation

oldmine
Copy link
Contributor

@oldmine oldmine commented Oct 6, 2020

In NUnit Console Runner 3.12 added net core support, but old extensions is not compatible, because they build for net framework.
Extension was updated to work with new version of console runner on net core.

Changes:

  • Updated csproj to new format
  • Added netstandard build target
  • Updated nuget references format
  • Updated nuget packages to netstandard support

@oldmine oldmine force-pushed the dev/netCoreSupport branch from b55b544 to 578cb89 Compare October 6, 2020 16:46
@oldmine
Copy link
Contributor Author

oldmine commented Nov 19, 2020

Please, can someone review pull request?
@NikolayPianikov @CharliePoole

@NikolayPianikov
Copy link
Member

@oldmine a build fails for a cloned repo. I suppose you should add .WithRestore() for _MSBuildSettings _ in _build.cake _. Also I asked about net20 previously. I suppose nuget packages will contain net3.5 version only. Is it expected result?

@oldmine
Copy link
Contributor Author

oldmine commented Nov 20, 2020

@NikolayPianikov Thanks for answer. Build was fail on your local machine or CI? Tests and checks passed successful.

About targeting netstandard:
For new version of Console Runner extension packages should target netstandard2.0 to be compatible and works on net framework and net core. If extension was build for net framework and run net core runner, extension will be not found and not worked.

Example that extension that build for netstandrad was work with NUnit.ConsoleRunner 3.10 on netframework
image_2020-11-20_18-39-19

Example that extension that build for netstandrad was work with NUnit.ConsoleRunner 3.12-beta1 on netcore3.1
image_2020-11-20_18-40-45

@NikolayPianikov
Copy link
Member

Yes, I cloned the repo from your fork and started the build from scratch. Build doesn't work locally.

Is it worth packing 2 versions of an extension into the nuget package in different directories? like:

  • tools/net20
  • tools/netstandard2.0

@CharliePoole
Copy link
Member

@NikolayPianikov Putting versions in directories like that seems right to me. It's true that the current console runner is in two versions and each one could use a different package, but I'm pretty sure that's not the way it will always be for nunit-console.

And other runners are free to work differently - running under one platform but supporting other platforms for execution out of process. That's how my own runner works. So using a runner like that, you would probably prefer to install a single package that included all supported targets.

@ChrisMaddock
Copy link
Member

Multiple platforms in a single NuGet package was the original design intention. 😄 I think an additional .addins text file is also needed in \tools\ to make it work too - although someone was recently saying they'd not needed that. It's been a good few years since we implemented this functionality in the engine - so my memory may well be wrong!

See this post for more of an explanation on the structure the engine is expecting --> nunit/nunit-console#806 (comment)

@NikolayPianikov NikolayPianikov merged commit d6bf628 into nunit:master Nov 23, 2020
@NikolayPianikov
Copy link
Member

NikolayPianikov commented Nov 24, 2020

I've created a nuget package containing:

  • tools/net20/teamcity-event-listener.dll
  • tools/netstandard2.0/teamcity-event-listener.dll
  • tools/.addins

.addins is a file:

netstandard2.0/
net20/

and found several issues:

  • nunit fails when tries to load the TeamCity extension for inappropriate .net because of the predefined sequence in the file .addins
NUnit.ConsoleRunner.3.12.0-beta1\tools\nunit3-console.exe --list-extensions
NUnit Console Runner 3.12.0-beta1 (.NET 2.0 Debug)
Copyright (c) 2020 Charlie Poole, Rob Prouse
Tuesday, 24 November, 2020 14:32:19

Runtime Environment
   OS Version: Microsoft Windows NT 6.2.9200.0
   Runtime: .NET Framework CLR v4.0.30319.42000

Installed Extensions
  Extension Point: /NUnit/Engine/NUnitV2Driver
  Extension Point: /NUnit/Engine/TypeExtensions/IService
  Extension Point: /NUnit/Engine/TypeExtensions/ITestEventListener
    Extension: NUnit.Engine.Listeners.TeamCityEventListener(.NET 4.0)
      Version: 1.0.8.0
      Path: C:\Projects\NUnit\aa\nunit\NUnit.Extension.TeamCityEventListener.1.0.8\tools\netstandard2.0\teamcity-event-listener.dll
  Extension Point: /NUnit/Engine/TypeExtensions/IDriverFactory
  Extension Point: /NUnit/Engine/TypeExtensions/IProjectLoader
  Extension Point: /NUnit/Engine/TypeExtensions/IResultWriter
  • NUnit.ConsoleRunner.3.12.0-beta1\tools\nunit3-console.exe fails with error Could not load file or assembly 'nunit.engine.api, Version=3.0.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb' or one of its dependencies. The system cannot find the file specified. when tools/net20 does not containt nunit.engine.api.dll with appropritae version.
  • NUnit.ConsoleRunner.3.12.0-beta1\tools\nunit3-console.exe fails with error
System.InvalidCastException : Unable to cast object of type 'NUnit.Engine.Listeners.TeamCityEventListener' to type 'NUnit.Engine.ITestEventListener'.

--InvalidCastException
Unable to cast object of type 'NUnit.Engine.Listeners.TeamCityEventListener' to type 'NUnit.Engine.ITestEventListener'.
   at NUnit.Engine.Services.ExtensionService.<GetExtensions>d__24`1.MoveNext()
   at NUnit.Engine.Runners.MasterTestRunner.RunTests(ITestEventListener listener, TestFilter filter)
   at NUnit.Engine.Runners.MasterTestRunner.Run(ITestEventListener listener, TestFilter filter)
   at NUnit.ConsoleRunner.ConsoleRunner.RunTests(TestPackage package, TestFilter filter) in C:\Projects\NUnit\nunit-console\src\NUnitConsole\nunit3-console\ConsoleRunner.cs:line 218
   at NUnit.ConsoleRunner.ConsoleRunner.Execute() in C:\Projects\NUnit\nunit-console\src\NUnitConsole\nunit3-console\ConsoleRunner.cs:line 120
   at NUnit.ConsoleRunner.Program.Main(String[] args) in C:\Projects\NUnit\nunit-console\src\NUnitConsole\nunit3-console\Program.cs:line 135

when tools/net20 contains nunit.engine.api.dll with version 3.11.1 from the nuget package

<PackageReference Include="NUnit.Engine.Api" Version="3.11.1" PrivateAssets="all" />

@NikolayPianikov
Copy link
Member

@ChrisMaddock could you suggest what I am doing wrong

@ChrisMaddock
Copy link
Member

Hi @NikolayPianikov,

Your package structure looks as I'd expect.


Lastly, point one is interesting. I think the behaviour here isn't exactly what we intended, but roughly correct.

I suspect you're running the Console on .NET 4.6.2 or later? The intended behaviour is that the engine discovers all valid extensions, and works out from those which ones have target frameworks it is able to load. The engine should then pick the extension for the "highest possible target framework" - so in this case, .NET Standard 2.0 over .NET 2.0. If your extension was to target .NET Core instead of .NET Standard, then the .NET Framework Console would ignore it and select the net20 version instead.

I think there's actually a bug in the code that the engine is only working out which extension is "best" by comparing the two version numbers (e.g. 2.0 vs 2.0) - but the end result is as intended. I presume it also doesn't matter which version is selected for the TC extension - are the two versions functionally identical?

@k15tfu
Copy link

k15tfu commented Dec 6, 2020

@NikolayPianikov Hi! When will the new package be available?

@NikolayPianikov
Copy link
Member

@ChrisMaddock yes versions are identical. I confirm that NUnit.ConsoleRunner.3.12.0-dev-04961 on myget works fine.

@NikolayPianikov
Copy link
Member

@ChrisMaddock when you are planning to release In NUnit Console Runner 3.12?

@NikolayPianikov
Copy link
Member

@k15tfu I suppose few days

@ChrisMaddock
Copy link
Member

Thanks @NikolayPianikov. Console 3.12 will probably be in the new year now, my time up until the end of the year will be limited now. Would recommend using the MyGet build of the console, for anyone who wants to start using this straight away. 🙂

@NikolayPianikov
Copy link
Member

I've published the TeamCity extension 1.0.8 containing netstandard2.0.
It works with release versions and with a MyGet build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants