vcsjones / AzureSignTool

SignTool Library and Azure Key Vault Support
MIT License
272 stars 85 forks source link

VS authentication fails with admin mismatch #193

Open uecasm opened 1 year ago

uecasm commented 1 year ago

I'm currently still using 2.0.18 (02845a3b631ea24852e72873b7a422e46d0bbae3) so it's possible this is something resolved since then, but one weird behaviour I've noticed is the following.

When I have VS2022 running not as admin, and with the correct Azure credentials specified in its settings, running AzureSignTool also as non-admin works as expected.

When I have VS2022 running as admin, still with the correct Azure credentials specified in its settings, running AzureSignTool as non-admin fails with:

       ---> (Inner Exception #2) Azure.Identity.CredentialUnavailableException: Process "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\CommonExtensions\Microsoft\Asal\TokenService\Microsoft.Asal.TokenService.exe" has failed with unexpected error: TS003: Error, TS005: No accounts found.  Please go to Tools->Options->Azure Services Authentication, and add an account to be authenticated to Azure services during development..
       ---> System.InvalidOperationException: TS003: Error, TS005: No accounts found.  Please go to Tools->Options->Azure Services Authentication, and add an account to be authenticated to Azure services during development.
         at Azure.Identity.VisualStudioCredential.RunProcessesAsync(List`1 processStartInfos, Boolean async, CancellationToken cancellationToken)
         --- End of inner exception stack trace ---
         at Azure.Identity.VisualStudioCredential.RunProcessesAsync(List`1 processStartInfos, Boolean async, CancellationToken cancellationToken)
         at Azure.Identity.VisualStudioCredential.GetTokenImplAsync(TokenRequestContext requestContext, Boolean async, CancellationToken cancellationToken)
         at Azure.Identity.CredentialDiagnosticScope.FailWrapAndThrow(Exception ex)
         at Azure.Identity.VisualStudioCredential.GetTokenImplAsync(TokenRequestContext requestContext, Boolean async, CancellationToken cancellationToken)
         at Azure.Identity.VisualStudioCredential.GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken)
         at Azure.Identity.DefaultAzureCredential.GetTokenFromSourcesAsync(TokenCredential[] sources, TokenRequestContext requestContext, Boolean async, CancellationToken cancellationToken)<---

When I have multiple instances of VS2022 open, it seems to matter which one was the first instance -- if I start an admin then a non-admin, it fails, then I close the admin (leaving only the non-admin) and start a new admin, and then it succeeds.

I haven't tested running AzureSignTool as admin as thoroughly, but it does seem like this always succeeds, even when the only VS instance is a non-admin one.


Edit: 4.0.1 (9f30f7a267eff7f3fe494c49e5a536a337c8dfde) has the same behaviour.