Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

3 Pages<123>
Tests utilising Microsoft.AspNet.TestHost fail in NCrunch
alastairs
#21 Posted : Monday, May 29, 2017 11:05:11 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/13/2011(UTC)
Posts: 54
Location: Cambridge, UK

Thanks: 22 times
Was thanked: 4 time(s) in 4 post(s)
Ok, thanks Remco. I tried doing the step-by-step conversion this morning, and the repro project just kept working :) All of the test projects are targeting netcoreapp1.1. Looking at the simpler of the two real-world solutions, I see that the Web project is indeed present in the workspace directory for one of the failing tests. I also found an ncruncherror file, which contained the following text:
Code:
System.Exception: Could not resolve assembly: System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089


I'm still waiting to hear back whether I can send through any of our code for you; a possible alternative could be a remote-debugging call via Skype or something?
ghelyar
#22 Posted : Tuesday, May 30, 2017 8:56:34 AM(UTC)
Rank: Member

Groups: Registered
Joined: 12/19/2016(UTC)
Posts: 15
Location: United Kingdom

Thanks: 4 times
Was thanked: 2 time(s) in 2 post(s)
This was working fine for me on ncrunch 3.6 with an asp.net core (.net framework) project and a .net framework class library unit test project running nunit.

Since upgrading to 3.8 it still works but I get the "The Microsoft.AspNetCore.TestHost package contains code that extracts dependency data from the .deps files of user projects in its environment. ..." warning.

I'm also suddenly getting the "NCrunch detected unusual behaviour around the resolution of referenced assemblies required by this project in its test environment. This can often be caused by usage of the 'Copy Referenced Assemblies To Workspace' setting, ..." warning, without having changed anything.

If this only affects .net core and not .net framework, although I'm not sure whether it does, can this behaviour/warning be disabled for .net framework?
Remco
#23 Posted : Wednesday, May 31, 2017 1:51:38 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,123

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
Thanks Alastair for your help in diagnosing this issue. When .NET Core generates these .deps files, it uses the name of the output assembly (dll) for each project, where it looks like NCrunch is using the project name (oops). Because your solution has projects with a different output assembly name to the project name, the .deps handling fails to work correctly. Changing the names of your projects to match the assembly names should get this working for you on v3.8 (if this is an option). I hope I should have a proper fix available for you on this later this week.

@ghelyar: Sorry, just to confirm your situation, are you using the Microsoft.AspNetCore.TestHost package under classic .NET and not .NET Core?
1 user thanked Remco for this useful post.
alastairs on 5/31/2017(UTC)
alastairs
#25 Posted : Wednesday, May 31, 2017 6:32:23 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/13/2011(UTC)
Posts: 54
Location: Cambridge, UK

Thanks: 22 times
Was thanked: 4 time(s) in 4 post(s)
*facepalm* The one thing I didn't even think about! Good detective work, thanks Remco :-)
ghelyar
#24 Posted : Wednesday, May 31, 2017 7:00:21 AM(UTC)
Rank: Member

Groups: Registered
Joined: 12/19/2016(UTC)
Posts: 15
Location: United Kingdom

Thanks: 4 times
Was thanked: 2 time(s) in 2 post(s)
Remco;10487 wrote:
@ghelyar: Sorry, just to confirm your situation, are you using the Microsoft.AspNetCore.TestHost package under classic .NET and not .NET Core?


Yes, the project template in Visual Studio 2017 is "ASP.NET Core Web Application (.NET Framework)" and the unit test project is Class Library (.NET Framework) with NUnit and Microsoft.AspNetCore.TestHost via nuget.

I don't know if .net framework vs .net core is what's making a difference, but I never had any problems with it on ncrunch 3.6, and it still works fine despite the warnings on ncrunch 3.8.

I'm currently copying reference assemblies to output, which then shows a different warning, which I'm hiding, but this obviously has drawbacks if it isn't needed and it means I need to check the .v3.ncrunchproject file into source control, which I try to avoid if I can.
Remco
#26 Posted : Wednesday, May 31, 2017 12:56:55 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,123

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
Ok, it looks like there is a problem with the TestHost support in that it switches itself on for .NET Framework when it probably isn't needed. This will hurt NCrunch's build optimisation. Since you have the 'Copy referenced assemblies to workspace' setting turned on, it shouldn't make any difference in your case .. but it's good to know that this should perhaps be avoided under .NET Framework. I'll take an extra look before I put the fix up. Thanks for making me aware of it.
ghelyar
#27 Posted : Wednesday, May 31, 2017 1:33:50 PM(UTC)
Rank: Member

Groups: Registered
Joined: 12/19/2016(UTC)
Posts: 15
Location: United Kingdom

Thanks: 4 times
Was thanked: 2 time(s) in 2 post(s)
Remco;10490 wrote:
Since you have the 'Copy referenced assemblies to workspace' setting turned on, it shouldn't make any difference in your case ..

I have only turned it on because of the new behaviour/warning introduced in ncrunch 3.8. I did what it told me to do, and when it still gave me a (new) warning, I told it to shut up. Then I checked it in to source control so that other developers don't freak out that a bunch of projects are suddenly throwing warnings out left, right and centre.

Ideally, I would like to turn 'Copy referenced assemblies to workspace' off again.

As long as you're aware of the issue, I'll leave alone for now.

Thanks
Remco
#28 Posted : Wednesday, May 31, 2017 1:49:40 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,123

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
ghelyar;10491 wrote:
Remco;10490 wrote:
Since you have the 'Copy referenced assemblies to workspace' setting turned on, it shouldn't make any difference in your case ..

