public async Task <IEnumerable <string> > ListRefsAsync(string ownerName, string repositoryName, RefType?type, CancellationToken cancellationToken) { var prefix = AH.Switch <RefType?, string>(type) .Case(null, "refs") .Case(RefType.Branch, "refs/heads") .Case(RefType.Tag, "refs/tags") .End(); var refs = await this.InvokePagesAsync("GET", $"{this.apiBaseUrl}/repos/{Esc(ownerName)}/{Esc(repositoryName)}/git/{prefix}", cancellationToken).ConfigureAwait(false); return(refs.Cast <Dictionary <string, object> >().Select(r => trim((string)r["ref"]))); string trim(string s) { if (s.StartsWith(prefix)) { s = s.Substring(prefix.Length); } if (s.StartsWith("/")) { s = s.Substring(1); } return(s); } }
public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config) { var credentialName = config["CredentialName"]; var feedName = config["FeedName"]; if (string.IsNullOrEmpty(credentialName) || string.IsNullOrEmpty(feedName)) { return(Enumerable.Empty <string>()); } ProGetClient client = null; var productCredentials = ResourceCredentials.TryCreate <InedoProductCredentials>(credentialName); if (productCredentials != null) { client = new ProGetClient(productCredentials.Host, feedName, "api", AH.Unprotect(productCredentials.ApiKey)); } if (client == null) { #pragma warning disable CS0618 // Type or member is obsolete var credentials = ResourceCredentials.Create <ProGetCredentials>(credentialName); #pragma warning restore CS0618 // Type or member is obsolete client = new ProGetClient(credentials.Url, feedName, credentials.UserName, AH.Unprotect(credentials.Password)); } var packages = await client.GetPackagesAsync().ConfigureAwait(false); return(from p in packages let name = new PackageName(p.@group, p.name) orderby name.Group, name.Name select name.ToString()); }
public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config) { var credentialName = config[nameof(IHasCredentials.CredentialName)]; if (string.IsNullOrEmpty(credentialName)) { return(Enumerable.Empty <string>()); } var credentials = ResourceCredentials.Create <GitHubCredentials>(credentialName); string ownerName = AH.CoalesceString(credentials.OrganizationName, credentials.UserName); if (string.IsNullOrEmpty(ownerName)) { return(Enumerable.Empty <string>()); } var client = new GitHubClient(credentials.ApiUrl, credentials.UserName, credentials.Password, credentials.OrganizationName); var orgs = await client.GetOrganizationsAsync(CancellationToken.None).ConfigureAwait(false); var names = from m in orgs let name = m["login"]?.ToString() where !string.IsNullOrEmpty(name) select name; return(names); }
public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config) { var credentialName = config["CredentialName"]; if (string.IsNullOrEmpty(credentialName)) { return(Enumerable.Empty <string>()); } var productCredentials = ResourceCredentials.TryCreate <InedoProductCredentials>(credentialName); if (productCredentials != null) { var url = new Uri(productCredentials.Host, UriKind.Absolute).GetLeftPart(UriPartial.Authority); var c = new ProGetClient(url, null, "api", AH.Unprotect(productCredentials.ApiKey)); return(await c.GetFeedNamesAsync().ConfigureAwait(false)); } #pragma warning disable CS0618 // Type or member is obsolete var credentials = ResourceCredentials.Create <ProGetCredentials>(credentialName); #pragma warning restore CS0618 // Type or member is obsolete string baseUrl = new Uri(credentials.Url, UriKind.Absolute).GetLeftPart(UriPartial.Authority); var client = new ProGetClient(baseUrl, null, credentials.UserName, AH.Unprotect(credentials.Password)); return(await client.GetFeedNamesAsync().ConfigureAwait(false)); }
private static object ConvertValue(object value, Type targetType) { if (value == null) { return(null); } var sourceType = value.GetType(); if (targetType.IsAssignableFrom(sourceType)) { return(value); } if (targetType == typeof(string)) { if (value is SecureString secure) { return(AH.Unprotect(secure)); } else { return(value.ToString()); } } else if (targetType == typeof(SecureString)) { return(AH.CreateSecureString(value.ToString())); } else { throw new NotSupportedException($"Type {sourceType.Name} cannot be converted to {targetType.Name} in resource credential target."); } }
public ArtandHistory(Model model) { InitializeComponent(); for (int index = 0; index < model.AHs.Count(); index++) { AH temp = model.AHs[index]; App1.smallview.AHsmall temp1 = new smallview.AHsmall(temp); innerOne.Children.Add(temp1); } searchBar.TextChanged += (sender, args) => { string temp = searchBar.Text; StackLayout temp2 = new StackLayout(); List <AH> temp1 = model.AHs; for (int index = 0; index < temp1.Count; index++) { if (temp1[index].contain(temp)) { temp2.Children.Add(new smallview.AHsmall(temp1[index])); } } scrollview.Content = temp2; }; searchBar.Focused += (sender, args) => { }; }
public override async Task <PersistedConfiguration> CollectAsync(IOperationCollectionContext context) { var github = new GitHubClient(this.Template.ApiUrl, this.Template.UserName, this.Template.Password, this.Template.OrganizationName); var ownerName = AH.CoalesceString(this.Template.OrganizationName, this.Template.UserName); var release = await github.GetReleaseAsync(ownerName, this.Template.RepositoryName, this.Template.Tag, context.CancellationToken); if (release == null) { return(new GitHubReleaseConfiguration { Exists = false }); } return(new GitHubReleaseConfiguration { Tag = (string)release["tag_name"], Target = (string)release["target_commitish"], Title = (string)release["name"], Description = (string)release["body"], Draft = (bool)release["draft"], Prerelease = (bool)release["prerelease"] }); }
public override ActionBase CreateFromForm() { var action = new HttpPostAction { HttpMethod = this.ddlHttpMethod.SelectedValue, Url = this.txtUrl.Text, LogResponseBody = this.chkLogResponseBody.Checked, SaveResponseBodyAsVariable = this.chkSaveResponseBodyInVariable.Checked, ErrorStatusCodes = StatusCodeRangeList.Parse(this.txtErrorStatusCodes.Text).ToString(), LogRequestData = this.chkLogContent.Checked }; if (this.chkRawInput.Checked) { action.PostData = this.txtBody.Text; action.ContentType = AH.NullIf(this.txtContentType.Text, string.Empty); } else { action.FormData = (from f in this.ctlFormData.Value.Split('&') where !string.IsNullOrEmpty(f) let p = f.Split(new[] { '=' }, 2) where p.Length == 2 let k = Uri.UnescapeDataString(p[0]).Trim() let v = Uri.UnescapeDataString(p[1]).Trim() where !string.IsNullOrEmpty(k) select new KeyValuePair <string, string>(k, v)).ToList(); } return(action); }
private AwsSecureCredentials GetCredentials(ICredentialResolutionContext context) { AwsSecureCredentials credentials; if (string.IsNullOrEmpty(this.CredentialName)) { credentials = this.AccessKey == null ? null : new AwsSecureCredentials(); } else { credentials = SecureCredentials.TryCreate(this.CredentialName, context) as AwsSecureCredentials; if (credentials == null) { var rc = SecureCredentials.TryCreate(this.CredentialName, context) as AwsLegacyCredentials; credentials = rc?.ToSecureCredentials() as AwsSecureCredentials; } } if (credentials != null) { credentials.AccessKeyId = AH.CoalesceString(this.AccessKey, credentials.AccessKeyId); credentials.SecretAccessKey = !string.IsNullOrWhiteSpace(this.SecretAccessKey) ? AH.CreateSecureString(this.SecretAccessKey) : credentials.SecretAccessKey; } return(credentials); }
private HttpWebRequest CreateWebRequest(string url, PackageDeploymentData deployInfo = null, SecureString apiKey = null) { var request = WebRequest.CreateHttp(url); request.KeepAlive = false; request.AllowReadStreamBuffering = false; request.AllowWriteStreamBuffering = false; request.Timeout = Timeout.Infinite; request.UserAgent = $"{SDK.ProductName}/{SDK.ProductVersion} InedoCore/{typeof(ProGetClient).Assembly.GetName().Version}"; if (apiKey != null) { request.Headers.Add("X-ApiKey", AH.Unprotect(apiKey)); } if (!string.IsNullOrWhiteSpace(this.UserName)) { request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(InedoLib.UTF8Encoding.GetBytes(this.UserName + ":" + this.Password))); } if (deployInfo != null) { request.Headers.Add(PackageDeploymentData.Headers.Application, deployInfo.Application ?? string.Empty); request.Headers.Add(PackageDeploymentData.Headers.Description, deployInfo.Description ?? string.Empty); request.Headers.Add(PackageDeploymentData.Headers.Url, deployInfo.Url ?? string.Empty); request.Headers.Add(PackageDeploymentData.Headers.Target, deployInfo.Target ?? string.Empty); } return(request); }
public static PackageDeploymentData Create(IOperationExecutionContext context, ILogSink log, string description) { string baseUrl = SDK.BaseUrl; if (string.IsNullOrEmpty(baseUrl)) { log.LogDebug("Deployment will not be recorded in ProGet because the System.BaseUrl configuration setting is not set."); return(null); } string serverName = AH.CoalesceString(context?.ServerName, Environment.MachineName); string relativeUrl; if (SDK.ProductName == "BuildMaster") { relativeUrl = context.ExpandVariables($"applications/{((IStandardContext)context).ProjectId}/builds/build?releaseNumber=$UrlEncode($ReleaseNumber)&buildNumber=$UrlEncode($PackageNumber)").AsString(); } else if (SDK.ProductName == "Hedgehog") { relativeUrl = "deployment-sets/details?deploymentSetId=" + ((IStandardContext)context).DeploymentSetId; } else { relativeUrl = "executions/execution-in-progress?executionId=" + context.ExecutionId; } return(new PackageDeploymentData(SDK.ProductName, baseUrl, relativeUrl, serverName, description)); }
private static SmtpClient CreateSmtpClient() { string host = SDK.GetConfigValue("Smtp.Host"); int? port = AH.ParseInt(SDK.GetConfigValue("Smtp.Port")); bool? ssl = bool.TryParse(SDK.GetConfigValue("Smtp.SslEnabled"), out bool s) ? s : (bool?)null; string username = SDK.GetConfigValue("Smtp.UserName"); string password = SDK.GetConfigValue("Smtp.Password"); if (string.IsNullOrEmpty(host) || port == null || ssl == null) { return(null); } SmtpClient client = null; try { client = new SmtpClient(host, port.Value); client.EnableSsl = ssl.Value; client.UseDefaultCredentials = false; // login to mail server anonymously if no username/password specified if (!string.IsNullOrEmpty(username)) { client.Credentials = new NetworkCredential(username, password); } return(client); } catch { client?.Dispose(); return(null); } }
protected override async Task <object> RemoteExecuteAsync(IRemoteOperationExecutionContext context) { this.LogInformation($"Downloading TFS artifact {this.ArtifactName} with build number \"{this.BuildNumber ?? "latest"}\" from TFS..."); var downloader = new ArtifactDownloader(this, this); using (var artifact = await downloader.DownloadAsync(this.TeamProject, this.BuildNumber, this.BuildDefinition, this.ArtifactName).ConfigureAwait(false)) { string targetDirectory = context.ResolvePath(this.TargetDirectory); if (this.ExtractFilesToTargetDirectory) { this.LogDebug("Extracting artifact files to: " + targetDirectory); AH.ExtractZip(artifact.Content, targetDirectory); } else { string path = PathEx.Combine(targetDirectory, artifact.FileName); this.LogDebug("Saving artifact as zip file to: " + path); using (var file = FileEx.Open(path, FileMode.Create, FileAccess.Write, FileShare.None, FileOptions.Asynchronous | FileOptions.SequentialScan)) { await artifact.Content.CopyToAsync(file).ConfigureAwait(false); } } } this.LogInformation("Artifact downloaded."); return(null); }
public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config) { var credentialName = config["CredentialName"]; if (string.IsNullOrEmpty(credentialName)) { return(Enumerable.Empty <string>()); } var credentials = ResourceCredentials.Create <GitLabCredentials>(credentialName); string ownerName = AH.CoalesceString(credentials.GroupName, credentials.UserName); string repositoryName = AH.CoalesceString(config["ProjectName"], credentials.ProjectName); if (string.IsNullOrEmpty(ownerName) || string.IsNullOrEmpty(repositoryName)) { return(Enumerable.Empty <string>()); } var client = new GitLabClient(credentials.ApiUrl, credentials.UserName, credentials.Password, credentials.GroupName); var milestones = await client.GetMilestonesAsync(repositoryName, "open", CancellationToken.None).ConfigureAwait(false); var titles = from m in milestones let title = m["title"]?.ToString() where !string.IsNullOrEmpty(title) select title; if (SDK.ProductName == "BuildMaster") { titles = new[] { "$ReleaseName", "$ReleaseNumber" }.Concat(titles); } return(titles); }
protected override ExtendedRichDescription GetDescription(IOperationConfiguration config) { return(new ExtendedRichDescription( new RichDescription("Close GitHub issue #", new Hilite(config[nameof(IssueNumber)])), new RichDescription("in ", new Hilite(AH.CoalesceString(config[nameof(RepositoryName)], config[nameof(CredentialName)]))) )); }
public override RichDescription GetDescription() { return(new RichDescription( "Git repository at ", new Hilite(AH.CoalesceString(this.RepositoryUrl, this.CredentialName)) )); }
public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config) { var credentialName = config["CredentialName"]; var projectName = AH.CoalesceString(config["TeamProject"], config["TeamProjectName"]); var definitionName = config["BuildDefinition"]; if (string.IsNullOrEmpty(credentialName) || string.IsNullOrEmpty(projectName) || string.IsNullOrEmpty(definitionName)) { return(Enumerable.Empty <string>()); } var credentials = ResourceCredentials.Create <TfsCredentials>(credentialName); var api = new TfsRestApi(credentials, null); var definition = await api.GetBuildDefinitionAsync(projectName, definitionName).ConfigureAwait(false); if (definition == null) { return(Enumerable.Empty <string>()); } var builds = await api.GetBuildsAsync(projectName, definition.id).ConfigureAwait(false); return(builds.Select(b => b.buildNumber)); }
public void Initialize() { string asmDir = PathEx.GetDirectoryName(typeof(GitTests).Assembly.Location); this.rootDir = PathEx.Combine(asmDir, "test-root"); DirectoryEx.Create(this.rootDir); DirectoryEx.Clear(this.rootDir); if (FileEx.Exists(credentialsFilePath)) { var lines = File.ReadAllLines(credentialsFilePath); this.userName = lines[0]; this.password = AH.CreateSecureString(lines[1]); } var fileOps = new TestFileOperationsExecuter(Path.Combine(this.rootDir, "agent")); //var fileOps = new SimulatedFileOperationsExecuter(fileOps); //fileOps.MessageLogged += (s, e) => TestLogger.Instance.Log(e.Level, e.Message); this.fileOps = fileOps; this.processExecuter = new TestRemoteProcessExecuter(); this.jobExecuter = new TestRemoteJobExecuter(); }
public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config) { var credentialName = config["CredentialName"]; var jobName = config["JobName"]; if (string.IsNullOrEmpty(credentialName) || string.IsNullOrEmpty(jobName)) { return(Enumerable.Empty <string>()); } var branchName = config["BranchName"]; int?projectId = AH.ParseInt(AH.CoalesceString(config["ProjectId"], config["ApplicationId"])); int?environmentId = AH.ParseInt(config["EnvironmentId"]); var credentials = (JenkinsLegacyCredentials)ResourceCredentials.TryCreate(JenkinsLegacyCredentials.TypeName, credentialName, environmentId: environmentId, applicationId: projectId, inheritFromParent: false); if (credentials == null) { return(Enumerable.Empty <string>()); } using (var cts = new CancellationTokenSource(new TimeSpan(0, 0, 30))) { var client = this.CreateClient(config, cts.Token); return(await client.GetBuildNumbersAsync(jobName, branchName).ConfigureAwait(false)); } }
protected override ExtendedRichDescription GetDescription(IOperationConfiguration config) { return(new ExtendedRichDescription( new RichDescription("HTTP ", AH.CoalesceString(config[nameof(this.Method)], "POST")), new RichDescription("to ", new Hilite(config[nameof(this.Url)])) )); }
public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config) { var credentialName = config["CredentialName"]; if (string.IsNullOrEmpty(credentialName)) { return(Enumerable.Empty <string>()); } var credentials = ResourceCredentials.Create <GitLabCredentials>(credentialName); string ownerName = AH.CoalesceString(credentials.GroupName, credentials.UserName); if (string.IsNullOrEmpty(ownerName)) { return(Enumerable.Empty <string>()); } var client = new GitLabClient(credentials.ApiUrl, credentials.UserName, credentials.Password, credentials.GroupName); var repos = await client.GetProjectsAsync(CancellationToken.None).ConfigureAwait(false); var names = from m in repos let name = m["path_with_namespace"]?.ToString() where !string.IsNullOrEmpty(name) select name; if (SDK.ProductName == "BuildMaster") { names = new[] { $"{ownerName}/$ApplicationName" }.Concat(names); } return(names); }
public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config) { var credentialName = config["CredentialName"]; var feedName = config["FeedName"]; var packageName = config["PackageName"]; if (string.IsNullOrEmpty(credentialName) || string.IsNullOrEmpty(feedName) || string.IsNullOrEmpty(packageName)) { return(Enumerable.Empty <string>()); } ProGetClient client = null; var productCredentials = ResourceCredentials.TryCreate <InedoProductCredentials>(credentialName); if (productCredentials != null) { client = new ProGetClient(productCredentials.Host, feedName, "api", AH.Unprotect(productCredentials.ApiKey)); } #pragma warning disable CS0618 // Type or member is obsolete var credentials = ResourceCredentials.Create <ProGetCredentials>(credentialName); #pragma warning restore CS0618 // Type or member is obsolete if (client == null) { client = new ProGetClient(credentials.Url, feedName, credentials.UserName, AH.Unprotect(credentials.Password)); } var package = await client.GetPackageInfoAsync(PackageName.Parse(packageName)); return(new[] { "latest", "latest-stable" }.Concat(package.versions)); }
internal static GitLabCredentials TryCreate(string name, IOperationConfiguration config) { int?projectId = AH.ParseInt(AH.CoalesceString(config["ProjectId"], config["ApplicationId"])); int?environmentId = AH.ParseInt(config["EnvironmentId"]); return((GitLabCredentials)ResourceCredentials.TryCreate(GitLabCredentials.TypeName, name, environmentId: environmentId, applicationId: projectId, inheritFromParent: false)); }
public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config) { var credentialName = config["CredentialName"]; var jobName = config["JobName"]; if (string.IsNullOrEmpty(credentialName) || string.IsNullOrEmpty(jobName)) { return(Enumerable.Empty <string>()); } var branchName = config["BranchName"]; string buildNumber = AH.CoalesceString(config["BuildNumber"], "lastSuccessfulBuild"); int?projectId = AH.ParseInt(AH.CoalesceString(config["ProjectId"], config["ApplicationId"])); int?environmentId = AH.ParseInt(config["EnvironmentId"]); var credentials = (JenkinsLegacyCredentials)ResourceCredentials.TryCreate(JenkinsLegacyCredentials.TypeName, credentialName, environmentId: environmentId, applicationId: projectId, inheritFromParent: false); if (credentials == null) { return(Enumerable.Empty <string>()); } using (var cts = new CancellationTokenSource(new TimeSpan(0, 0, 30))) { var client = new JenkinsClient(credentials.UserName, credentials.Password, credentials.ServerUrl, false, null, cts.Token); return((await client.GetBuildArtifactsAsync(jobName, branchName, buildNumber)) .Select(a => a.RelativePath) .ToList()); } }
public ActiveDirectoryUser(ADUserDirectory directory, UserId userId, string displayName, string emailAddress) { this.directory = directory; this.userId = userId ?? throw new ArgumentNullException(nameof(userId)); this.DisplayName = AH.CoalesceString(displayName, userId.Principal); this.EmailAddress = emailAddress; }
protected override ExtendedRichDescription GetDescription(IOperationConfiguration config) { return(new ExtendedRichDescription( new RichDescription("Create issue titled ", new Hilite(config[nameof(Title)])), new RichDescription("in ", new Hilite(AH.CoalesceString(config[nameof(ProjectName)], config[nameof(CredentialName)]))) )); }
public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config) { string ownerName = AH.CoalesceString(config[nameof(GitHubCredentials.OrganizationName)], config[nameof(GitHubCredentials.UserName)]); if (string.IsNullOrEmpty(ownerName)) { return(Enumerable.Empty <string>()); } GitHubClient client; try { client = new GitHubClient(config[nameof(GitHubCredentials.ApiUrl)], config[nameof(GitHubCredentials.UserName)], AH.CreateSecureString(config[nameof(GitHubCredentials.Password)].ToString()), config[nameof(GitHubCredentials.OrganizationName)]); } catch (InvalidOperationException) { return(Enumerable.Empty <string>()); } var orgs = await client.GetOrganizationsAsync(CancellationToken.None).ConfigureAwait(false); var names = from m in orgs let name = m["login"]?.ToString() where !string.IsNullOrEmpty(name) select name; return(names); }
private async Task <object> InvokeAsync(string method, string uri, object data, bool allPages, CancellationToken cancellationToken) { var request = WebRequest.CreateHttp(uri); request.UserAgent = "InedoGitLabExtension/" + typeof(GitLabClient).Assembly.GetName().Version.ToString(); request.Method = method; if (!string.IsNullOrEmpty(this.UserName)) { request.Headers["PRIVATE-TOKEN"] = AH.Unprotect(this.Password); } using (cancellationToken.Register(() => request.Abort())) { if (data != null) { using (var requestStream = await request.GetRequestStreamAsync().ConfigureAwait(false)) using (var writer = new StreamWriter(requestStream, InedoLib.UTF8Encoding)) { await writer.WriteAsync(jsonSerializer.Serialize(data)).ConfigureAwait(false); } } try { using (var response = await request.GetResponseAsync().ConfigureAwait(false)) using (var responseStream = response.GetResponseStream()) using (var reader = new StreamReader(responseStream, InedoLib.UTF8Encoding)) { string responseText = await reader.ReadToEndAsync().ConfigureAwait(false); var responseJson = jsonSerializer.DeserializeObject(responseText); if (allPages) { var nextPage = NextPageLinkPattern.Match(response.Headers["Link"] ?? ""); if (nextPage.Success) { responseJson = ((IEnumerable <object>)responseJson).Concat((IEnumerable <object>)await this.InvokeAsync(method, nextPage.Groups["uri"].Value, data, true, cancellationToken).ConfigureAwait(false)); } } return(responseJson); } } catch (WebException ex) when(ex.Status == WebExceptionStatus.RequestCanceled) { cancellationToken.ThrowIfCancellationRequested(); throw; } catch (WebException ex) when(ex.Response != null) { using (var responseStream = ex.Response.GetResponseStream()) using (var reader = new StreamReader(responseStream, InedoLib.UTF8Encoding)) { string message = await reader.ReadToEndAsync().ConfigureAwait(false); throw new Exception(message, ex); } } } }
protected override void Execute() { int?seconds = AH.ParseInt(this.SecondsToSleep); if (seconds == null) { this.LogError("The specified number of seconds to sleep \"{0}\", does not evaluate to a valid number of seconds.", this.SecondsToSleep); return; } this.LogInformation("Execution halted for {0} second{1}...", this.SecondsToSleep, seconds == 1 ? "" : "s"); for (int i = (int)seconds; i > 0; i--) { this.ThrowIfCanceledOrTimeoutExpired(); if (i <= 15) { this.LogDebug("Resume in {0}s...", i); } else if (i < 60 && i % 10 == 0) { this.LogDebug("Resume in {0}s...", i); } else if (i % 60 == 0) { this.LogDebug("Resume in {0}m...", i / 60); } this.Context.CancellationToken.WaitHandle.WaitOne(1000); } this.LogInformation("Execution resumed."); }
public ConvertedOperation <CreatePackageOperation> ConvertActionToOperation(CreatePackage action, IActionConverterContext context) { List <string> properties = null; if (action.Properties?.Length > 0) { properties = new List <string>(action.Properties.Length); foreach (var p in action.Properties) { properties.Add(context.ConvertLegacyExpression(p)); } } return(new CreatePackageOperation { SourceDirectory = AH.NullIf(context.ConvertLegacyExpression(action.OverriddenSourceDirectory), string.Empty), OutputDirectory = AH.NullIf(context.ConvertLegacyExpression(action.OverriddenTargetDirectory), string.Empty), Build = action.Build, IncludeReferencedProjects = action.IncludeReferencedProjects, ProjectPath = context.ConvertLegacyExpression(action.ProjectPath), Symbols = action.Symbols, Verbose = action.Verbose, Version = AH.NullIf(context.ConvertLegacyExpression(action.Version), string.Empty), Properties = properties }); }