Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 38 additions & 24 deletions src/ADOGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@
.Replace("bin\\Debug\\net8.0", "")
.Replace("bin\\Release\\net8.0", "")
.Replace("bin\\Debug", "")
.Replace("bin\\Release", "");
.Replace("bin\\Release", "")
.Replace("ADOGenerator\\", "ADOGenerator\\");

do
{
if (currentPath.EndsWith("ADOGenerator"))
currentPath = currentPath + "\\";
string id = Guid.NewGuid().ToString().Split('-')[0];
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("Do you want to create a new template or create a new project using the demo generator project template?");
Expand Down Expand Up @@ -99,36 +102,39 @@
Environment.Exit(0);

} while (true);
return 0;

Check warning on line 105 in src/ADOGenerator/Program.cs

View workflow job for this annotation

GitHub Actions / build

Unreachable code detected

Check warning on line 105 in src/ADOGenerator/Program.cs

View workflow job for this annotation

GitHub Actions / build

Unreachable code detected

void HandleTemplateAndArtifactsUpdate(string template, string id, Project model, string currentPath)
{
var templatePathBin = Path.Combine(Directory.GetCurrentDirectory(), "Templates", "TemplateSetting.json");
var templatePathOriginal = Path.Combine(currentPath, "Templates", "TemplateSetting.json");
if (UpdateTemplateSettings(template, id, templatePathOriginal))
{
id.AddMessage(Environment.NewLine + "Template settings updated successfully at " + templatePathOriginal);
}
else
{
id.ErrorId().AddMessage(Environment.NewLine + "Template settings update failed at " + templatePathOriginal);
}
if (templatePathBin.Equals(templatePathOriginal))
{
id.AddMessage(Environment.NewLine + "Template path is same as original.");
return;
}
id.AddMessage(Environment.NewLine+"Do you want to update the template settings and move the artifacts to the executable directory? (yes/no): press enter to confirm");
var updateTemplateSettings = Console.ReadLine();

if (string.IsNullOrWhiteSpace(updateTemplateSettings) || updateTemplateSettings.Equals("yes", StringComparison.OrdinalIgnoreCase) || updateTemplateSettings.Equals("y", StringComparison.OrdinalIgnoreCase))
{
id.AddMessage(Environment.NewLine + "Updating template settings...");
var templatePathBin = Path.Combine(Directory.GetCurrentDirectory(), "Templates", "TemplateSetting.json");
var templatePathOriginal = Path.Combine(currentPath, "Templates", "TemplateSetting.json");

if (UpdateTemplateSettings(template, id, templatePathOriginal))
{
id.AddMessage(Environment.NewLine+"Template settings updated successfully at " + templatePathOriginal);
}
else
{
id.ErrorId().AddMessage(Environment.NewLine+"Template settings update failed at " + templatePathOriginal);
}


CopyFileIfExists(id,templatePathOriginal, templatePathBin);

id.AddMessage(Environment.NewLine+"Template settings copied to the current directory and updated successfully.");
id.AddMessage(Environment.NewLine + "Moving artifacts to the current directory...");

var artifactsPathOriginal = Path.Combine(currentPath, "Templates", $"CT-{model.ProjectName.Replace(" ", "-")}");
var artifactsPath = Path.Combine(Directory.GetCurrentDirectory(), "Templates", $"CT-{model.ProjectName.Replace(" ", "-")}");

MoveArtifacts(artifactsPathOriginal, artifactsPath, id);
}
else
Expand All @@ -139,18 +145,26 @@

void CopyFileIfExists(string id,string sourcePath, string destinationPath)
{
if (File.Exists(sourcePath))
try
{
File.Copy(sourcePath, destinationPath, true);
if (File.Exists(sourcePath))
{
File.Copy(sourcePath, destinationPath, true);
}
else
{
Console.ForegroundColor = ConsoleColor.Green;
id.AddMessage(Environment.NewLine + $"Source file '{sourcePath}' does not exist. Creating a new file at the destination.");
string fileContents = File.ReadAllText(sourcePath);
File.WriteAllText(destinationPath, fileContents);
id.AddMessage(Environment.NewLine + $"New file created at '{destinationPath}'.");
Console.ResetColor();
}
}
else
catch(Exception ex)
{
Console.ForegroundColor = ConsoleColor.Green;
id.AddMessage(Environment.NewLine+$"Source file '{sourcePath}' does not exist. Creating a new file at the destination.");
string fileContents = File.ReadAllText(sourcePath);
File.WriteAllText(destinationPath, fileContents);
id.AddMessage(Environment.NewLine + $"New file created at '{destinationPath}'.");
Console.ResetColor();
id.ErrorId().AddMessage(Environment.NewLine + "Error copying file: " + ex.Message);
return;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/ADOGenerator/Services/ExtractorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class ExtractorService : IExtractorService
public ExtractorService(IConfiguration config)
{
_config = config;
if (currentPath.EndsWith("ADOGenerator"))
currentPath = currentPath + "\\";
}
#endregion STATIC DECLARATIONS

Expand Down
15 changes: 10 additions & 5 deletions src/API/ProjectsAndTeams/Teams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public GetTeamResponse.Team CreateNewTeam(string json, string project)
if (response.IsSuccessStatusCode)
{
GetTeamResponse.Team viewModel = new GetTeamResponse.Team();
viewModel = response.Content.ReadFromJsonAsync<GetTeamResponse.Team>().Result;
string responseString = response.Content.ReadAsStringAsync().Result;
viewModel = JsonConvert.DeserializeObject<GetTeamResponse.Team>(responseString);
return viewModel;
}
else
Expand Down Expand Up @@ -68,7 +69,8 @@ public TeamMemberResponse.TeamMembers GetTeamMembers(string projectName, string
if (response.IsSuccessStatusCode)
{
TeamMemberResponse.TeamMembers viewModel = new TeamMemberResponse.TeamMembers();
viewModel = response.Content.ReadFromJsonAsync<TeamMemberResponse.TeamMembers>().Result;
string responseString = response.Content.ReadAsStringAsync().Result;
viewModel = JsonConvert.DeserializeObject<TeamMemberResponse.TeamMembers>(responseString);
return viewModel;
}
else
Expand Down Expand Up @@ -186,7 +188,8 @@ public string GetTeamSetting(string projectName)
if (response.IsSuccessStatusCode)
{
TeamSettingResponse.TeamSetting viewModel = new TeamSettingResponse.TeamSetting();
viewModel = response.Content.ReadFromJsonAsync<TeamSettingResponse.TeamSetting>().Result;
string responseString = response.Content.ReadAsStringAsync().Result;
viewModel = JsonConvert.DeserializeObject<TeamSettingResponse.TeamSetting>(responseString);
return viewModel.backlogIteration.id;
}
else
Expand Down Expand Up @@ -257,7 +260,8 @@ public TeamIterationsResponse.Iterations GetAllIterations(string projectName)
HttpResponseMessage response = client.GetAsync(projectName + "/_apis/wit/classificationnodes?$depth=1&api-version=5.0-preview.2").Result;
if (response.IsSuccessStatusCode)
{
viewModel = response.Content.ReadFromJsonAsync<TeamIterationsResponse.Iterations>().Result;
string responseString = response.Content.ReadAsStringAsync().Result;
viewModel = JsonConvert.DeserializeObject<TeamIterationsResponse.Iterations>(responseString);
return viewModel;
}
else
Expand Down Expand Up @@ -329,7 +333,8 @@ public TeamResponse GetTeamByName(string projectName, string teamaName)
HttpResponseMessage response = client.GetAsync("_apis/projects/" + projectName + "/teams/" + teamaName + "?api-version=" + _configuration.VersionNumber).Result;
if (response.IsSuccessStatusCode)
{
viewModel = response.Content.ReadFromJsonAsync<TeamResponse>().Result;
string responseString = response.Content.ReadAsStringAsync().Result;
viewModel = JsonConvert.DeserializeObject<TeamResponse>(responseString);
return viewModel;
}
else
Expand Down
Loading