Skip to content

Get-VstsTfsClientCredentials -OMDirectory $dir needs binding redirect for NewtonsoftJson on VS2019 #580

@jessehouwing

Description

@jessehouwing

Environment

azure-pipelines-task-lib version: 0.11 PowerShell

Issue Description

When calling get-vststfsclientcredentials on a VS2019 hosted agent, it fails to load with a newtonsoft.json binding issue.
It looks like other functions were patched with a assembly resolver. But this function fails.

It works when pointing to a VS2015OM or a VS2017 OM. It fails when pointing to a VS2019OM.

Expected behaviour

credentials are returned.

Actual behaviour

##[debug]Get-VstsTfsClientCredentials : Exception calling ".ctor" with "1" argument(s): "Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified."
##[debug]At D:\a\_tasks\tf-vc-add_2ef90ef1-5298-4f6a-8b99-12933fed4de4\2.0.7\ps_modules\VstsTfvcShared\VstsTfvcShared.psm1:114 char:29
##[debug]+ ... edentials = Get-VstsTfsClientCredentials -OMDirectory $(Find-VisualSt ...
##[debug]+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
##[debug]    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
##[debug]    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-VstsTfsClientCredentials
##[debug] 
##[debug]Script stack trace:
##[debug]at Get-TfsClientCredentials, D:\a\_tasks\tf-vc-add_2ef90ef1-5298-4f6a-8b99-12933fed4de4\2.0.7\ps_modules\VstsTaskSdk\ServerOMFunctions.ps1: line 152
##[debug]at Get-TfsTeamProjectCollection, D:\a\_tasks\tf-vc-add_2ef90ef1-5298-4f6a-8b99-12933fed4de4\2.0.7\ps_modules\VstsTfvcShared\VstsTfvcShared.psm1: line 114
##[debug]at Get-SourceProvider, D:\a\_tasks\tf-vc-add_2ef90ef1-5298-4f6a-8b99-12933fed4de4\2.0.7\ps_modules\VstsTfvcShared\VstsTfvcShared.psm1: line 137
##[debug]at <ScriptBlock>, D:\a\_tasks\tf-vc-add_2ef90ef1-5298-4f6a-8b99-12933fed4de4\2.0.7\TfvcAdd.v3.ps1: line 37
##[debug]at <ScriptBlock>, <No file>: line 1
##[debug]at <ScriptBlock>, <No file>: line 22
##[debug]at <ScriptBlock>, <No file>: line 18
##[debug]at <ScriptBlock>, <No file>: line 1
##[debug]Exception:
##[debug]Microsoft.PowerShell.Commands.WriteErrorException: Exception calling ".ctor" with "1" argument(s): "Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified."
##[error]Exception calling ".ctor" with "1" argument(s): "Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified."
##[debug]Processed: ##vso[task.logissue type=error]Exception calling ".ctor" with "1" argument(s): "Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified."
##[debug]Processed: ##vso[task.complete result=Failed]

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions