Build/Test Issues

AnyCPU Test not working

Started by Dinesh on 3,526 views

My main project is AnyCPU and so is my test project. Before I did not have the following line in my main project csproj file <PlatformTarget>AnyCPU</PlatformTarget>, once added I get following exception.

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:\TestProject\obj\project.assets.json' doesn't have a target for '.NETFramework,Version=v4.6.1/win7-x86'. Ensure that restore has run and that you have included 'net461' in the TargetFrameworks for your project. You may also need to include 'win7-x86' in your project's RuntimeIdentifiers.
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 , ProcessorArchitecture , GridClientId , BuildSystemParameters , IList`1 , Nullable`1 , GridAddress )
at nCrunch.Core.BuildManagement.BuildProcessLauncher.AnalyseComponentBuildInExternalProcess(ComponentLoadParameters parameters, IList`1 customEnvironmentVariables)
at nCrunch.Client.ComponentLoader.SnapshotComponentLoader.(ProcessorArchitecture , 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)

According to your documentation I can force it to use CPU architecture from AutoDetect to x86, which I've done and still same error.

Please note the test builds successfully using Resharper Test Runner as well as MSTest and NUnit Test Runner, it is just NCrunch that is complaining.



Hi, thanks for sharing this issue.

This looks like a synchronisation problem between your project.assets.json file and the project as loaded by your IDE.

Try the following steps:

1. Close all instances of VS
2. Browse to the directory of the offending project
3. Delete the 'obj' and 'bin' directories (or rename if you're unsure)
4. Re-open VS and open the solution
5. Wait for VS to regenerate the project.assets.json file. NCrunch should detect it automatically. If not, try resetting the NCrunch engine a few seconds after opening the solution.

The configuration overrides in the documentation won't have any impact on this problem, as it's appearing when NCrunch first loads the project. The overrides all apply to downstream tasks (i.e. building, running tests, etc).
Thanks, I don't need to do this anymore so I've removed <PlatformTarget>AnyCPU</PlatformTarget> from my csproj which is what it was before and all good.

Post a reply

Log in to reply.