Skip to content

Updating System.ServiceProcess.ServiceController to its .Net Core 3-preview6 version breaks 2 tests #10067

@bergmeister

Description

@bergmeister

Updating the 2 NuGet package System.ServiceProcess.ServiceController (or Microsoft.Windows.Compatibility, which is depending on it) from 4.5.0 (.Net Core 2.1) to 4.6.0-preview6.19303.8 (.Net Core 3-preview6) breaks 2 tests and the reason for their failure seems to be unclear (i.e. whether it is a problem of PowerShell itself that is now being exposed or a regression in the System.ServiceProcess.ServiceController NuGet package itself), therefore their update was deferred in PR 9888

Steps to reproduce

Update the System.ServiceProcess.ServiceController NuGet package to 4.6.0-preview6.19303.8

Expected behavior

All tests pass.

Actual behavior

There are 2 failures on Windows:

  • Set/New/Remove-Service cmdlet tests.Set-Service can accept a ServiceController as positional input:
Expected strings to be the same, but they were different.
String lengths are both 14.
Strings differ at index 0.
Expected: 'newdisplayname'
But was:  'testsetservice'
at <ScriptBlock>, D:\a\1\s\test\powershell\Modules\Microsoft.PowerShell.Management\Set-Service.Tests.ps1: line 321
321:             $service.DisplayName | Should -BeExactly $newdisplayname

It is worthwhile noting that the first Windows service test throws an ObjectDisposedException before it fails:

		Set-Service : Cannot access a disposed object.
Object name: 'ServiceController'.
At C:\Users\cberg\git\PowerShell\test\powershell\Modules\Microsoft.PowerShell.Management\Set-Service.Tests.ps1:318 char:25
+ ...       $script = { Set-Service $service -DisplayName $newdisplayname }
+                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (:) [Set-Service], ObjectDisposedException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.SetServiceCommand

image

  • Get-WinEvent.Get-WinEvent can retrieve events.Get-WinEvent can use the simplest of filters
Cannot convert argument "value", with value: "System.Diagnostics.Eventing.Reader.EventLogRecord", for "TryAdd" to type "System.Diagnostics.Eventing.Reader.EventLogRecord": "Cannot convert the "System.Diagnostics.Eventing.Reader.EventLogRecord" value of type "System.Diagnostics.Eventing.Reader.EventLogRecord" to type "System.Diagnostics.Eventing.Reader.EventLogRecord"."
at <ScriptBlock>, D:\a\1\s\test\powershell\Modules\Microsoft.PowerShell.Diagnostics\Get-WinEvent.Tests.ps1: line 61
61:                 $testEventDict.TryAdd($te.Id, $te)

Environment data

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-FixedThe issue is fixed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions