Browse Source

Refactor solution file path handling in module addition

pull/24697/head
maliming 2 weeks ago
parent
commit
304b89d747
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 13
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionFileModifier.cs

13
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionFileModifier.cs

@ -51,16 +51,17 @@ public class SolutionFileModifier : ITransientDependency
private async Task AddModuleAsync(ModuleWithMastersInfo module, string solutionFile)
{
var slnDir = Path.GetDirectoryName(solutionFile);
var projectsUnderModule = Directory.GetFiles(
Path.Combine(Path.GetDirectoryName(solutionFile), "modules", module.Name),
Path.Combine(slnDir, "modules", module.Name),
"*.csproj",
SearchOption.AllDirectories);
var projectsUnderTest = new List<string>();
if (Directory.Exists(Path.Combine(Path.GetDirectoryName(solutionFile), "modules", module.Name, "test")))
if (Directory.Exists(Path.Combine(slnDir, "modules", module.Name, "test")))
{
projectsUnderTest = Directory.GetFiles(
Path.Combine(Path.GetDirectoryName(solutionFile), "modules", module.Name, "test"),
Path.Combine(slnDir, "modules", module.Name, "test"),
"*.csproj",
SearchOption.AllDirectories).ToList();
}
@ -68,11 +69,9 @@ public class SolutionFileModifier : ITransientDependency
foreach (var projectPath in projectsUnderModule)
{
var folder = projectsUnderTest.Contains(projectPath) ? "test" : "src";
var projectId = Path.GetFileName(projectPath).Replace(".csproj", "");
var package = @$"modules\{module.Name}\{folder}\{projectId}\{projectId}.csproj";
_cmdHelper.RunCmd($"dotnet sln \"{solutionFile}\" add \"{package}\" --solution-folder {folder}", workingDirectory: Path.GetDirectoryName(solutionFile));
var package = Path.Combine(slnDir, "modules", module.Name, folder, projectId, $"{projectId}.csproj");
_cmdHelper.RunCmd($"dotnet sln \"{solutionFile}\" add \"{package}\" --solution-folder {folder}", workingDirectory: slnDir);
}
if (module.MasterModuleInfos != null)

Loading…
Cancel
Save