I have only turned it on because of the new behaviour/warning introduced in ncrunch 3.8. I did what it told me to do, and when it still gave me a (new) warning, I told it to shut up. Then I checked it in to source control so that other developers don't freak out that a bunch of projects are suddenly throwing warnings out left, right and centre.


Understood! Sorry, you definitely want this off then. That will require a codefix. I recommend you stick with v3.7 until I can get you a new build.
Remco
#29 Posted : Thursday, June 1, 2017 6:41:04 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,123

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
2 users thanked Remco for this useful post.
ghelyar on 6/1/2017(UTC), alastairs on 6/2/2017(UTC)
ghelyar
#30 Posted : Thursday, June 1, 2017 7:03:52 AM(UTC)
Rank: Member

Groups: Registered
Joined: 12/19/2016(UTC)
Posts: 15
Location: United Kingdom

Thanks: 4 times
Was thanked: 2 time(s) in 2 post(s)
Thanks. 3.9.0.1 works for me. I was able to remove the CopyReferencedAssembliesToWorkspace setting, CopyReferencedAssembliesToWorkspaceIsOn warning and AspNetTestHostCompatibility warning with the setup I described above (asp.net core (.net framework)) and all tests ran and passed successfully with no warnings in VS2017.
1 user thanked ghelyar for this useful post.
Remco on 6/1/2017(UTC)
alastairs
#32 Posted : Friday, June 2, 2017 10:27:53 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/13/2011(UTC)
Posts: 54
Location: Cambridge, UK

Thanks: 22 times
Was thanked: 4 time(s) in 4 post(s)
Remco, this build works like a charm, thank you so much.
1 user thanked alastairs for this useful post.
Remco on 6/2/2017(UTC)
Remco
#33 Posted : Friday, June 16, 2017 4:06:28 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,123

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
Remco
#34 Posted : Tuesday, July 18, 2017 1:19:42 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,123

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
NCrunch v3.10 has now been released.
Remco
#35 Posted : Wednesday, September 6, 2017 8:50:32 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,123

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
1 user thanked Remco for this useful post.
alastairs on 9/27/2017(UTC)
Tonyh
#36 Posted : Sunday, September 10, 2017 7:25:25 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/10/2017(UTC)
Posts: 5
Location: Australia

Hi,
Glad I found this post after a weekend of frustration.
Using Core 2.0 on VS2017 and NCrunch 3.10.0.20 to try to test Authorisation on a Razor Pages web app.

Using the following to get a path for .UseWebRoot in WebHostBuilder looked promising but still 404s.
string CalculateRelativeContentRootPath() =>
Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, @"WineShow");

Tony
Remco
#37 Posted : Sunday, September 10, 2017 11:25:56 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,123

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
Hi Tony, can you confirm whether the 3.12.0.1 build has solved this problem for you?
Tonyh
#38 Posted : Sunday, September 10, 2017 10:42:54 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/10/2017(UTC)
Posts: 5
Location: Australia

Hi Remco,
I just downloaded and installed 3.11.0.9 - You probably know that does not resolve the issue.
I can wait until you release 3.12 before I run these tests.
I need to get on with the project and can come back to integration tests later.
alastairs
#39 Posted : Wednesday, September 27, 2017 11:15:05 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/13/2011(UTC)
Posts: 54
Location: Cambridge, UK

Thanks: 22 times
Was thanked: 4 time(s) in 4 post(s)
Hi Remco

I upgraded our projects to ASP.NET Core 2.0 yesterday, and have found the TestHost projects are failing again; they run successfully when run against a running instance of the web project. The error now appears to be:
- running NCrunch 3.11.0.9 in VS 2015 15.3.5
- with the same project/library split as in the previous repro
- issuing a request via the created HttpClient instance throws a NullReferenceException on HttpClient.SendAsync(HttpRequestMessage)

Do you still have the repro project from earlier in the year, or should I send you a fresh one?

Many thanks

Alastair
alastairs
#40 Posted : Wednesday, September 27, 2017 11:16:08 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/13/2011(UTC)
Posts: 54
Location: Cambridge, UK

Thanks: 22 times
Was thanked: 4 time(s) in 4 post(s)
Have just seen the update about 3.12.0.1 and am giving that a go.

I can confirm that the 3.12 update resolves the problem! Thanks Remco for being on top of this! :-D
1 user thanked alastairs for this useful post.
Remco on 9/27/2017(UTC)
alastairs
#41 Posted : Wednesday, September 27, 2017 1:41:47 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/13/2011(UTC)
Posts: 54
Location: Cambridge, UK

Thanks: 22 times
Was thanked: 4 time(s) in 4 post(s)
I'm seeing the following error pretty often in NCrunch 3.12:

Code:
NCrunch was unable to parse this project file because of an unexpected error: System.NullReferenceException: Object reference not set to an instance of an object.
   at nCrunch.Common.IO.DirectoryPath.GetNumberOfCommonDirectories(DirectoryPath path1, DirectoryPath path2)
   at nCrunch.Common.IO.DiskPath.DoRebase(DirectoryPath originalBase, DirectoryPath newBase)
   at nCrunch.Common.IO.FilePath.Rebase(DirectoryPath originalBase, DirectoryPath newBase)
   at nCrunch.Compiler.ProjectAssetsJson.WriteToWorkspace(DirectoryPath originalProjectDirOnClient, DirectoryPath workspaceProjectDir)
   at nCrunch.Compiler.RemoteBuildRunner.(ComponentBuildParameters )
   at nCrunch.Compiler.RemoteBuildRunner..()
   at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
   at nCrunch.Compiler.RemoteBuildRunner.(ComponentBuildParameters )


Sometimes hitting the "Resynchronise, Rebuild and Rerun" button fixes it, but not always.
Users browsing this topic
Guest (2)
3 Pages<123>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.131 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download