|
|
|
|
@ -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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|