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

Notification

Icon
Error

Not initializing due to exception
christopher7694
#1 Posted : Monday, April 26, 2021 10:17:45 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/26/2021(UTC)
Posts: 4
Location: United States of America

When attempting to load a project, I get the following output:


Quote:
System.Exception: An exception was thrown in the remote environment: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> nCrunch.Common.UserException: Errors occurred while trying to load the project file:
Assets file 'C:\{...redacted...}\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.
at nCrunch.Compiler.ComponentAnalysisContext.()
at nCrunch.Compiler.ComponentAnalysisContext.AnalyseComponentBuild()
at nCrunch.Compiler.RemoteBuildRunner.AnalyseComponentBuild(ComponentLoadParameters parameters)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at nCrunch.TaskRunner.Ipc.IpcMessageProcessor.(CallMethodMessage )
at nCrunch.TaskRunner.Ipc.IpcMessageProcessor.ProcessMessageReturningResult(Byte[] data)
at nCrunch.TaskRunner.Ipc.RemoteInstance.(Byte[] )
at nCrunch.TaskRunner.Ipc.RemoteInstance.Invoke(IMessage msg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at nCrunch.Compiler.IRemoteBuildRunner.AnalyseComponentBuild(ComponentLoadParameters parameters)
at nCrunch.Core.BuildManagement.BuildProcessLauncher..(IRemoteBuildRunner )
at nCrunch.Core.BuildManagement.BuildProcessLauncher.(Action`1 , FilePath , String , ExternalProcess )
at nCrunch.Core.BuildManagement.BuildProcessLauncher.(Action`1 , EffectiveProcessorArchitecture , GridClientId , BuildSystemParameters , IList`1 , Nullable`1 , GridAddress )
at nCrunch.Core.BuildManagement.BuildProcessLauncher.AnalyseComponentBuildInExternalProcess(ComponentLoadParameters parameters, IList`1 customEnvironmentVariables)
at nCrunch.Client.ComponentLoader.SnapshotComponentLoader.(EffectiveProcessorArchitecture , String )
at nCrunch.Client.ComponentLoader.SnapshotComponentLoader.CreateComponentFromXml(FilePath projectFilePath, ParsedBuildXml projectXml, FilePath solutionFilePath, String[] additionalFilesToIncludeAtSolutionLevel, Boolean isLoadedFromFile, VisualStudioVersion vsVersion, ComponentUniqueName componentName, TaskSettings componentTaskSettings, Exception parseException, String targetFramework)


following the suggestion in the output, I get this:


Quote:
All packages are already installed and there is nothing to restore.
Time Elapsed: 00:00:00.0669642
========== Finished ==========


Still unable to go forward.
Is there enough information here to help diagnose what is going on?
If not, is there anything else I can provide?

Remco
#2 Posted : Tuesday, April 27, 2021 12:25:06 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Hi, thanks for sharing this problem.

The project.assets.json file is supposed to be produced by VS prior to NCrunch loading the project. Sometimes, it isn't ready in time and NCrunch needs a reload cycle to pick it up. Can you confirm whether building the solution in VS then resetting NCrunch resolves the problem?
christopher7694
#3 Posted : Tuesday, April 27, 2021 12:39:20 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/26/2021(UTC)
Posts: 4
Location: United States of America

I have built the project in VS and then reset NCrunch, the problem persists.
I verified the file exists.
Is the projects.assets.json location hard-coded?

I have a Directory.Build.props file that uses the two properties:
BaseIntermediateOutputPath and IntermediateOutputPath.

Does NCrunch pick up these properties?
Remco
#4 Posted : Tuesday, April 27, 2021 12:55:42 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
christopher7694;15417 wrote:

I have a Directory.Build.props file that uses the two properties:
BaseIntermediateOutputPath and IntermediateOutputPath.
Does NCrunch pick up these properties?


Changing these properties massively increases the complexity of the load system under NCrunch, especially if they are overridden using derived values inside a directory.props file.

We do have handling for this, but I'll need more information to understand how the system is failing. It's possible you have a use case that we can't handle.

Can you share any more information about how these values are declared in your directory.props file?
christopher7694
#5 Posted : Tuesday, April 27, 2021 5:44:50 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/26/2021(UTC)
Posts: 4
Location: United States of America

The file is not particularly complex:

Quote:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<BaseIntermediateOutputPath>..\..\..\.build\.intermediate\$(MSBuildProjectName)\obj\</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<BaseIntermediateOutputPath>..\..\..\.build\.intermediate\$(MSBuildProjectName)\obj\</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>


If you need specific information to help diagnose, please let me know.

Thank you for your help.
Remco
#6 Posted : Wednesday, April 28, 2021 12:31:32 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Thanks for sharing the extra details.

I see now where the compatibility hole is. We aren't able to properly handle an overridden BaseIntermediateOutputPath in a directory.props file using $(MSBuildProjectName). This is due to technical limitations with the way that MSBuild works and how we need to integrate with it in this area. Perhaps you could use a different property, such as $(AssemblyName) instead?
christopher7694
#7 Posted : Friday, April 30, 2021 6:32:24 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/26/2021(UTC)
Posts: 4
Location: United States of America

Remco;15420 wrote:
Thanks for sharing the extra details.

I see now where the compatibility hole is. We aren't able to properly handle an overridden BaseIntermediateOutputPath in a directory.props file using $(MSBuildProjectName). This is due to technical limitations with the way that MSBuild works and how we need to integrate with it in this area. Perhaps you could use a different property, such as $(AssemblyName) instead?


Still trying to figure this out.

So far, I've found that I need to remove:
Quote:

<OutDir>..\..\.build\</OutDir>
<OutputPath>..\..\.build\</OutputPath>

and
Quote:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<BaseIntermediateOutputPath>..\..\.build\.intermediate\$(MSBuildProjectName)\obj\</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<BaseIntermediateOutputPath>..\..\.build\.intermediate\$(MSBuildProjectName)\obj\</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>


as well as inform NCrunch config that each of the projects in the solution need to include a top level .editorconfig that apparently isn't found by NCrunch.

With all those changes, I do get the builds and tests to be recognized.

However, this isn't going to be viable long term. Do you have any other suggestions I can try?

Thanks!!

Remco
#8 Posted : Friday, April 30, 2021 10:56:55 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Does replacing the $(MSBuildProjectName) reference with $(AssemblyName) in the directory.build.props file make any difference?

Usually replacing the OutputPath/OutDir properties shouldn't create a problem. Did you need to do this to solve a different error?

The .editorconfig file won't be automatically detected if it isn't included in the project file(s). Using NCrunch's 'Additional files to include' setting is the correct solution to this problem.
divverencebart
#9 Posted : Wednesday, December 22, 2021 3:57:06 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/22/2021(UTC)
Posts: 1
Location: Netherlands

$(AssemblyName) doesn't even work for `dotnet build` itself - seems that that is resolved to 'empty' so it's 'dotnet restore'ing into the same folder for all projects
Any other suggestions?

Problem is that the default (project/obj) is messing with my docker based build - windows-generated files (needed for ncrunch, for example) are copied along into the docker build environment....

Remco
#10 Posted : Wednesday, December 22, 2021 10:53:23 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
divverencebart;15906 wrote:
$(AssemblyName) doesn't even work for `dotnet build` itself - seems that that is resolved to 'empty' so it's 'dotnet restore'ing into the same folder for all projects
Any other suggestions?


I'm reduced to guesswork here, but what if you set the AssemblyName to a fixed value inside each project file? It's intended to be a user specified value in the project configuration anyway:

<PropertyGroup>
<AssemblyName>MyProjectName</AssemblyName>
</PropertyGroup>
TobiasvdVen
#11 Posted : Monday, July 22, 2024 3:26:53 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/18/2022(UTC)
Posts: 7
Location: Denmark

Thanks: 2 times
Was thanked: 2 time(s) in 2 post(s)
I've been dealing with this issue at work, and I would really like to be able to use NCrunch, so I spent some time messing around :)
I've found what appears to be a workaround, but it makes me wonder if there is any way to make it a bit easier to maintain from NCrunch's side, or if this will fail at some point due to factors I'm failing to anticipate.

For my use-case, all intermediate output of each project in a solution must go to a directory named after the project, and grouped in a single directory. Due to MSBuild constraints, specifying BaseIntermediateOutputPath in the csproj file fails, see: https://github.com/dotnet/msbuild/issues/1603. So we use a Directory.build.props file instead, but this causes issues for NCrunch due to the temporary project file it must create. We must also use `$(MSBuildProjectName)` instead of `$(ProjectName)` or `$(AssemblyName)`, as the latter are empty when resolved in the props file.

I have been able to make this work with a Directory.build.props file containing:

Quote:

<BaseIntermediateOutputPath Condition="'$(NCrunch)' != '1'">..\_base\$(Platform)-$(Configuration)\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
<IntermediateOutputPath Condition="'$(NCrunch)' != '1'">..\_obj\$(Platform)-$(Configuration)\$(MSBuildProjectName)\</IntermediateOutputPath>
<BaseIntermediateOutputPath Condition="'$(NCrunch)' == '1'">..\_base\$(Platform)-$(Configuration)\$(NCrunchProjectName)\</BaseIntermediateOutputPath>
<IntermediateOutputPath Condition="'$(NCrunch)' == '1'">..\_obj\$(Platform)-$(Configuration)\$(NCrunchProjectName)\</IntermediateOutputPath>


`$(NCrunchProjectName)` is a custom build property that must be added for each project and set to that project's name. Additionally `Use build configuration` and `Use build platform` must be set manually, as `$(Platform)-$(Configuration)` is resolved to simply `-` by NCrunch by default.

I have 2 questions then:

1. Can we avoid needing to set `$(NCrunchProjectName)` manually per project somehow? Perhaps with an NCrunch build property for `NCrunchOriginalProjectName` such as those listed here: https://www.ncrunch.net/...runch-build-properties.
2. Can we make $(Platform)-$(Configuration) work out-of-the-box so we don't have to hardcode this in the NCrunch settings, but have it use whatever we have Visual Studio (in this case) set to?

I have a minimal repro to demonstrate this if that would be helpful, but I'm unsure how to share it.

Curious if you have any thoughts.
Remco
#12 Posted : Tuesday, July 23, 2024 12:41:34 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Sorry that this is such a painful issue. I may have some good news though. Can you confirm which version of NCrunch you've last tested this on? In v5.8 (released 20th of June) we included a change/hack by which NCrunch will forcefully align MSBuildProjectName with the main project name. This was done specifically to address issues such as the usage of this property in Directory.build.props. I'm hopeful it will have solved the problem for you without the need for proxy properties or other configuration. Can you confirm whether it works?
TobiasvdVen
#13 Posted : Tuesday, July 23, 2024 7:49:00 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/18/2022(UTC)
Posts: 7
Location: Denmark

Thanks: 2 times
Was thanked: 2 time(s) in 2 post(s)
I should have mentioned my version, it's: 4.16.0.4.

So I don't have that fix yet, I guess I'll upgrade and report back if it works :)
1 user thanked TobiasvdVen for this useful post.
Remco on 7/23/2024(UTC)
TobiasvdVen
#14 Posted : Wednesday, July 24, 2024 1:05:03 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/18/2022(UTC)
Posts: 7
Location: Denmark

Thanks: 2 times
Was thanked: 2 time(s) in 2 post(s)
It seems to work for us on the latest version, excellent!

(5.9.0.1)
1 user thanked TobiasvdVen for this useful post.
Remco on 7/24/2024(UTC)
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.136 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download