From 2fdbb3e9c0793b19cd4cb1e3eb3252b936f643ba Mon Sep 17 00:00:00 2001 From: Berkan Sasmaz Date: Tue, 9 Nov 2021 10:43:39 +0300 Subject: [PATCH 1/2] fix(Abp-Cli): `add-module` command doesn't work for `blazor-server` project `abp bundle` command only support blazor-wasm project. --- .../Volo/Abp/Cli/Bundling/BundlingService.cs | 18 ++++++++++++++++-- .../ProjectModification/SolutionModuleAdder.cs | 10 ++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundlingService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundlingService.cs index 74be59e014..9cce1cd734 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundlingService.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundlingService.cs @@ -39,6 +39,8 @@ namespace Volo.Abp.Cli.Bundling } var projectFilePath = projectFiles[0]; + + CheckProjectIsSupportedType(projectFilePath); var config = ConfigReader.Read(PathHelper.GetWwwRootPath(directory)); var bundleConfig = config.Bundle; @@ -282,14 +284,26 @@ namespace Volo.Abp.Cli.Bundling { var document = new XmlDocument(); document.Load(projectFilePath); + CheckProjectIsSupportedType(document); + + return document.SelectSingleNode("//TargetFramework").InnerText; + } + + private void CheckProjectIsSupportedType(string projectFilePath) + { + var document = new XmlDocument(); + document.Load(projectFilePath); + CheckProjectIsSupportedType(document); + } + + private void CheckProjectIsSupportedType(XmlDocument document) + { var sdk = document.DocumentElement.GetAttribute("Sdk"); if (sdk != BundlingConsts.SupportedWebAssemblyProjectType) { throw new BundlingException( $"Unsupported project type. Project type must be {BundlingConsts.SupportedWebAssemblyProjectType}."); } - - return document.SelectSingleNode("//TargetFramework").InnerText; } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs index cf1e9a3687..affb89771f 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs @@ -7,8 +7,10 @@ using System.IO; using System.Linq; using System.Net; using System.Threading.Tasks; +using System.Xml; using NuGet.Versioning; 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; @@ -184,6 +186,14 @@ namespace Volo.Abp.Cli.ProjectModification { return; } + // return if project is blazor-server + var document = new XmlDocument(); + document.Load(blazorProject); + var sdk = document.DocumentElement.GetAttribute("Sdk"); + if (sdk != BundlingConsts.SupportedWebAssemblyProjectType) + { + return; + } var args = new CommandLineArgs("bundle"); From 1bc2d0d5a62a4657d4adcec50dc36c0f2e2775a2 Mon Sep 17 00:00:00 2001 From: Berkan Sasmaz Date: Tue, 9 Nov 2021 11:44:20 +0300 Subject: [PATCH 2/2] fix(Abp.Cli): No need to double check sdk in `bundle` command --- .../Volo/Abp/Cli/Bundling/BundlingService.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundlingService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundlingService.cs index 9cce1cd734..905f9bc8e4 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundlingService.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundlingService.cs @@ -284,7 +284,6 @@ namespace Volo.Abp.Cli.Bundling { var document = new XmlDocument(); document.Load(projectFilePath); - CheckProjectIsSupportedType(document); return document.SelectSingleNode("//TargetFramework").InnerText; } @@ -293,11 +292,7 @@ namespace Volo.Abp.Cli.Bundling { var document = new XmlDocument(); document.Load(projectFilePath); - CheckProjectIsSupportedType(document); - } - - private void CheckProjectIsSupportedType(XmlDocument document) - { + var sdk = document.DocumentElement.GetAttribute("Sdk"); if (sdk != BundlingConsts.SupportedWebAssemblyProjectType) {