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 76bc82f570..3ee7cfdea3 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 @@ -66,7 +66,14 @@ public class BundlingService : IBundlingService, ITransientDependency var frameworkVersion = GetTargetFrameworkVersion(projectFilePath, projectType); var projectName = Path.GetFileNameWithoutExtension(projectFilePath); - var assemblyFilePath = projectType == BundlingConsts.WebAssembly? PathHelper.GetWebAssemblyFilePath(directory, frameworkVersion, projectName) : PathHelper.GetMauiBlazorAssemblyFilePath(directory, projectName); + var assemblyFilePath = projectType == BundlingConsts.WebAssembly + ? PathHelper.GetWebAssemblyFilePath(directory, frameworkVersion, projectName) + : PathHelper.GetMauiBlazorAssemblyFilePath(directory, projectName); + if (assemblyFilePath == null) + { + throw new BundlingException("No assembly file found. Please build the project first."); + } + var startupModule = GetStartupModule(assemblyFilePath); var bundleDefinitions = new List(); diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/PathHelper.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/PathHelper.cs index 1b6b56adab..1618004bb5 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/PathHelper.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/PathHelper.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; using System.Linq; namespace Volo.Abp.Cli.Bundling; @@ -13,12 +14,15 @@ static internal class PathHelper static internal string GetWebAssemblyFilePath(string directory, string frameworkVersion, string projectFileName) { var outputDirectory = Path.Combine(directory, "bin", "Debug", frameworkVersion); - return Path.Combine(outputDirectory, projectFileName + ".dll"); + var path = Path.Combine(outputDirectory, projectFileName + ".dll"); + return !File.Exists(path) ? null : path; } static internal string GetMauiBlazorAssemblyFilePath(string directory, string projectFileName) { - return Directory.GetFiles(directory, "*.dll", SearchOption.AllDirectories).First(f => !f.Contains("android") && f.EndsWith(projectFileName + ".dll")); + return Directory.GetFiles(directory, "*.dll", SearchOption.AllDirectories).FirstOrDefault(f => + !f.Contains("android") && + f.EndsWith(projectFileName + ".dll", StringComparison.OrdinalIgnoreCase)); } static internal string GetWwwRootPath(string directory)