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

Notification

Icon
Error

NCrunch failing to build projects that are buildable in VS
AdNecrias
#1 Posted : Wednesday, August 7, 2024 11:57:54 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/7/2024(UTC)
Posts: 3
Location: Portugal

Hello,

I've installed the trial and am trying to give NCrunch a spin but it's failing to build a few projects in my solution.

I can't just post everything here, but the projects it is failing do so in result of missing references, specifically to UnityEngine. On VS I can build and run tests using these classLibraries as expected.
Here's a simple example of the Trace Output:
Quote:
NCrunch: If you are experiencing problems in getting this project to build, have a look at https://www.ncrunch.net/...ng_project-build-issues
ApiCompatibility.cs (1, 12): The type or namespace name 'UnityEngine' could not be found (are you missing a using directive or an assembly reference?)


WARNING - CallbackDispatcher.cs (304, 65): CS8625: Cannot convert null literal to non-nullable reference type.
WARNING - CallbackDispatcher.cs (308, 48): CS8625: Cannot convert null literal to non-nullable reference type.
WARNING - CallbackDispatcher.cs (328, 71): CS8625: Cannot convert null literal to non-nullable reference type.
WARNING - autogen\isteamgameserverugc.cs (35, 202): CS8625: Cannot convert null literal to non-nullable reference type.
WARNING - autogen\isteamugc.cs (36, 202): CS8625: Cannot convert null literal to non-nullable reference type.


I checked out the workspace built for these projects and noticed inconsistencies (not same project as above, but same references errors).
In my workspace:
Quote:

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Unity3D" Version="2.1.3" />
</ItemGroup>

<ItemGroup>
<Reference Remove="$(UnityEnginePath)" />
<Reference Include="$(UnityEngineUIPath)" Private="true"/>
<Reference Include="$(UnityModulesPath)\UnityEngine.CoreModule.dll" Private="true" />
<Reference Include="$(UnityModulesPath)\UnityEngine.Physics2DModule.dll" Private="true" />
<Reference Include="$(UnityModulesPath)\UnityEngine.UIModule.dll" Private="true" />
</ItemGroup>

</Project>


In NCrunch workspace:
Quote:

<Project DefaultTargets="Build;NCrunchOutputDataQuery" Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Unity3D" Version="2.1.3" />
</ItemGroup>
<ItemGroup>
<Reference Remove="$(UnityEnginePath)" />
<Reference Include="C:\Users\Adnecrias\AppData\Local\NCrunch\27788\11\_ncrunchreferences\UnityEngine.UI.dll">
<Private>true</Private>
</Reference>
</ItemGroup>
<Target Name="NCrunchOutputDataQuery" DependsOnTargets="">
<Message Text="#Expression_71bbb746da1f4c6fac5eb93c02efeb9e=$(OutDir)$(TargetName)$(TargetExt)" />
<Message Text="#Expression_d23a1c22f7884b6c988a7bb40a765c6b=$(Configuration)" />
<Message Text="#Expression_77d801ba68af488699837495e4c2ee13=$(TargetName)" />
<Message Text="#$TargetFrameworkDirectory=;$(TargetFrameworkDirectory)" />
<Message Text="#ReferencePath=;@(ReferencePath)" />
<Message Text="#ReferenceCopyLocalPaths=;@(ReferenceCopyLocalPaths)" />
<Message Text="#TargetPathWithTargetPlatformMoniker=;@(TargetPathWithTargetPlatformMoniker)" />
<Message Text="#CopiedFiles_SourceItemsToCopyToOutputDirectoryAlways=@(_SourceItemsToCopyToOutputDirectoryAlways)|@(_SourceItemsToCopyToOutputDirectoryAlways->'$(OutDir)%(TargetPath)')" Condition="'@(_SourceItemsToCopyToOutputDirectoryAlways->'$(OutDir)%(TargetPath)')'!=''" />
<Message Text="#CopiedFiles_SourceItemsToCopyToOutputDirectory=@(_SourceItemsToCopyToOutputDirectory)|@(_SourceItemsToCopyToOutputDirectory->'$(OutDir)%(TargetPath)')" Condition="'@(_SourceItemsToCopyToOutputDirectory->'$(OutDir)%(TargetPath)')'!=''" />
<Message Text="#CopiedFilesAllItemsFullPathWithTargetPath=@(AllItemsFullPathWithTargetPath)|@(AllItemsFullPathWithTargetPath->'$(OutDir)%(TargetPath)')" Condition="'@(AllItemsFullPathWithTargetPath->'$(OutDir)%(TargetPath)')'!=''" />
</Target>
<PropertyGroup>
<ProjectAssetsFile>C:\Users\Adnecrias\AppData\Local\NCrunch\27788\11\Vectrosity\obj\project.assets.json</ProjectAssetsFile>
</PropertyGroup>
</Project>


Why are the other references not showing up? Is it because they are private? The one to UnityEngine.UI.dll is at it has shown up.
Remco
#2 Posted : Wednesday, August 7, 2024 12:23:30 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for sharing this issue.

I think the issue may be related to the build property being used to specify the reference's file path. If you replace this with the full path to the file, does the problem go away?
AdNecrias
#3 Posted : Wednesday, August 7, 2024 4:09:14 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/7/2024(UTC)
Posts: 3
Location: Portugal

