Visual studio 2019 Test is failing with error "System.ComponentModel.Win32Exception (0x80004005): This program is blocked by group policy


I had recently upgraded to Visual studio 2019 from 2017. The tests (xunit) was working fantastic until this update. But after updating, when i run my tests it just says "Outcomes Not Run".!!! strange, even it doesn't shows any details of any error under Output window, later found we have to manually change "Show output from: " drop-down in Output window to "Tests" to see that. I got these details as below

System.Runtime.InteropServices.COMException (0x89710016): Unable to start program C:\Users\bb00001\.nuget\packages\microsoft.testplatform.testhost\16.5.0\build\netcoreapp2.1\x64\testhost.exe.

This program is blocked by group policy. For more information, contact your system administrator.

Since I works in a very restrictive environment, understood i cant run any exes under that location since GP restriction. But got access to particular locations under C Drive.

Is there anyway I can change my testhost.exe file location? which visual studio can pickup the exe from a configured path?
asked on Stack Overflow Feb 7, 2020 by RX100 • edited Feb 13, 2020 by RX100

1 Answer


After referring the link, I had set an environmental variable like below, where i set a new nuget-package source which my group policy allows me to run applications

enter image description here

This will automatically override the default location to newly setup location. Later restart the visual studio and rebuild the solution, it must add all the dependencies to new location. It worked for me. Not sure this issue will occur to anyone else, but maybe helpful, if someone with need.

answered on Stack Overflow Feb 7, 2020 by RX100

User contributions licensed under CC BY-SA 3.0