Browse Source

Merge pull request #22731 from abpframework/Maui-BundlingService

Add error handling for missing assembly files in BundlingService and improve file path checks in PathHelper
pull/22732/head
liangshiwei 10 months ago
committed by GitHub
parent
commit
1ba3bacfd2
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 9
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundlingService.cs
  2. 10
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/PathHelper.cs

9
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<BundleTypeDefinition>();

10
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)

Loading…
Cancel
Save