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

Notification

Icon
Error

Implicit Project Dependencies
spolonski
#1 Posted : Monday, July 29, 2024 12:37:11 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 7/11/2016(UTC)
Posts: 32
Location: Germany

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

If I set in the Ncrunch settings that the project should use Implicit Project Dependencies, an error occurs during the build.
Code:

System.InvalidCastException: Unable to cast object of type 'nCrunch.Client.Settings.ImplicitProjectDependencies' to type 'nCrunch.Client.Settings.CopiedProjectDependencies'.
   at nCrunch.Client.ComponentLoader.SnapshotComponentLoader.()
   at nCrunch.Client.ComponentLoader.SnapshotComponentLoader.(EffectiveProcessorArchitecture , String )
   at nCrunch.Client.ComponentLoader.SnapshotComponentLoader.CreateComponentFromXml(FilePath projectFilePath, ParsedBuildXml projectXml, FilePath solutionFilePath, String[] additionalFilesToIncludeAtSolutionLevel, Boolean isLoadedFromFile, IDEVersion ideVersion, BuildEngineId buildEngineId, ComponentUniqueName componentName, TaskSettings componentTaskSettings, Exception parseException, String targetFrameworkForMsbuild, String visibleTargetFramework)

NCrunch Version 5.9.0.1
Remco
#2 Posted : Monday, July 29, 2024 1:25:30 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)
Thanks for sharing this issue. Could you copy/paste the .v3.ncrunchproject file containing this configuration? I can't seem to recreate this with a code sample when I build this setting in the UI.
spolonski
#3 Posted : Monday, July 29, 2024 1:31:57 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 7/11/2016(UTC)
Posts: 32
Location: Germany

Thanks: 6 times
Was thanked: 4 time(s) in 4 post(s)
Sure. Here is it.

Code:
<ProjectConfiguration>
  <Settings>
    <ImplicitProjectDependencyPathsRelativeToSolutionDirectory>
      <Value>MyIdClient\MyIdClient.csproj</Value>
    </ImplicitProjectDependencyPathsRelativeToSolutionDirectory>
  </Settings>
</ProjectConfiguration>



TestProject is a full framework and a MyIdClient is a core project.
Remco
#4 Posted : Monday, July 29, 2024 11:10:33 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)
Oddly this seems to be ok on my end.

Is there any chance you can whittle this down to a sample solution you can share with me? You can submit small code samples in ZIP form through the NCrunch contact form.
spolonski
#5 Posted : Wednesday, July 31, 2024 7:10:26 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 7/11/2016(UTC)
Posts: 32
Location: Germany

Thanks: 6 times
Was thanked: 4 time(s) in 4 post(s)
I was trying to submit a demo today, but I got an error every time after I clicked on the submit button. I am not sure if a file was sent or not.

The behavior in a small demo is slightly different. I don't get an exception during the NCrunch build anymore, but the test case is not discovered anymore.

When I remove the "Implicit Project Dependencies" setting from a test project, the test is discovered correctly.
spolonski
#6 Posted : Wednesday, July 31, 2024 7:31:51 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 7/11/2016(UTC)
Posts: 32
Location: Germany

Thanks: 6 times
Was thanked: 4 time(s) in 4 post(s)
Remco
#7 Posted : Friday, August 2, 2024 11:15:04 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)
I apologise for the time it's taken me to get back to you on this. I've reproduced the issue as you've described it and we're working to get a fixed build for you. Unfortunately in this case the problem needs to be fixed in NCrunch itself (there is no direct workaround), so a new build is necessary.
Remco
#8 Posted : Tuesday, August 6, 2024 1:02:13 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)
spolonski
#9 Posted : Tuesday, August 6, 2024 7:52:53 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 7/11/2016(UTC)
Posts: 32
Location: Germany

Thanks: 6 times
Was thanked: 4 time(s) in 4 post(s)
Thanks. Test discovery works as expected, but I have the next problem with a test case. I can't run an exe from a "ImplcitlyReferencedAssemlyLocation".
I am getting an exception:

Code:

C:\Users\spolonski\AppData\Local\NCrunch\3268\5\XXXIdClient\bin\x86\Debug\net8.0-windows\XXXIdClient.exe

Error: Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'nCrunch.TestRuntime.DotNetCore, Version=5.10.0.2, Culture=neutral, PublicKeyToken=01d101bf6f3e0aea'. The system cannot find the file specified.
File name: 'nCrunch.TestRuntime.DotNetCore, Version=5.10.0.2, Culture=neutral, PublicKeyToken=01d101bf6f3e0aea'
   at XXXId.Client.App..ctor()
   at XXXId.Client.App.Main()


Hmm. I don't referencing a nCrunch.TestRuntime.DotNetCore in XXXIdClient project.

Is it possible to start an exe from a Ncrunch Test Case?
Remco
#10 Posted : Tuesday, August 6, 2024 9:23:19 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)
Yes, this is possible. But it can be somewhat painful to get set up with.

The first complication is, as you've discovered, assemblies instrumented by NCrunch have a reference to nCrunch.TestRuntime. You'll need to copy this assembly programmatically into the same directory as the .EXE so that it can find them at run time. I would suggest running through the assemblies loaded into the test's application domain and finding the assembly path from there, since it needs to be loaded for the NCrunch test domain to function.

The second complication is that the EXE is likely to be alone in its NCrunch workspace without its dependencies adjacent to it. There are two ways you can handle this, either by copying the dependencies into the same directory (using implicit dependencies, the methods in NCrunch.Framework.NCrunchEnvironment, or running through the application domain in your test environment) .. or you can just turn on the copy referenced assemblies to workspace setting for the .EXE so that its dependencies are present.

A third complication is that managing the lifetime of the EXE can be tricky, especially if the test doesn't tear down properly .. as this can leave an orphaned EXE hanging around. There are ways to solve this problem. The best approach usually depends on how you're using the process.

The good news is that both code coverage tracking and RDI should work for the EXE's process, which is VERY powerful for tracking problems and understanding code. We use this approach ourselves in NCrunch's tests (many of which are multiprocess in the same way as yours). It saves us a lot of time.
Users browsing this topic
Guest
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.118 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download