Merge pull request #6533 from abpframework/issue/6468

CLI: Run abp bundle on add-module for Blazor UI
pull/6421/head^2
Yunus Emre Kalkan 5 years ago committed by GitHub
commit 271b851022
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,6 +7,8 @@ using System.Threading.Tasks;
using System.Xml;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Volo.Abp.Cli.Args;
using Volo.Abp.Cli.Commands;
using Volo.Abp.Cli.Http;
using Volo.Abp.Cli.ProjectBuilding;
using Volo.Abp.Cli.Utils;
@ -25,19 +27,22 @@ namespace Volo.Abp.Cli.ProjectModification
protected DerivedClassFinder ModuleClassFinder { get; }
protected ModuleClassDependcyAdder ModuleClassDependcyAdder { get; }
protected IRemoteServiceExceptionHandler RemoteServiceExceptionHandler { get; }
public BundleCommand BundleCommand { get; }
public ProjectNugetPackageAdder(
IJsonSerializer jsonSerializer,
ProjectNpmPackageAdder npmPackageAdder,
DerivedClassFinder moduleClassFinder,
ModuleClassDependcyAdder moduleClassDependcyAdder,
IRemoteServiceExceptionHandler remoteServiceExceptionHandler)
IRemoteServiceExceptionHandler remoteServiceExceptionHandler,
BundleCommand bundleCommand)
{
JsonSerializer = jsonSerializer;
NpmPackageAdder = npmPackageAdder;
ModuleClassFinder = moduleClassFinder;
ModuleClassDependcyAdder = moduleClassDependcyAdder;
RemoteServiceExceptionHandler = remoteServiceExceptionHandler;
BundleCommand = bundleCommand;
Logger = NullLogger<ProjectNugetPackageAdder>.Instance;
}
@ -50,14 +55,14 @@ namespace Volo.Abp.Cli.ProjectModification
);
}
public Task AddAsync(string projectFile, NugetPackageInfo package, string version = null,
public async Task AddAsync(string projectFile, NugetPackageInfo package, string version = null,
bool useDotnetCliToInstall = true)
{
var projectFileContent = File.ReadAllText(projectFile);
if (projectFileContent.Contains($"\"{package.Name}\""))
{
return Task.CompletedTask;
return;
}
if (version == null)
@ -94,11 +99,14 @@ namespace Volo.Abp.Cli.ProjectModification
}
ModuleClassDependcyAdder.Add(moduleFiles.First(), package.ModuleClass);
}
Logger.LogInformation("Successfully installed.");
if (package.Target == NuGetPackageTarget.Blazor)
{
await RunBundleForBlazorAsync(projectFile);
}
return Task.CompletedTask;
Logger.LogInformation("Successfully installed.");
}
private Task AddUsingDotnetCli(NugetPackageInfo package, string version = null)
@ -185,5 +193,15 @@ namespace Volo.Abp.Cli.ProjectModification
return JsonSerializer.Deserialize<NugetPackageInfo>(responseContent);
}
}
protected virtual async Task RunBundleForBlazorAsync(string projectFile)
{
var args = new CommandLineArgs("bundle");
args.Options.Add(BundleCommand.Options.WorkingDirectory.Short, Path.GetDirectoryName(projectFile));
args.Options.Add(BundleCommand.Options.ForceBuild.Short, string.Empty);
await BundleCommand.ExecuteAsync(args);
}
}
}

@ -7,6 +7,7 @@ using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Volo.Abp.Cli.Args;
using Volo.Abp.Cli.Bundling;
using Volo.Abp.Cli.Commands;
using Volo.Abp.Cli.Commands.Services;
using Volo.Abp.Cli.Http;
@ -35,6 +36,7 @@ namespace Volo.Abp.Cli.ProjectModification
public NugetPackageToLocalReferenceConverter NugetPackageToLocalReferenceConverter { get; }
public AngularModuleSourceCodeAdder AngularModuleSourceCodeAdder { get; }
public NewCommand NewCommand { get; }
public BundleCommand BundleCommand { get; }
public SolutionModuleAdder(
IJsonSerializer jsonSerializer,
@ -49,7 +51,8 @@ namespace Volo.Abp.Cli.ProjectModification
SolutionFileModifier solutionFileModifier,
NugetPackageToLocalReferenceConverter nugetPackageToLocalReferenceConverter,
AngularModuleSourceCodeAdder angularModuleSourceCodeAdder,
NewCommand newCommand)
NewCommand newCommand,
BundleCommand bundleCommand)
{
JsonSerializer = jsonSerializer;
ProjectNugetPackageAdder = projectNugetPackageAdder;
@ -64,6 +67,7 @@ namespace Volo.Abp.Cli.ProjectModification
NugetPackageToLocalReferenceConverter = nugetPackageToLocalReferenceConverter;
AngularModuleSourceCodeAdder = angularModuleSourceCodeAdder;
NewCommand = newCommand;
BundleCommand = bundleCommand;
Logger = NullLogger<SolutionModuleAdder>.Instance;
}
@ -118,9 +122,28 @@ namespace Volo.Abp.Cli.ProjectModification
await AddAngularPackages(solutionFile, module);
}
await RunBundleForBlazorAsync(projectFiles, module);
ModifyDbContext(projectFiles, module, startupProject, skipDbMigrations);
}
private async Task RunBundleForBlazorAsync(string[] projectFiles, ModuleWithMastersInfo module)
{
var blazorProject = projectFiles.FirstOrDefault(f => f.EndsWith(".Blazor.csproj"));
if (blazorProject == null || !module.NugetPackages.Any(np=> np.Target == NuGetPackageTarget.Blazor))
{
return;
}
var args = new CommandLineArgs("bundle");
args.Options.Add(BundleCommand.Options.WorkingDirectory.Short, Path.GetDirectoryName(blazorProject));
args.Options.Add(BundleCommand.Options.ForceBuild.Short, string.Empty);
await BundleCommand.ExecuteAsync(args);
}
private async Task RemoveUnnecessaryProjectsAsync(string solutionDirectory, ModuleWithMastersInfo module,
string[] projectFiles)
{

Loading…
Cancel
Save