Build/Test Issues

Using generic ActionResult from aspnet core 3.0.0.0 results in build failure

Started by debgz on 2,724 views

I am currently building an aspnet core 3.0 web api with a core 3.0 test project.
In my controller Method I use the generic version of ActionResult as return value.
If I now try to write a test containing this particular class, ncrunch tells me the following:


CSC (0, 0): Assembly "RecipeBuilderApplicationApi" mit Identität "RecipeBuilderApplicationApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" verwendet "Microsoft.AspNetCore.Mvc.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" mit einer höheren Version als die referenzierte Assembly "Microsoft.AspNetCore.Mvc.Core" mit Identität "Microsoft.AspNetCore.Mvc.Core, Version=1.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60".
Controller\ToolControllerTest.cs (34, 13): Typ "ActionResult" ist nicht generisch und kann daher nicht mit Typargumenten verwendet werden.
Controller\ToolControllerTest.cs (34, 64): Assembly "RecipeBuilderApplicationApi" mit Identität "RecipeBuilderApplicationApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" verwendet "Microsoft.AspNetCore.Mvc.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" mit einer höheren Version als die referenzierte Assembly "Microsoft.AspNetCore.Mvc.Core" mit Identität "Microsoft.AspNetCore.Mvc.Core, Version=1.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60".


Seems like ncrunch is using version 1.0.3.0 from Mvc.Core whilst I use version 3.0.0.0 therefore not finding the generic version of ActionResult.
Ncrunch however seems fine when building the webapi project. It just refuses to build the test project.

Controller:

public async Task<ActionResult<IList<ToolDto>>> GetRelevantTools() {


Test:

ActionResult<IList<ToolDto>> relevantTools = await toolController.GetRelevantTools();


What do I need to do to tell ncrunch to use version 3.0.0.0 in the test project?

----------------------

Just created a small webApi/Nunit test project from default vs2019 templates and I am not able to get ncrunch to build the test project:


NCrunch: If you are experiencing problems in getting this project to build, have a look at http://www.ncrunch.net/documentation/troubleshooting_project-build-issues
UnitTest1.cs (2, 17): Der Typ- oder Namespacename "AspNetCore" ist im Namespace "Microsoft" nicht vorhanden. (Möglicherweise fehlt ein Assemblyverweis.)
UnitTest1.cs (3, 28): Der Typ- oder Namespacename "Logging" ist im Namespace "Microsoft.Extensions" nicht vorhanden. (Möglicherweise fehlt ein Assemblyverweis.)


It tells type or namespace AspNetCore and Logging is missing. Strange thing is that it runs just fine in Resharper testrunner.
Same applies for the main problem. It runs just fine within resharper.

Edited

Thanks for posting!

Could you please confirm which version of NCrunch you are using?
I think its NCrunch 4.1 but will double check on monday.
Using it in VS2019 on Win10 (nearly latest).

But maybe I am just using 4.0 and this one gets me: "Fixed an issue that would cause an exception when trying to process a generic class containing an async
method under optimised mode."
Thanks for sharing these extra details. We haven't knowingly fixed this issue in v4.1 (the generic class exception was something else).

Is there any chance you could ZIP up your sample project that reproduces the problem and send it through the NCrunch contact form? We can then take a look and try to figure this out.
Just checked the version and yes, its 4.1.0.1 Send a sample project through the contact form.
The sample was generated using stock vs2019 webapi template and stock nunit test project template.
It does not matter which intrumentation mode I use nor if I set "Copy referenced ..." to true on the test project.

I get the following errors on the test project:


NCrunch: If you are experiencing problems in getting this project to build, have a look at http://www.ncrunch.net/documentation/troubleshooting_project-build-issues
UnitTest1.cs (2, 17): Der Typ- oder Namespacename "AspNetCore" ist im Namespace "Microsoft" nicht vorhanden. (Möglicherweise fehlt ein Assemblyverweis.)
UnitTest1.cs (3, 28): Der Typ- oder Namespacename "Logging" ist im Namespace "Microsoft.Extensions" nicht vorhanden. (Möglicherweise fehlt ein Assemblyverweis.)


The main project seems to build just fine.

Edited

Thanks! We're looking at this now and will get back to you soon.
Could you try the build below and confirm if it solves the problem for you?

NCrunch_Console_4.2.0.4.msi
NCrunch_Console_4.2.0.4.zip
NCrunch_GridNodeServer_4.2.0.4.msi
NCrunch_GridNodeServer_4.2.0.4.zip
NCrunch_LicenseServer_4.2.0.4.zip
NCrunch_VS2008_4.2.0.4.msi
NCrunch_VS2010_4.2.0.4.msi
NCrunch_VS2010_4.2.0.4.zip
NCrunch_VS2012_4.2.0.4.msi
NCrunch_VS2012_4.2.0.4.zip
NCrunch_VS2013_4.2.0.4.msi
NCrunch_VS2013_4.2.0.4.zip
NCrunch_VS2015_4.2.0.4.msi
NCrunch_VS2015_4.2.0.4.msi.7z
NCrunch_VS2015_4.2.0.4.zip
NCrunch_VS2017_4.2.0.4.msi
NCrunch_VS2017_4.2.0.4.msi.7z
NCrunch_VS2017_4.2.0.4.zip
NCrunch_VS2019_4.2.0.4.msi
NCrunch_VS2019_4.2.0.4.msi.7z
NCrunch_VS2019_4.2.0.4.zip
Ohhh yes. Fixed. Thank you!

Post a reply

Log in to reply.