public override void ExecuteCommand() { var agent = base.Arguments[0]; var packageId = base.Arguments[1]; string defaultEmail; agent = RemoteProvider.ResolveAndValidateAgent(agent, out defaultEmail); var remoteApiKey = GetRemoteApiKey(agent, true); if (string.IsNullOrEmpty(remoteApiKey)) { throw new CommandLineException(Local.NoAgentApiKeyFound, new[] { Utility.GetRemoteDisplayName(agent) }); } //if (!System.Messaging.MessageQueue.Exists(remoteQueue)) // throw new CommandLineException(Local.NoRemoteQueueFound, new object[] { remoteQueue }); // DeployMessage.Item[] items; bool fromSpec; if (Path.GetFileName(packageId).EndsWith(PackageReferenceRepository.PackageReferenceFile, StringComparison.OrdinalIgnoreCase)) { if (IncludeDependency) { throw new CommandLineException("Message needed"); } fromSpec = true; Prerelease = true; items = DeployPackagesFromConfigFile(GetPackageReferenceFile(packageId)); if (items == null) { Console.WriteLine(Local.DeployCommandNoItemsFound, packageId); return; } } else { fromSpec = !IncludeDependency; items = new[] { new DeployMessage.Item { PackageId = packageId, Version = Version } }; } var bus = ServiceBusManager.Current; DeployReply.WaitState waitState = null; if (Wait) { waitState = new DeployReply.WaitState { Success = b => Console.WriteLine(b), Failure = () => Console.WriteLine("didn't get in time {0}, {1}", agent, packageId), } } ; bus.Send(agent, new DeployMessage { ApiKey = remoteApiKey, WantReply = Wait, FromSpec = fromSpec, Items = items, ExcludeVersion = !IncludeVersion, Prerelease = Prerelease, Email = Email ?? defaultEmail, Project = Project, }); Console.WriteLine(Local.DeployCommandSent, agent, packageId); if (waitState != null) { Console.WriteLine("Waiting for reply..."); waitState.DoWait(); } }
public override void ExecuteCommand() { var agent = Arguments[0]; var packageId = Arguments[1]; agent = RemoteProvider.ResolveAndValidateAgent(agent, out var defaultEmail); var remoteApiKey = GetRemoteApiKey(agent, true); if (string.IsNullOrEmpty(remoteApiKey)) { throw new CommandLineException(Local.NoAgentApiKeyFound, new[] { Utility.GetRemoteDisplayName(agent) }); } //if (!System.Messaging.MessageQueue.Exists(remoteQueue)) // throw new CommandLineException(Local.NoRemoteQueueFound, new object[] { remoteQueue }); // var items = GetItemsFromPackage(packageId, out var fromSpec); if (items == null) { Console.WriteLine(Local.DeployCommandNoItemsFound, packageId); return; } DeployReply.WaitState waitState = null; if (Wait) { waitState = new DeployReply.WaitState { Success = x => Console.WriteLine(x), Failure = () => Console.WriteLine($"Did not receive in time {agent}, {packageId}"), } } ; BusDispacher.Send(agent, new DeployMessage { ApiKey = remoteApiKey, WantReply = Wait, FromSpec = fromSpec, Items = items, ExcludeVersion = !IncludeVersion, Prerelease = Prerelease, Email = Email ?? defaultEmail, Project = Project, }); Console.WriteLine(Local.DeployCommandSent, agent, packageId); if (waitState != null) { Console.WriteLine("Waiting for reply..."); waitState.DoWait(); } } DeployMessage.Item[] GetItemsFromPackage(string packageId, out bool fromSpec) { if (Path.GetFileName(packageId).EndsWith(Constants.PackageReferenceFile, StringComparison.OrdinalIgnoreCase)) { if (IncludeDependency) { throw new CommandLineException("Message needed"); } fromSpec = true; Prerelease = true; return(DeployPackagesFromConfigFile(GetPackageReferenceFile(packageId))); } // single fromSpec = !IncludeDependency; return(new[] { new DeployMessage.Item { PackageId = packageId, Version = Version } }); } string GetRemoteApiKey(string remote, bool throwIfNotFound = true) { if (!string.IsNullOrEmpty(ApiKey)) { return(ApiKey); } string str = null; if (Arguments.Count > 2) { str = Arguments[2]; } if (string.IsNullOrEmpty(str)) { str = Utility.GetRemoteApiKey(Settings, remote, throwIfNotFound); } return(str); }