Thanks for the quick response, got distracted by another thing and couldn't quickly reply.

I've changed the paths to be absolute, still same problem, the last three are being ignored.

My csproj:
Quote:

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Unity3D" Version="2.1.3" />
</ItemGroup>

<ItemGroup>
<Reference Remove="$(UnityEnginePath)" />
<Reference Include="C:\REPOS\Code\Unity\Library\ScriptAssemblies\UnityEngine.UI.dll" Private="true"/>
<Reference Include="C:\Program Files\2022.3.20f1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll" Private="true" />
<Reference Include="C:\Program Files\2022.3.20f1\Editor\Data\Managed\UnityEngine\UnityEngine.Physics2DModule.dll" Private="true" />
<Reference Include="C:\Program Files\2022.3.20f1\Editor\Data\Managed\UnityEngine\UnityEngine.UIModule.dll" Private="true" />
</ItemGroup>

</Project>


NCrunch's csproj:
Quote:

<Project DefaultTargets="Build;NCrunchOutputDataQuery" Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Unity3D" Version="2.1.3" />
</ItemGroup>
<ItemGroup>
<Reference Remove="$(UnityEnginePath)" />
<Reference Include="C:\Users\Adnecrias\AppData\Local\NCrunch\35008\10\_ncrunchreferences\UnityEngine.UI.dll">
<Private>true</Private>
</Reference>
</ItemGroup>
<Target Name="NCrunchOutputDataQuery" DependsOnTargets="">
<Message Text="#Expression_a0a35528a4be4d7eb69e30fc99ed7907=$(OutDir)$(TargetName)$(TargetExt)" />
<Message Text="#Expression_8b076ffb219d4546a8bf99d81df587c4=$(Configuration)" />
<Message Text="#Expression_eccec8e2b5634d2a99f6e902d4dff307=$(TargetName)" />
<Message Text="#$TargetFrameworkDirectory=;$(TargetFrameworkDirectory)" />
<Message Text="#ReferencePath=;@(ReferencePath)" />
<Message Text="#ReferenceCopyLocalPaths=;@(ReferenceCopyLocalPaths)" />
<Message Text="#TargetPathWithTargetPlatformMoniker=;@(TargetPathWithTargetPlatformMoniker)" />
<Message Text="#CopiedFiles_SourceItemsToCopyToOutputDirectoryAlways=@(_SourceItemsToCopyToOutputDirectoryAlways)|@(_SourceItemsToCopyToOutputDirectoryAlways->'$(OutDir)%(TargetPath)')" Condition="'@(_SourceItemsToCopyToOutputDirectoryAlways->'$(OutDir)%(TargetPath)')'!=''" />
<Message Text="#CopiedFiles_SourceItemsToCopyToOutputDirectory=@(_SourceItemsToCopyToOutputDirectory)|@(_SourceItemsToCopyToOutputDirectory->'$(OutDir)%(TargetPath)')" Condition="'@(_SourceItemsToCopyToOutputDirectory->'$(OutDir)%(TargetPath)')'!=''" />
<Message Text="#CopiedFilesAllItemsFullPathWithTargetPath=@(AllItemsFullPathWithTargetPath)|@(AllItemsFullPathWithTargetPath->'$(OutDir)%(TargetPath)')" Condition="'@(AllItemsFullPathWithTargetPath->'$(OutDir)%(TargetPath)')'!=''" />
</Target>
<PropertyGroup>
<ProjectAssetsFile>C:\Users\Adnecrias\AppData\Local\NCrunch\35008\10\Vectrosity\obj\project.assets.json</ProjectAssetsFile>
</PropertyGroup>
</Project>


EDIT: I might add, this is an issue specific to my setup... Two other people have the same solution and there NCrucnh works out of the box.
Remco
#4 Posted : Wednesday, August 7, 2024 11:04:00 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Is there any change you could submit a bug report right after NCrunch has loaded the project? Somehow these dependencies are getting excluded .. the log in the report might reveal some more detail on this.
AdNecrias
#5 Posted : Thursday, August 8, 2024 9:14:32 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/7/2024(UTC)
Posts: 3
Location: Portugal

I've submitted the bug report.
Remco
#6 Posted : Thursday, August 8, 2024 10:49:27 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks for sending through the bug report.

Interestingly, MSBuild isn't resolving these files at all. When NCrunch loads the project, MSBuild reports all the source files, and it also reports UnityEngine.CoreModule.dll, but none of the other unity files.

I wonder if it might be dropping the DLLs due to a lack of source references to them. MSBuild does have optimisations like this that don't normally cause problems, but if Unity has a custom build step somewhere generating code that makes use of the DLLs later in the build system, this could cause us a problem.

Something worth trying is to introduce a reference from your source code to at least one of the Unity types in these DLLs. In this way, MSBuild won't have a reason to exclude them from the list of reported dependencies. It could just be a static reference to a typeof or something that isn't executed but still need to be compiled.

I should probably add that we haven't done any work or testing to support Unity under NCrunch. I'm aware they do a few odd things when compared with standard .NET projects, and sometimes they give us trouble.
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.089 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download