If you start Visual Studio without administrator rights and the Finance and Operations extension is installed, you may get this message box at every start:

Failed to add assembly redirects to test platform configuration files.
Please open the output window pane 'Dynamics 365 for Finance and Operations' to see more details.

Start Visual Studio as administrator and the message is gone. That points to file permissions, and that is the cause.

What the extension is doing #

When the extension package initializes, it runs an AssemblyRedirectChecker (method AddRedirectsToTestConfigs / AddRedirectsIfNecessary in Microsoft.Dynamics.Framework.Tools.Installer.17.0.dll, extension version 7.0.8199.32). It adds binding redirects to the configuration files of the Visual Studio test platform, so that X++ unit tests can load the versions of two .NET assemblies the X++ runtime needs. The details in the output pane show what it wants to add:

<dependentAssembly>
  <assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
<dependentAssembly>
  <assemblyIdentity name="Microsoft.Extensions.Options" publicKeyToken="adb9793829ddae60" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>

Those configuration files are part of the Visual Studio installation, under Program Files:

C:\Program Files\Microsoft Visual Studio\18\Professional\Common7\IDE\Extensions\TestPlatform\
    testhost.exe.config
    testhost.net48.exe.config
    vstest.console.exe.config
    ...

Ordinary users can only read and execute these files:

PS> icacls "...\TestPlatform\testhost.exe.config"
NT AUTHORITY\SYSTEM:(I)(F)
BUILTIN\Administrators:(I)(F)
BUILTIN\Users:(I)(RX)

A non-elevated Visual Studio cannot write them, so the check fails, and because the redirects never get written, it fails again at the next start. An elevated Visual Studio writes them and stays quiet.

If you ignore the message, building and synchronizing still work. As the output pane warns, the missing redirects may break running X++ unit tests from Visual Studio.

Why it comes back after a Visual Studio update #

The Visual Studio installer replaces the files in TestPlatform with every update. The redirects the extension added are gone, and the message box returns. Starting Visual Studio once as administrator after each update is a workaround, but it is easy to forget, and on machines where elevation goes through a privilege-management tool it is not always an option.

The fix: let users modify these files #

Give the local Users group modify rights on the .config files in that one folder. Run this in an elevated PowerShell:

$testPlatform = "C:\Program Files\Microsoft Visual Studio\18\Professional\Common7\IDE\Extensions\TestPlatform"
icacls "$testPlatform\*.config" /grant "*S-1-5-32-545:M"

Notes on the command:

  • *S-1-5-32-545 is the well-known SID of the local Users group. Using the SID instead of the name works on every Windows display language (on a German Windows the group is called Benutzer).
  • M (modify) lets the extension read and rewrite the file. It does not grant rights to change permissions or take ownership.
  • The grant applies only to the existing .config files, not to the folder or the executables next to them.

Adjust the path to your edition and version (Professional, Enterprise, 17 for Visual Studio 2022). To find it, run:

& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -all -property installationPath

Then start Visual Studio normally. The extension adds its redirects on the next start, and the message disappears. You can check that they were written:

Select-String -Path "$testPlatform\*.config" -Pattern 'Microsoft.Extensions.Options' -List |
    ForEach-Object Filename

Things to keep in mind #

  • Re-run the icacls command after Visual Studio updates. The installer replaces the files, and the new files inherit the default read-only permissions again.
  • This loosens permissions under Program Files. Any process running as a local user can now change how the test host binds assemblies. On a single-user development VM that is an acceptable trade-off. If your organization does not allow it, start Visual Studio once as administrator after each update instead.
  • This is a workaround for a design choice of the extension. Writing into the Visual Studio installation from a non-elevated IDE cannot work with the default permissions. The extension simply reports it at every start.

<
Previous Post
Why SysTestCaseDataDependency Stalls Unit Test Runs on a UDE
>
Blog Archive
Archive of all previous blog posts