How do I run Visual Studio 2022 unit tests to WSL as root?
I have a testEnvironments.json file that is able to run unit tests to my WSL instance from Visual Studio 2022 on Windows 11. Unfortunately there seems to be no way to force these tests to run as sudo / root. I've already tried running Visual Studio as administrator.
I have verified the getuid
returns a non-zero value.
I have a hard requirement of running my code as root on Linux.
{
"version": "1",
"environments":
[
{
"name": "Ubuntu",
"type": "wsl",
"wslDistribution": "Ubuntu"
}
]
}
CodePudding user response:
Run from powershell:
ubuntu config --default-user root
If that does not work, try using the following code for the testEnvironments.json file:
{
"version": "1",
"environments":
[
{
"name": "Ubuntu",
"type": "wsl",
"wslDistribution": "Ubuntu",
"runAsRoot": "true"
}
]
}