Build/Test Issues

Build fails - net48/win7-x86 not found

Started by Dirk Maegh on 2,818 views

Hi,

I am changing a netstandard2.0 library and client to net48;net60;net80.

For the package dependencies I have introduced some conditional ItemGroup on TargetFramework.

All builds run fine in VS2022 Preview - I had set the ncrunch build SDK to 9.0 rc something, but for this solution, I updated it to something fixed and solid - 8.0.403.

My library has these settings
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net48;net6.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>
...


My client has about the same
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net48;net6.0;net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
...


As already mentioned, VS builds fine.
But ncrunch gives me this error

System.Exception: An exception was thrown in the remote environment: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> Errors occurred while trying to load the project file:
Assets file 'D:\P\xxx\src\Samples\xxx.Client\obj\project.assets.json' doesn't have a target for 'net48/win7-x86'. Ensure that restore has run and that you have included 'net48' in the TargetFrameworks for your project. You may also need to include 'win7-x86' in your project's RuntimeIdentifiers.
--- End of inner exception stack trace ---
at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at nCrunch.TaskRunner.Ipc.IpcMessageProcessor.processCallMethodMessage(CallMethodMessage callMethodMessage)
at nCrunch.TaskRunner.Ipc.IpcMessageProcessor.ProcessMessageReturningResult(Byte[] data)
at nCrunch.TaskRunner.Ipc.RemoteProxyCommunicator.(Byte[] )
at nCrunch.TaskRunner.Ipc.RemoteProxyCommunicator.Invoke(String methodName, Object[] args)
at nCrunch.Compiler.RemoteBuildRunnerProxy.AnalyseComponentBuild(ComponentLoadParameters parameters)
at nCrunch.Core.BuildManagement.BuildProcessLauncher..(IRemoteBuildRunner )
at nCrunch.Core.BuildManagement.BuildProcessLauncher.(Action`1 , FilePath , String , DirectoryPath , ExternalProcess )
at nCrunch.Core.BuildManagement.BuildProcessLauncher.(Action`1 , EffectiveProcessorArchitecture , GridClientId , BuildSystemParameters , IList`1 , Nullable`1 , GridClientDescription , DotNetCoreSdkVersion  )
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, IDEVersion ideVersion, BuildEngineId buildEngineId, ComponentUniqueName componentName, TaskSettings componentTaskSettings, Exception parseException, String targetFrameworkForMsbuild, String visibleTargetFramework)



I can't make sense of "You may also need to include 'win7-x86' in your project's RuntimeIdentifiers."
I can add it I think, but why would I need win7 something ? (I don't want windows 7 - we're on windows 11, if that's relevant)

Edited

Hi, thanks for sharing this issue.

I think this is being caused by a discrepancy between the build system being used by VS compared with NCrunch.

Most likely the project.assets.json file generated by VS's package restore step has been generated by a different version of the platform to the one NCrunch is using to build the project. This can result in some crazy weird errors. If you're running the preview version of VS, you'll need to make sure the chosen Build SDK for NCrunch is set to the latest preview version of .NET that you have installed. VS2022's .NET resolution logic is different when it is in preview mode (the normal one won't use preview platforms when it resolves).

Note that the Build SDK is not the same as the target framework for the project. It's perfectly fine to have Build SDK set to 9.0 rc, and have it build a .NET 8.0 project. If you want to avoid using preview tooling for this solution, you'll need to avoid using the preview version of VS2022.

This post has been deleted.
I have removed the item about ExcludeFromCoverage. After cleaning my projects, I got the same problem from VS. So not an nCrunch issue. I should have been more careful before posting, sorry :)

Post a reply

Log in to reply.