public static KuduWebProjectDetails Create(string name, string type, string projectFilePath) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException(nameof(name)); } if (string.IsNullOrWhiteSpace(type)) { throw new ArgumentNullException(nameof(type)); } if (string.IsNullOrWhiteSpace(projectFilePath)) { throw new ArgumentNullException(nameof(projectFilePath)); } var webJobProject = new KuduWebProjectDetails( true, ParseName(name), KuduWebJobType.Parse(type), projectFilePath); return(webJobProject); }
private KuduWebProjectDetails IsKuduWebJobProject(FileInfo file) { KuduWebProjectDetails kuduWebJobProject = null; const string kuduWebJobName = "KuduWebJobName"; const string kuduWebJobType = "KuduWebJobType"; var expectedKeys = new List <string> { kuduWebJobName, kuduWebJobType }; var foundItems = new Dictionary <string, string>(); using (FileStream fs = file.OpenRead()) { using (var streamReader = new StreamReader(fs)) { while (streamReader.Peek() >= 0) { string line = streamReader.ReadLine(); if (line != null) { expectedKeys.ForEach(key => { if (line.IndexOf( key, StringComparison.InvariantCultureIgnoreCase) >= 0) { if (!foundItems.ContainsKey(key)) { foundItems.Add(key, line); } else { string existingValue = foundItems[key]; if (!existingValue.Equals(line, StringComparison.InvariantCultureIgnoreCase)) { _logger.WriteWarning( $"A Kudu web job key '{key}' has already been found with value '{existingValue}', new value is different '{line}', using first value"); } } } }); if (foundItems.Count == expectedKeys.Count) { kuduWebJobProject = KuduWebProjectDetails.Create( foundItems[kuduWebJobName], foundItems[kuduWebJobType], file.FullName); break; } } } } } return(kuduWebJobProject ?? KuduWebProjectDetails.NotAKuduWebJobProject()); }