自定义cmdlet程序集与其他cmdlet冲突

时间:2017-09-28 10:09:53

标签: c# powershell assemblies

我正在尝试使用AWSSDK nuget包在C#中创建一个cmdlet。我发现当我在加载official AWS tools for powershell时在powershell中加载我的模块时,我遇到类似这样的错误:

Get-AWSSessionToken : Method 'CredentialsFromAssumeRoleAuthentication' in type
'Amazon.SecurityToken.AmazonSecurityTokenServiceClient' from assembly 'AWSSDK.SecurityToken, Version=3.3.0.0,
Culture=neutral, PublicKeyToken=885c28607f98e604' does not have an implementation.
At line:1 char:1
+ Get-AWSSessionToken 646634
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-AWSSessionToken], TypeLoadException
    + FullyQualifiedErrorId : System.TypeLoadException,Get_AWSSessionToken.GetAWSSessionTokenCmdlet

我认为这是由于2个模块使用不同版本的AWS组件在加载时互相覆盖,但我可能错了。

我尝试使用Costura将AWS dll打包到我的程序集中,但这并没有帮助。

以下是我的模块清单:

# Module manifest for module 'AWSSessionToken'
@{
RootModule = 'Get-AWSSessionToken.dll'
ModuleVersion = '1.0'
GUID = '6aff26a7-8573-43a1-919c-683dc2e32394'
Author = 'George Richardson'
CompanyName = 'foo'
Copyright = '(c) 2017 george.richardson. All rights reserved.'
Description = 'Allow generation of session tokens for AWS using MFA'
RequiredAssemblies = @('AWSSDK.Core.dll', 'AWSSDK.SecurityToken.dll')
}

0 个答案:

没有答案