Browse Source

CLI: Fix change theme step for basic theme.

pull/19474/head
Engincan VESKE 3 years ago
parent
commit
75bb0f14e3
  1. 32
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/ChangeThemeStep.cs

32
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/ChangeThemeStep.cs

@ -565,6 +565,31 @@ public class ChangeThemeStep : ProjectBuildPipelineStep
file.SetLines(lines);
}
private static void AddNamespaces(ProjectBuildContext context, string targetModuleFilePath, params string[] namespaces)
{
var file = context.Files.FirstOrDefault(x => x.Name.Contains(targetModuleFilePath));
if (file == null)
{
return;
}
file.NormalizeLineEndings();
var lines = file.GetLines();
foreach (var @namespace in namespaces.Select(x => x.EnsureEndsWith(';')))
{
if (lines.Any(x => x.Contains(@namespace)))
{
continue;
}
lines.AddFirst(@namespace);
}
file.SetLines(lines);
}
private static void ChangeThemeToBasicForMvcProjects(ProjectBuildContext context, string defaultThemeName)
{
var projectNames = new[]
@ -601,6 +626,13 @@ public class ChangeThemeStep : ProjectBuildPipelineStep
defaultThemeName,
Basic
);
AddNamespaces(
context,
moduleFile.Name,
"using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic",
"using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling"
);
}
}

Loading…
Cancel
Save