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

Notification

Icon
Error

Load Project failure: Your project.json doesn't have a runtimes section
pbering
#1 Posted : Monday, August 1, 2016 8:24:45 AM(UTC)
Rank: Member

Groups: Registered
Joined: 10/26/2012(UTC)
Posts: 13
Location: Denmark

Thanks: 1 times
Hi,

NCrunch can't load a class library project that is csproj based but also has project.json and PROJECTNAME.project.json (see repo with solution here: https://github.com/pbering/ncrunch-issue)

This setup works fine when building solution from command line with MSBUILD and from visual studio, but NCrunch fails loading with:

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:
Your project.json doesn't have a runtimes section. You should add '"runtimes": { "win": { } }' to your project.json and then re-run NuGet restore.
at nCrunch.Compiler.RemoteBuildRunner.(FilePath ,   , String , String , DirectoryPath , String )
at nCrunch.Compiler.RemoteBuildRunner.AnalyseComponentBuild(FilePath projectFilePath, BuildXml buildXml, String useBuildConfiguration, String useBuildPlatform, DirectoryPath solutionDir, String solutionName, List`1 importExpressionsToEvaluate, ProcessorArchitecture buildProcessProcessorArchitecture, DirectoryPath workspaceBasePath)
--- 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.[T](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(FilePath projectFilePath, BuildXml buildXml, String useBuildConfiguration, String useBuildPlatform, DirectoryPath solutionDir, String solutionName, List`1 importExpressionsToEvaluate, ProcessorArchitecture buildProcessProcessorArchitecture, DirectoryPath workspaceBasePath)
at nCrunch.Core.BuildManagement.BuildProcessLauncher..(IRemoteBuildRunner )
at nCrunch.Core.BuildManagement.BuildProcessLauncher.(Action`1 , IBuildableProject , ExternalProcess )
at nCrunch.Core.BuildManagement.BuildProcessLauncher.(Action`1 , ProcessorArchitecture , GridClientId , IBuildableProject , IList`1 )
at nCrunch.Core.BuildManagement.BuildProcessLauncher.AnalyseComponentBuildInExternalProcess(FilePath projectFilePath, BuildXml buildXml, String useBuildConfiguration, String useBuildPlatform, DirectoryPath solutionDir, String solutionName, List`1 importExpressionsToEvaluate, ProcessorArchitecture processorArchitecture, VisualStudioVersion vsVersion, IList`1 customEnvironmentVariables)
at nCrunch.Client.ComponentLoader.SnapshotComponentFactory.(ProcessorArchitecture )
at nCrunch.Client.ComponentLoader.SnapshotComponentFactory.CreateSnapshotComponentFromXml(FilePath projectFilePath, BuildXml projectXml, FilePath solutionFilePath, String[] additionalFilesToIncludeAtSolutionLevel, Boolean isLoadedFromFile, ISnapshotConfig snapshotConfig, VisualStudioVersion vsVersion)

What can I do to fix this besides setting projects to be ignored completely by NCrunch?
Remco
#2 Posted : Monday, August 1, 2016 8:31:52 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks for sharing this issue. Can you confirm which version of NCrunch you're running? This looks suspiciously similar to a problem that was fixed late last year.
pbering
#3 Posted : Monday, August 1, 2016 8:34:12 AM(UTC)
Rank: Member

Groups: Registered
Joined: 10/26/2012(UTC)
Posts: 13
Location: Denmark

Thanks: 1 times
I'm running 2.24.0.2, should be latest...
Remco
#4 Posted : Monday, August 1, 2016 8:44:00 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
My first thought was that this error was originating from NCrunch's own DNX integration, as last year there were some builds of NCrunch that specifically looked for project.json and tried to interact with the DNX runtime to load them. This integration was disabled/removed after the DNX runtime changed significantly enough to break it.

However, it looks like this error is being kicked up by MSBuild itself during project load. I can't seem to reproduce it myself using the sample solution you've provided (these projects load correctly for me), so I think it may be related to something either of us have installed or not installed. Does removing the .json files from the project XML make any difference?

pbering
#5 Posted : Monday, August 1, 2016 8:55:14 AM(UTC)
Rank: Member

Groups: Registered
Joined: 10/26/2012(UTC)
Posts: 13
Location: Denmark

Thanks: 1 times
hmm if it remove the json files and reloads the solution it works - but as soon as a do a "dotnet restore" and "dotnet build" in the ClassLibrary4 project and reloads solution then it stops working again. Very strange... From commandline everything seems to work both with MSBUILD building solution or projects and dotnet build,
pbering
#6 Posted : Monday, August 1, 2016 8:58:41 AM(UTC)
Rank: Member

Groups: Registered
Joined: 10/26/2012(UTC)
Posts: 13
Location: Denmark

Thanks: 1 times
btw dotnet --version is: 1.0.0-preview2-003121
Remco
#7 Posted : Monday, August 1, 2016 9:10:11 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Try using an MSBuild expression to exclude the json files from the project for NCrunch builds, for example:

<ItemGroup Condition="'$(NCrunch)' != '1'">
<None Include="ClassLibrary4.project.json" />
<None Include="project.json" />
</ItemGroup>

With this in place, the files won't be included in the project when NCrunch runs MSBuild to load the project. The files will still be included when the project is built outside of NCrunch.
pbering
#8 Posted : Monday, August 1, 2016 9:55:39 AM(UTC)
Rank: Member

Groups: Registered
Joined: 10/26/2012(UTC)
Posts: 13
Location: Denmark

Thanks: 1 times
It does not seem to have any effect. Even when I exclude both json files from the project, ncrunch still fails. When I remove both json filen (and the lock files) and reloads solution then it works. Added the json files (without including in project) works until dotnet restore. I can also make ncrunch work again by only removing the lock files from disk. Is there away to make ncrunch ignore files on disk?
Remco
#9 Posted : Monday, August 1, 2016 10:42:49 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
pbering;9073 wrote:
It does not seem to have any effect. Even when I exclude both json files from the project, ncrunch still fails. When I remove both json filen (and the lock files) and reloads solution then it works. Added the json files (without including in project) works until dotnet restore. I can also make ncrunch work again by only removing the lock files from disk. Is there away to make ncrunch ignore files on disk?


Interesting. Whatever is causing this must be a step inside your build system that is specifically looking for the .lock file.

Unfortunately, making NCrunch blind to these files won't solve the problem, as the exception is being thrown by the build system, not NCrunch itself. All NCrunch knows about is the invocation of MSBuild. The explosion happens further down the tool-chain. Technically this should probably be put past Microsoft, but as they are working to replace the whole infrastructure involved in this process I don't think we'll see a timely solution from them. The best we can hope for here is to find a workaround.

Would you be able to obtain for me a detailed MSBuild log from when you build this project using the command line? Try the following command:

msbuild /v:d ClassLibrary4.csproj > build.log

It may be quite a large file, so you can zip it up and send it via the contact form if you like.
pbering
#10 Posted : Monday, August 1, 2016 10:53:35 AM(UTC)
Rank: Member

Groups: Registered
Joined: 10/26/2012(UTC)
Posts: 13
Location: Denmark

Thanks: 1 times
Thanks, I've send the build log...

As a workaround I can delete the lock files locally when I need ncrunch to work. Locally I only do dotnet restore when testing build scripts for the CI pipeline.
Remco
#11 Posted : Monday, August 1, 2016 11:08:48 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Try adding this to the top of your project file (as the first propertygroup):

<PropertyGroup>
<ResolveNuGetPackages Condition="'$(NCrunch)' == '1'">false</ResolveNuGetPackages>
</PropertyGroup>
pbering
#12 Posted : Monday, August 1, 2016 11:26:07 AM(UTC)
Rank: Member

Groups: Registered
Joined: 10/26/2012(UTC)
Posts: 13
Location: Denmark

Thanks: 1 times
That did the trick! Thank you! Where does this setting come from? The .NET Core preview tooling, Nuget extension or?
Remco
#13 Posted : Monday, August 1, 2016 11:42:44 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
pbering;9077 wrote:
That did the trick! Thank you! Where does this setting come from? The .NET Core preview tooling, Nuget extension or?


It's related to a Nuget build task responsible for doing some tricky things around resolving packages. By turning off the resolution property, the target invoking the task won't execute and the error isn't kicked up.

I've yet to determine the true reason why the task is kicking up the error. Depending on the future of this area of tooling, it may not be worth investigating.
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.072 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download