I need to execute a .NET 6 or 7 Background Service as a different account user. Note I need to do this in Visual Studio 2022. I have referenced "Start external program" functionality under the Debug section of a project's properties and reviewed How to debug a Visual Studio 2022 console application running as a service using a gMSA.
Has anyone figured out how to do this with 2022's new Debug settings?
I've tried different permutations on the following screen, with different arguments, with and without working directory, etc.:
When I debug the application, a console appears requesting the password (I do realize there is switch for caching this) which I provide. It attempts to start a different console, yet closes extremely quick. The original console then shows an exit code of 0:
VS's Output window shows the following:
08:12:35:002 The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.
08:12:35:002 The program '[33484] runas.exe: Program Trace' has exited with code 0 (0x0).
08:12:35:002 The program '[33484] runas.exe' has exited with code 0 (0x0).
My TargetFramework is "net6.0" and I have a number of runtimes and sdks on this box.
Has anyone been successful with 2022 and have some recommendations?