NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 252 forks source link

Test: NetCoreProjectExecuteInitScriptOnlyOnce test consistently fails #7891

Open dtivel opened 5 years ago

dtivel commented 5 years ago
System.Management.Automation.PSInvalidOperationException: The WriteObject and WriteError methods cannot be called from outside the overrides of the BeginProcessing, ProcessRecord, and EndProcessing methods, and they can only be called from within the same thread. Validate that the cmdlet makes these calls correctly, or contact Microsoft Customer Support Services.
at System.Management.Automation.MshCommandRuntime.ThrowIfWriteNotPermitted(Boolean needsToWriteToPipeline)
at System.Management.Automation.MshCommandRuntime.DoWriteError(Object obj)
at System.Security.SecurityContext.Run(SecurityContext securityContext, ContextCallback callback, Object state)
at System.Management.Automation.MshCommandRuntime.WriteError(ErrorRecord errorRecord, Boolean overrideInquire)
at System.Management.Automation.MshCommandRuntime.WriteError(ErrorRecord errorRecord)
at System.Management.Automation.Cmdlet.WriteError(ErrorRecord errorRecord)
at NuGet.PackageManagement.PowerShellCmdlets.NuGetPowerShellBaseCommand.HandleError(ErrorRecord errorRecord, Boolean terminating)
at NuGet.PackageManagement.PowerShellCmdlets.NuGetPowerShellBaseCommand.HandleException(Exception exception, Boolean terminating, String errorId, ErrorCategory category, Object target)
at NuGet.PackageManagement.PowerShellCmdlets.NuGetPowerShellBaseCommand.WriteError(Exception exception)
at NuGet.PackageManagement.PowerShellCmdlets.NuGetPowerShellBaseCommand.WriteError(String message)
at NuGet.PackageManagement.PowerShellCmdlets.NuGetPowerShellBaseCommand.LogCore(MessageLevel level, String formattedMessage)
at NuGet.PackageManagement.PowerShellCmdlets.NuGetPowerShellBaseCommand.WaitAndLogPackageActions()
at NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand.<ProcessRecordCore>b__7_1()
at NuGet.PackageManagement.VisualStudio.NuGetLockService.<>c__DisplayClass9_0`1.<<ExecuteNuGetOperationAsync>b__2>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask.<JoinAsync>d__68.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask`1.<JoinAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.PackageManagement.VisualStudio.NuGetLockService.<>c__DisplayClass9_0`1.<<ExecuteNuGetOperationAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask.<JoinAsync>d__68.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask`1.<JoinAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.PackageManagement.VisualStudio.NuGetLockService.<ExecuteNuGetOperationAsync>d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand.<<ProcessRecordCore>b__7_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
at NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand.ProcessRecordCore()
at NuGet.PackageManagement.PowerShellCmdlets.NuGetPowerShellBaseCommand.ProcessRecord() 
dtivel commented 5 years ago

Appears to be resolved, though no fix was explicitly made.

dtivel commented 5 years ago

Happening again.

cdonnellytx commented 5 years ago

This error does happen to me quite frequently in Visual Studio when running Update-Package, as well as a number of other errors that suggest concurrency issues, so it's not just something that happens during a flaky test.

Based on the stack trace it's probably executing outside the main thread, so it looks like that code should call a Dispatcher to write to WriteError?

References:

Edit: This happens on pretty much any version of VS, including the current (VS2019 16.3.0, PowerShell Desktop 5.1.18362.145).

IanKemp commented 4 years ago

Happens to me only when I do uninstall-package <packagename> ; install-package <packagename> - this error is then thrown by install-package.