Exception when running Resharper Command Line Tools during msbuild

I'm currently evaluating reshaper and tried to run Resharper Command Line Tools during the msbuild process with MS Visual Studio 2017 Professional Version 15.9.3 and .net target framework 4.6.1.
I get the following exception during the build process:
Error resolving component request for Microsoft.Build.Framework.IBuildEngine in ComponentAccessCardinality::Single mode in context “for <Unidentified Request> in Container: JetEnvironment” (for full exception see attachment).

I get this exception both when building in VS and with msbuild from the command line. I don't get any exception when running Resharper InspectCode from the command line or when I do a an inspection in VS. I also tried it with different projects (even with a new concole application), so I think it must be a problem with my Visual Studio.

The project file entry looks like this:

<Target Name="AfterBuild">
<InspectCode SolutionFile="..\ResharperConsoleTest.sln" IncludedProjects="ResharperConsoleTest" />
</Target>

Any ideas what could cause that exception?

 

Here is a full stack trace:

Error resolving component request for Microsoft.Build.Framework.IBuildEngine in ComponentAccessCardinality::Single mode in context “for <Unidentified Request> in Container: JetEnvironment”. Die Sequenz enthält mehr als ein Element.

--- EXCEPTION #1/2 [InvalidOperationException]
Message = “Die Sequenz enthält mehr als ein Element.”
ExceptionPath = Root.InnerException
ClassName = System.InvalidOperationException
HResult = COR_E_INVALIDOPERATION=80131509
Source = System.Core
StackTraceString = “
bei System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
bei JetBrains.Application.Components.ComponentRegisterEntry.SingleOrDefault()
bei JetBrains.Application.Components.ComponentStorage.ResolveImpl[TRequest](TRequest request, IValueResolveContext context)

--- Outer ---

--- EXCEPTION #2/2 [LoggerException]
Message = “Error resolving component request for Microsoft.Build.Framework.IBuildEngine in ComponentAccessCardinality::Single mode in context “for <Unidentified Request> in Container: JetEnvironment”.”
ExceptionPath = Root
ClassName = JetBrains.Util.LoggerException
InnerException = “Exception #1 at Root.InnerException”
HResult = COR_E_APPLICATION=80131600
StackTraceString = “
bei JetBrains.Application.Components.ComponentContainer.Resolve[TRequest](TRequest request, IValueResolveContext context)
bei JetBrains.Application.Components.ComponentResolveContext.Resolve[TRequest](TRequest request)
bei JetBrains.Application.Components.DelegatingComponentContainer.Resolve[TRequest](TRequest request, IValueResolveContext context)
bei JetBrains.Application.Components.ComponentContainer.ResolveFirstOrDefault[TRequest](List`1 resolvers, TRequest request, IValueResolveContext context)
bei JetBrains.Application.Components.ComponentContainer.Resolve[TRequest](TRequest request, IValueResolveContext context)
bei JetBrains.Application.Components.ComponentResolveContext.Resolve[TRequest](TRequest request)
bei JetBrains.Application.Components.DelegatingComponentContainer.Resolve[TRequest](TRequest request, IValueResolveContext context)
bei JetBrains.Application.Components.ComponentContainer.ResolveFirstOrDefault[TRequest](List`1 resolvers, TRequest request, IValueResolveContext context)
bei JetBrains.Application.Components.ComponentContainer.Resolve[TRequest](TRequest request, IValueResolveContext context)
bei JetBrains.Application.Components.ComponentResolveContext.Resolve[TRequest](TRequest request)
bei JetBrains.Application.Components.DelegatingComponentContainer.Resolve[TRequest](TRequest request, IValueResolveContext context)
bei JetBrains.Application.Components.ComponentContainer.ResolveFirstOrDefault[TRequest](List`1 resolvers, TRequest request, IValueResolveContext context)
bei JetBrains.Application.Components.ComponentContainer.Resolve[TRequest](TRequest request, IValueResolveContext context)
bei JetBrains.Application.Components.ComponentResolveContext.Resolve[TRequest](TRequest request)
bei JetBrains.Application.Components.SignatureResolution.BindToMethod(MethodBase[] candidates, IValueResolveContext context, Object origin)
bei JetBrains.Application.Components.SignatureResolution.BindToConstructor(Type type, IValueResolveContext context)
bei JetBrains.Application.Extensibility.PartCatalogTypeComponentDescriptor.CreateInstanceOf(Type type, IValueResolveContext context)
bei JetBrains.Application.Extensibility.PartCatalogTypeComponentDescriptor.CreateInstance(IValueResolveContext context)
bei JetBrains.Application.Components.SingletonDescriptor.CreateInstanceChecked(OnError onError, IComponentContainer container)
bei JetBrains.Application.Components.SingletonDescriptor.GetValue()
bei JetBrains.Application.Components.EnumerableValueResolver.EnumerableComponentDescriptor`1.<GetEnumerator>d__5.MoveNext()
bei JetBrains.Application.Components.EnumerableValueResolver.EnumerableComponentDescriptor`1.GetValue()
bei JetBrains.Application.Components.SignatureResolution.BindArguments(List`1 argumentDescriptors, Object origin)
bei JetBrains.Application.Extensibility.PartCatalogTypeComponentDescriptor.CreateInstanceOf(Type type, IValueResolveContext context)
bei JetBrains.Application.Extensibility.PartCatalogTypeComponentDescriptor.CreateInstance(IValueResolveContext context)
bei JetBrains.Application.Components.SingletonDescriptor.CreateInstanceChecked(OnError onError, IComponentContainer container)
bei JetBrains.Application.Components.SingletonDescriptor.GetValue()
bei JetBrains.Application.Components.InitializationStrategyDefault.Schedule(Lifetime lifetime, ICollection`1 dscs, IComponentContainer container)
bei JetBrains.Application.Components.ComponentStorage.ComposeDescriptors(ICollection`1 descriptors)
bei JetBrains.Application.Components.ComponentStorage.Compose()
bei JetBrains.ProjectModel.SolutionInstance.OpenSolution(ISolutionOwner solutionOwner)
bei JetBrains.ProjectModel.SolutionManagerBase.<>c__DisplayClass23_0.<CreateSolutionInstance>b__0()
bei JetBrains.ProjectModel.Tasks.SolutionLoadTasksSchedulerBase.<>c__DisplayClass21_0.<ExecuteTask>b__1()
bei JetBrains.Util.ILoggerEx.Catch(ILogger thіs, Action F, ExceptionOrigin origin, LoggingLevel loggingLevel)
bei JetBrains.ProjectModel.Tasks.SolutionLoadTasksSchedulerBase.ExecuteTask(SolutionLoadTask task)
bei JetBrains.ProjectModel.Tasks.SolutionLoadTasksSchedulerSync.ExecuteTasks()
bei JetBrains.ProjectModel.Tasks.SolutionLoadTasksSchedulerSync.StartScheduling()
bei JetBrains.ProjectModel.SolutionManagerBase.CreateSolutionInstance(SolutionElement solutionElement, SolutionInstance solutionInstance)
bei JetBrains.ProjectModel.ProjectsHost.SolutionHost.Impl.SolutionHostManager.OpenSolution(ISolutionMark solutionMark, Object cookie)
bei JetBrains.CommandLine.InspectCode.Unattended.Console.InspectCodeProductMain.<>c__DisplayClass3_0.<OpenSolution>b__0()
bei JetBrains.Threading.ReentrancyGuard.Execute(String name, Action action)
bei JetBrains.CommandLine.InspectCode.Unattended.Console.InspectCodeProductMain.OpenSolution(FileSystemPath solutionFilePath, IShellLocks shellLocks, ILogger logger, SolutionHostManager solutionHost)
bei JetBrains.CommandLine.InspectCode.Unattended.Console.InspectCodeProductMain.Main(Lifetime lifetime, IThreading invocator, IComponentContainer container, IShellLocks shellLocks, ILogger logger, IInspectCodeSettings settings, IProductCommandLineArguments argumentsRaw)
bei System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
bei System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
bei JetBrains.Application.Environment.RunsPublicStaticIntMain.<>c__DisplayClass0_0.<.ctor>b__0()
bei JetBrains.Application.Environment.RunsPublicStaticIntMain.<>c__DisplayClass0_2.<.ctor>b__5()
bei JetBrains.Util.Logging.Logger.Catch(Action action)
bei JetBrains.Application.Threading.IThreadingEx.<>c__DisplayClass18_1.<ExecuteOrQueueWhenNotGuarded>b__4()
bei JetBrains.Threading.JetDispatcher.Closure.Execute()
bei JetBrains.Util.Concurrency.WinJetDispatcher.ProcessQueue(Int32 nMinBucket)
bei JetBrains.Util.Concurrency.WinJetDispatcher.<>c__DisplayClass18_0.<BeginInvokeCore>b__0()
bei System.Windows.Threading.DispatcherOperation.InvokeDelegateCore()
bei System.Windows.Threading.DispatcherOperation.InvokeImpl()
bei System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
bei MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Windows.Threading.DispatcherOperation.Invoke()
bei System.Windows.Threading.Dispatcher.ProcessQueue()
bei System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
bei MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
bei MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
bei System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
bei System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
bei MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
bei System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
bei System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
bei JetBrains.Application.Environment.IJetHostEx.<>c__DisplayClass2_0.<RunHostMessageLoop>b__0(Lifetime lifetime)
bei JetBrains.DataFlow.Lifetimes.Using(Action`1 λ)
bei JetBrains.Application.Environment.IJetHostEx.RunHostMessageLoop(IComponentContainer containerEnv)
bei JetBrains.Application.Environment.HostParameters.MessagePumpMainLoopHostMixin.JetBrains.Application.Environment.HostParameters.IRunMainLoopHostMixin.RunMainLoop(ComponentContainer containerEnv)
bei JetBrains.Application.Environment.HostParameters.JetHostParametersCaller.RunMainLoop(ComponentContainer containerEnv)
bei JetBrains.Application.Environment.JetEnvironment.InternalRun(JetHostParametersCaller host, ComponentContainer containerEnv)
bei JetBrains.Application.Environment.JetEnvironment.CreateAndRun(Full hostparams)
bei JetBrains.Application.Environment.JetHostItems.CreateAndRun(Full input)
bei JetBrains.CommandLine.InspectCode.MsBuild.Tasks.InspectCode.Execute()
bei Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
bei Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
bei System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
bei Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
bei Microsoft.Build.BackEnd.TaskBuilder.<InitializeAndExecuteTask>d__24.MoveNext()
bei System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
bei Microsoft.Build.BackEnd.TaskBuilder.InitializeAndExecuteTask(TaskLoggingContext taskLoggingContext, ItemBucket bucket, IDictionary`2 taskIdentityParameters, TaskHost taskHost, TaskExecutionMode howToExecuteTask)
bei Microsoft.Build.BackEnd.TaskBuilder.<>c__DisplayClass21_0.<ExecuteTaskInSTAThread>b__0()
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart()

 

 

3 comments
Comment actions Permalink

I'm having the same issue with VS 2019 and versions 2018.3.4/2019.1.1 of the command line tools.  My project is pretty much just the default console app with a few badly formatted lines of code to test the inspections.

0
Comment actions Permalink

I'm also getting the same issue with VS 2017 Professional 15.8.7 for a netstandard20 library project. Using 2019.1.1 version of the JetBrains.ReSharper.CommandLineTools NuGet package.

0
Comment actions Permalink

Hello!

 

Please refer to the following issue reported here - https://youtrack.jetbrains.com/issue/RSRP-470113.

You are welcome to comment or vote for it.

Thank you.

0

Please sign in to leave a comment.