Это очень специфическая ошибка, я провел последние несколько дней, исследуя ее, но зашел в тупик.
Задача в моем скрипте сборки тортов - проверить, готова ли среда эластичных бобов. Мы использовали это дополнение (https://github.com/mathieukempe/Cake.AWS.ElasticBeanstalk). Я разветвил репозиторий, чтобы добавить реализацию DescribeEnvironments (). Код расширения работает, если я запускаю его непосредственно в консольном приложении. Однако, когда я запускаю его из скрипта сборки торта, он броски System.MissingMethodException: Method not found: 'System.String Amazon.Runtime.Internal.Util.StringUtils.FromDateTimeToISO8601(System.DateTime)'
и, к сожалению, я думаю, что я единственный человек в Интернете, имеющий эту проблему.
Ниже приведена задача, выполняемая моим скриптом:
Task("CheckEBEnvironment")
.Does((context) => {
var settings = CreateElasticBeanstalkSettings();
if (context.ApplicationVersionReady(settings, ebApplication, ebEnvironment, ebVersion)) {
Information("Environment ready.");
isReady = true;
} else {
Information("Environment not ready...");
}
});
и ниже - дополнительный код:
[CakeAliasCategory("AWS")]
[CakeNamespaceImport("Amazon")]
[CakeNamespaceImport("Amazon.ElasticBeanstalk")]
public static class ElasticBeanstalkAliases
{
private static IElasticBeanstalkManager CreateManager(this ICakeContext context)
{
return new ElasticBeanstalkManager(context.Environment, context.Log);
}
// ...
[CakeMethodAlias]
[CakeAliasCategory("ElasticBeanstalk")]
public static bool ApplicationVersionReady(this ICakeContext context, ElasticBeanstalkSettings settings, string applicationName, string environmentName, string versionLabel)
{
var manager = context.CreateManager();
return manager.ApplicationVersionReady(settings, applicationName, environmentName, versionLabel);
}
}
Вот реализация:
public class ElasticBeanstalkManager : IElasticBeanstalkManager
{
private readonly ICakeEnvironment _Environment;
private readonly ICakeLog _Log;
/// <summary>
/// If the manager should output progrtess events to the cake log
/// </summary>
public bool LogProgress { get; set; }
public ElasticBeanstalkManager(ICakeEnvironment environment, ICakeLog log)
{
if (environment == null)
{
throw new ArgumentNullException("environment");
}
if (log == null)
{
throw new ArgumentNullException("log");
}
_Environment = environment;
_Log = log;
this.LogProgress = true;
}
//Request
private AmazonElasticBeanstalkClient GetClient(ElasticBeanstalkSettings settings)
{
if (settings == null)
{
throw new ArgumentNullException("settings");
}
if (settings.Region == null)
{
throw new ArgumentNullException("settings.Region");
}
if (settings.Credentials == null)
{
if (String.IsNullOrEmpty(settings.AccessKey))
{
throw new ArgumentNullException("settings.AccessKey");
}
if (String.IsNullOrEmpty(settings.SecretKey))
{
throw new ArgumentNullException("settings.SecretKey");
}
return new AmazonElasticBeanstalkClient(settings.AccessKey, settings.SecretKey, settings.Region);
}
else
{
return new AmazonElasticBeanstalkClient(settings.Credentials, settings.Region);
}
}
public bool ApplicationVersionReady(ElasticBeanstalkSettings settings, string applicationName, string environmentName, string versionLabel)
{
if (string.IsNullOrEmpty(applicationName))
{
throw new ArgumentNullException(nameof(applicationName));
}
if (string.IsNullOrEmpty(environmentName))
{
throw new ArgumentNullException(nameof(environmentName));
}
if (string.IsNullOrEmpty(versionLabel))
{
throw new ArgumentNullException(nameof(versionLabel));
}
var client = GetClient(settings);
var status = client.DescribeEnvironmentsAsync(new DescribeEnvironmentsRequest
{
ApplicationName = applicationName,
EnvironmentNames = new List<string>(new[] {environmentName}),
VersionLabel = versionLabel,
IncludeDeleted = false,
}).Result.Environments[0].Status.Value;
return status == "Ready";
}
}
Вот полное сообщение об исключении:
System.AggregateException: произошла одна или несколько ошибок. ---> System.MissingMethodException: метод не найден: 'System.String Amazon.Runtime.Internal.Util.StringUtils.FromDateTimeToISO8601 (System.DateTime)'.
в Amazon.ElasticBeanstalk.Model.Internal.MarshallTransformations.DescribeEnvironmentsRequestMarshaller.Marshall (DescribeEnvironmentsRequest publicRequest)
в Amazon.Runtime.Internal.Marshaller.PreInvoke (IExecutionContext executeContext)
в Amazon.Runtime.Internal.Marshaller.InvokeAsync [T] (IExecutionContext executeContext)
в Amazon.Runtime.Internal.CallbackHandler.d__9 1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Amazon.Runtime.Internal.ErrorCallbackHandler.<InvokeAsync>d__5
1.MoveNext ()
--- Конец стека трассировки от предыдущего местоположения, где было сгенерировано исключение ---
в System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw ()
в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Задача)
at Amazon.Runtime.Internal.MetricsHandler.d__1 1.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task
1.GetResultCore (логическое ожидание завершения уведомления)
в Cake.AWS.ElasticBeanstalk.ElasticBeanstalkManager.ApplicationVersionReady (настройки ElasticBeanstalkSettings, String applicationName, String environmentName, String versionLabel)
в представлении № 0. <> b__0_11 (контекст ICakeContext)
---> (Внутреннее исключение # 0) System.MissingMethodException: метод не найден: 'System.String Amazon.Runtime.Internal.Util.StringUtils.FromDateTimeToISO8601 (System.DateTime)'.
в Amazon.ElasticBeanstalk.Model.Internal.MarshallTransformations.DescribeEnvironmentsRequestMarshaller.Marshall (DescribeEnvironmentsRequest publicRequest)
в Amazon.Runtime.Internal.Marshaller.PreInvoke (IExecutionContext executeContext)
в Amazon.Runtime.Internal.Marshaller.InvokeAsync [T] (IExecutionContext executeContext)
в Amazon.Runtime.Internal.CallbackHandler.d__9 1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Amazon.Runtime.Internal.ErrorCallbackHandler.<InvokeAsync>d__5
1.MoveNext ()
--- Конец стека трассировки от предыдущего местоположения, где было сгенерировано исключение ---
в System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw ()
в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Задача)
в Amazon.Runtime.Internal.MetricsHandler.d__1`1.MoveNext () <--- </p>
Я предполагаю, что контекст торта где-то задает время даты для запроса, который находится в формате, который Amazon не может обработать. Если у кого-то возникнут какие-либо идеи или возникнет аналогичная проблема, я был бы очень признателен.