Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.TypeInitializationException thrown on MacOS #530

Open
victorlazaro opened this issue Nov 7, 2024 · 1 comment
Open

System.TypeInitializationException thrown on MacOS #530

victorlazaro opened this issue Nov 7, 2024 · 1 comment
Labels
question Further information is requested

Comments

@victorlazaro
Copy link

I am running into this error when running nuget restore on a Mac:

MSBuild auto-detection: using msbuild version '' from '/opt/homebrew/bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
Using /Users/victorlazaro/.nuget/plugins/netfx/CredentialProvider.Microsoft/CredentialProvider.Microsoft.exe as a credential provider plugin.
    [CredentialProvider.153721]Running in plug-in mode
    [CredentialProvider.153721]Command-line v1.2.3: /Users/victorlazaro/.nuget/plugins/netfx/CredentialProvider.Microsoft/CredentialProvider.Microsoft.exe -Plugin
    [CredentialProvider.153721]Handling 'Request' 'Initialize'. Time elapsed in ms: 1 - Payload: {"ClientVersion":"6.10.0","Culture":"en-US","RequestTimeout":"00:00:30"}
    [CredentialProvider.153721]Sending response: 'Request' 'Initialize'. Time elapsed in ms: 1
    [CredentialProvider.153721]Time elapsed in milliseconds after sending response 'Request' 'Initialize': 1
    [CredentialProvider.153721]Handling 'Request' 'GetOperationClaims'. Time elapsed in ms: 0 - Payload: {}
    [CredentialProvider.153721]Sending response: 'Request' 'GetOperationClaims'. Time elapsed in ms: 0
    [CredentialProvider.153721]Time elapsed in milliseconds after sending response 'Request' 'GetOperationClaims': 2
    [CredentialProvider.153721]Handling 'Request' 'SetLogLevel'. Time elapsed in ms: 0 - Payload: {"LogLevel":"Debug"}
    [CredentialProvider]Sending response: 'Request' 'SetLogLevel'. Time elapsed in ms: 0
    [CredentialProvider]Time elapsed in milliseconds after sending response 'Request' 'SetLogLevel': 1
    [CredentialProvider]Handling 'Request' 'GetAuthenticationCredentials'. Time elapsed in ms: 3 - Payload: {"Uri":"[https://<redacted>","IsRetry":false,"IsNonInteractive":true,"CanShowDialog":true}](<redacted>%22,%22IsRetry%22:false,%22IsNonInteractive%22:true,%22CanShowDialog%22:true%7D)
    [CredentialProvider]Creating a progress reporter with interval: 00:00:02
    [CredentialProvider]Handling auth request, Uri: <redacted>, IsRetry: False, IsNonInteractive: True, CanShowDialog: True
    [CredentialProvider]URI: <redacted>
    [CredentialProvider]VstsBuildTaskServiceEndpointCredentialProvider - This credential provider must be run under the Team Build tasks for NuGet with external endpoint credentials. Appropriate environment variable needs to be set.
    [CredentialProvider]Skipping NuGetCredentialProvider.CredentialProviders.VstsBuildTaskServiceEndpoint.VstsBuildTaskServiceEndpointCredentialProvider, cannot provide credentials for <redacted>
    [CredentialProvider]VstsBuildTaskCredentialProvider - This credential provider must be run under the Team Build tasks for NuGet. Appropriate environment variables must be set.
    [CredentialProvider]Skipping NuGetCredentialProvider.CredentialProviders.VstsBuildTask.VstsBuildTaskCredentialProvider, cannot provide credentials for <redacted>
    [CredentialProvider]VstsCredentialProvider - Matched well-known Azure DevOps Service hostname: microsoft.pkgs.visualstudio.com
    [CredentialProvider]Using NuGetCredentialProvider.CredentialProviders.Vsts.VstsCredentialProvider to try to get credentials for <redacted>.
    [CredentialProvider]IsRetry: False
    [CredentialProvider]Could not find cached SessionToken for <redacted>
    [CredentialProvider]Failed to acquire session token: System.TypeInitializationException: The type initializer for 'NuGetCredentialProvider.Util.HttpClientFactory' threw an exception. ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
  at System.Net.Http.HttpRuleParser.GetExpressionLength (System.String input, System.Int32 startIndex, System.Char openChar, System.Char closeChar, System.Boolean supportsNesting, System.Int32& nestedCount, System.Int32& length) [0x00094] in <1f0bb75ee5a64f6297b697b8820c2c83>:0
  at System.Net.Http.HttpRuleParser.GetCommentLength (System.String input, System.Int32 startIndex, System.Int32& length) [0x00002] in <1f0bb75ee5a64f6297b697b8820c2c83>:0
  at System.Net.Http.Headers.HeaderUtilities.CheckValidComment (System.String value, System.String parameterName) [0x00016] in <1f0bb75ee5a64f6297b697b8820c2c83>:0
  at System.Net.Http.Headers.ProductInfoHeaderValue..ctor (System.String comment) [0x00006] in <1f0bb75ee5a64f6297b697b8820c2c83>:0
  at Microsoft.Artifacts.Authentication.MsalHttpClientFactory.get_ClrComment () [0x00043] in <99910d855c594afa86b0e15c5e36e1df>:0
  at Microsoft.Artifacts.Authentication.MsalHttpClientFactory..ctor (System.Net.Http.HttpClient httpClient) [0x0004d] in <99910d855c594afa86b0e15c5e36e1df>:0
  at NuGetCredentialProvider.Util.HttpClientFactory..ctor (System.Net.Http.HttpClient httpClient) [0x00000] in <1ce45e86e929418d903d4f62b1872d6f>:0
  at NuGetCredentialProvider.Util.HttpClientFactory..cctor () [0x0002e] in <1ce45e86e929418d903d4f62b1872d6f>:0
   --- End of inner exception stack trace ---
  at NuGetCredentialProvider.CredentialProviders.Vsts.AuthUtil.GetResponseHeadersAsync (System.Uri uri, System.Threading.CancellationToken cancellationToken) [0x0002d] in <1ce45e86e929418d903d4f62b1872d6f>:0
  at NuGetCredentialProvider.CredentialProviders.Vsts.AuthUtil.GetAuthorizationInfoAsync (System.Uri uri, System.Threading.CancellationToken cancellationToken) [0x00074] in <1ce45e86e929418d903d4f62b1872d6f>:0
  at NuGetCredentialProvider.CredentialProviders.Vsts.VstsCredentialProvider.HandleRequestAsync (NuGet.Protocol.Plugins.GetAuthenticationCredentialsRequest request, System.Threading.CancellationToken cancellationToken) [0x0012b] in <1ce45e86e929418d903d4f62b1872d6f>:0
  at NuGetCredentialProvider.RequestHandlers.GetAuthenticationCredentialsRequestHandler.HandleRequestAsync (NuGet.Protocol.Plugins.GetAuthenticationCredentialsRequest request) [0x00283] in <1ce45e86e929418d903d4f62b1872d6f>:0
    [CredentialProvider]Sending response: 'Request' 'GetAuthenticationCredentials'. Time elapsed in ms: 15
    [CredentialProvider]Time elapsed in milliseconds after sending response 'Request' 'GetAuthenticationCredentials': 16

This is with the -NonInteractive flag. Without the flag, the same error occurs before I'm prompted for my credentials. I tried using previous versions of the netfx plugin, but no luck.

I am on a MacOS 15 using dotnet version 8.0.403. Please let me know if any more info is needed.

@embetten
Copy link
Contributor

embetten commented Nov 8, 2024

@victorlazaro - I have yet to reproduce this - which version of msbuild are you using? Thanks

@embetten embetten added the question Further information is requested label Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants