Github Actions UWP vstest fails to start (access denied) on self-hosted runner but not on github-hosted runner

236 Views Asked by At

I set up a self-hosted runner to run my UWP tests (on Windows 10). The tests run fine when I am locally connected via RDC and run vstest.console.exe from a powershell. The exact same command does give below error (UnauthorizedAccessException: Access is denied.) when executed as a runner via Github Actions. I then set up a runner with an admin account, but it results in the same error.

My assumption is that it has something to do with privileges of the runner itself, and with the fact that UWP tests are actually ran via a package that first needs be installed and then executed as an app. However, when I run the test app via a Github-hosted runner (also using vstest.console.exe), it all runs fine. Thus I am sure that there must be a way to run it. FYI, I am literally using the same action, just one runs on "self-hosted" the other on "windows-latest".

Does anyone have an idea why I get the error and how to resolve it?

'UnitTesterUWP_1.0.0.0_x64__gwkdyh6xmv8h8'.
Attempting to launch app with app user model Id 'UnitTesterUWP_gwkdyh6xmv8h8!vstest.executionengine.universal.App' and arguments '--port 57663 --endpoint 127.0.0.1:057663 --role client --parentprocessid 32412 --local-path "C:\actions-runner\_work\MY_App\MY_App\repoMY_App\x64\Release\MY_UNITTEST_WIN_UWP" --datacollectionport 57662 --telemetryoptedin false'.
Deploy: END (Success, 0:00:00,935)
UnauthorizedAccessException: Access is denied.

Access is denied.

   at Microsoft.VisualStudio.Deployment.IPackageDebugSettings.EnableDebugging(String packageFullName, String debuggerCommandLine, String environment)
App activation failed.
   at Microsoft.VisualStudio.Deployment.LocalAppActivationDriver.LaunchAppLocally(String appUserModelId, String packageFullName, String launchArgs, String architecture)
   at Microsoft.VisualStudio.Deployment.LocalAppActivationDriver.Microsoft.VisualStudio.Deployment.IAppActivationDriver.LaunchAppAsync(String appUserModelId, String packageFullName, String launchArgs, String target, String architecture)
   at Microsoft.VisualStudio.Deployment.Service.<Microsoft-UniversalApps-Deployment-IAppLauncher-LaunchAppAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.Deployer.<Microsoft-VisualStudio-UwpTestHostRuntimeProvider-IDeployer-ActivateAsync>d__53.MoveNext()
Failed to initialize client proxy: could not connect to test process.
Closing app with package full name 'UnitTesterUWP_1.0.0.0_x64__gwkdyh6xmv8h8'.
UnauthorizedAccessException: Access is denied.

Access is denied.

Closing the app failed.
   at Microsoft.VisualStudio.Deployment.IPackageDebugSettings.TerminateAllProcesses(String packageFullName)
   at Microsoft.VisualStudio.Deployment.LocalAppActivationDriver.Microsoft.VisualStudio.Deployment.IAppActivationDriver.CloseAppAsync(String appUserModelId, String packageFullName, String target, String architecture)
   at Microsoft.VisualStudio.Deployment.Service.<Microsoft-UniversalApps-Deployment-IAppLauncher-CloseAppAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.Deployer.<Microsoft-VisualStudio-UwpTestHostRuntimeProvider-IDeployer-CloseAppAsync>d__54.MoveNext()


Test Run Aborted.
1

There are 1 best solutions below

0
Dr.J On

The only solution I found now is to start the runner manually after login (e.g. via autostart). As testing a UWP app requires to open a window, it seems to be required to have an active user session. I can RDP to the test machine, log in, start the runner, and then close RDP. So, eventually I will probably configure the RDP machine to auto login with a test user account, that autostarts the Github runner. In any case, using the Github runner as a service or starting it via task scheduler did not work.