Skip to content

Commit

Permalink
Fix additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edvilme committed Nov 6, 2024
1 parent c03cad7 commit 90f4248
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Cli/dotnet/commands/dotnet-sln/add/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private async Task AddProjectsToSolutionAsync(string solutionFileFullPath, strin
var relativePath = Path.GetRelativePath(Path.GetDirectoryName(solutionFileFullPath), projectPath);
try
{
solution.AddProject(relativePath, null, solutionFolder);
AddProjectWithDefaultGuid(solution, relativePath, solutionFolder);
Reporter.Output.WriteLine(CommonLocalizableStrings.ProjectAddedToTheSolution, relativePath);
}
catch (Exception ex)
Expand All @@ -107,5 +107,20 @@ private string GetSolutionFolderPathWithForwardSlashes()
// SolutionModel::AddFolder expects path to have leading, trailing and inner forward slashes
return PathUtility.EnsureTrailingForwardSlash( PathUtility.GetPathWithForwardSlashes(Path.Join("/", _solutionFolderPath)) );
}

private void AddProjectWithDefaultGuid(SolutionModel solution, string relativePath, SolutionFolderModel solutionFolder)
{
try
{
solution.AddProject(relativePath, null, solutionFolder);
}
catch (ArgumentException ex)
{
if (ex.Message == "ProjectType '' not found. (Parameter 'projectTypeName')")
{
solution.AddProject(relativePath, "130159A9-F047-44B3-88CF-0CF7F02ED50F", solutionFolder);
}
}
}
}
}

0 comments on commit 90f4248

Please sign in to comment.