Open Closed

Volo.Abp.AbpException: Could not find file '~/global-styles.css hatasi #10160


User avatar
0
user9.abpio created

Merhaba,

ABP layered application projesi sahibiyim. Projemin swagger ve ABP UI(MVC) olarak iki arayuzu var. Lokalimde her iki taraf sorunsuz calisirken Digital Ocean Droplets container icerisinde barinan uygulamam ABP UI'i bir turlu goruntuleyemiyor 500 hatasi veriyor. Hata detaylarini asagida paylastim. Bir cok cozum yolu denedim fakat hic birinde basarili olamadim. build ve deploy basarili oluyor proje ayakta fakat UI ekrani acilmiyor. ilgili file iceriklerini sizinle paylasiyorum. gerekirse uzaktan baglanmanizi beraber cozmemizi sizden rica ediyorum. ProdigyEnablerWebModule.cs, ci-cd.yml, Dockerfile ve hata mesaji txt dosyasinda.hatayi cozmenize yardimci assetler


5 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    1. Solution ABP UI renders global CSS/JS through the bundling system and the Virtual File System. In production containers, the “Could not find file '~/global-styles.css'” error typically happens because the file is not included in any bundle or the static/virtual files are not mapped/packaged into the image.

    Apply all steps below:

    • Ensure you add your CSS into the Basic Theme global bundle (so ABP can serve it virtually)
    using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
      using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling;
    
      public class ProdigyEnablerWebModule : AbpModule
      {
          public override void ConfigureServices(ServiceConfigurationContext context)
          {
              Configure<AbpBundlingOptions>(options =>
              {
                  options.StyleBundles.Configure(BasicThemeBundles.Styles.Global, bundle =>
                  {
                      // Path must be relative to web root (wwwroot)
                      bundle.AddFiles("/styles/global-styles.css");
                  });
              });
          }
      }
    

    Notes:

    • Place the file at WebProject/wwwroot/styles/global-styles.css.
    • Don’t reference “~/global-styles.css” directly in your layout; use the bundle tag helper:
    <abp-style-bundle name="@BasicThemeBundles.Styles.Global" />
    
    • Map ABP static assets in the ASP.NET Core pipeline (for virtual/static files to be reachable)
    public override void OnApplicationInitialization(ApplicationInitializationContext context)
      {
          var app = context.GetApplicationBuilder();
          var env = context.GetEnvironment();
    
          if (!env.IsDevelopment())
          {
              app.UseHsts();
          }
    
          app.UseHttpsRedirection();
          app.UseStaticFiles();
          app.MapAbpStaticAssets(); // important for ABP’s virtual files
          app.UseRouting();
          app.UseAuthentication();
          app.UseAuthorization();
          app.UseConfiguredEndpoints();
      }
    
    • Ensure client libraries and bundles are present when you build/publish:

      • If your UI depends on npm/yarn packages (e.g., theme packages), run install-libs during CI:
        • Add a step in your Dockerfile or CI to execute from the Web project folder:
          • dotnet tool restore
          • dotnet tool update -g Volo.Abp.Cli (optional)
          • abp install-libs
      • Then publish:
        • dotnet publish -c Release -o /app/publish
      • Copy the published output only in your final image (multi-stage build).
    • Dockerfile (reference pattern)

      • Multi-stage example to guarantee libs and wwwroot are included:
    FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
        WORKDIR /src
    
        # Copy solution and restore
        COPY ./ ./
        RUN dotnet restore
    
        # Install ABP libs for the Web project (adjust path to your Web csproj folder)
        WORKDIR /src/YourCompany.YourProj.Web
        RUN dotnet tool restore
        RUN dotnet tool install -g Volo.Abp.Cli || true
        ENV PATH="$PATH:/root/.dotnet/tools"
        RUN abp install-libs
    
        # Build and publish
        WORKDIR /src
        RUN dotnet publish YourCompany.YourProj.Web/YourCompany.YourProj.Web.csproj -c Release -o /app/publish
    
        FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
        WORKDIR /app
        COPY --from=build /app/publish .
        ENV ASPNETCORE_URLS=http://+:8080
        EXPOSE 8080
        ENTRYPOINT ["dotnet", "YourCompany.YourProj.Web.dll"]
    
    • CI/CD (DigitalOcean)

      • If you build inside CI, ensure the abp install-libs step runs before dotnet publish, and the working directory is the Web project where package.json/abp.resourcemapping.js live.
      • Do not ignore wwwroot in .dockerignore.
    • Verify at runtime

      • After container starts, check:
        • GET http://your-host/global.css → should return combined CSS (if using Global Assets) or
        • Ensure your page renders <abp-style-bundle name="@BasicThemeBundles.Styles.Global" /> and the network tab shows the CSS request(s) from /styles/global-styles.css included in the bundle.
      • If you still reference “~/global-styles.css” directly anywhere, remove it and rely on the bundle.

    Common pitfalls that cause this error

    • Using bundle.AddFiles("~/global-styles.css") with a wrong path. Use a rooted web path like “/styles/global-styles.css” that matches wwwroot/styles/global-styles.css.
    • Missing app.MapAbpStaticAssets() or app.UseStaticFiles() in Program.cs/Module.
    • Not running abp install-libs during container build (relevant if you use theme or library bundles).
    • Publishing from a solution root without first installing libs in the Web project.
    • Trimming/publish options removing embedded/virtual files. If you enabled aggressive trimming, disable it for the web project or ensure ABP assemblies’ resources are preserved.
    1. Sources
    • ABP Basic Theme – add a global style via bundling:
      • https://abp.io/docs/latest/framework/ui/mvc-razor-pages/basic-theme
    • ABP Modularity basics (for where to configure bundling in your module):
      • https://abp.io/docs/latest/framework/architecture/modularity/basics

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    user9.abpio created

    sorun cozulmedi

  • User Avatar
    0
    user9.abpio created

    AI'nin dediklerini yaptim ve kontrol ettim ama sorun cozulmedi

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Hi

    Can you use English?

    You can share the logs file with liming.ma@volosoft.com

    Thanks.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Hi

    Can you check your wwwroot folder to see if global-scripts.js and global-styles.cs files exist?

    Can you try to change

    bundle.AddFiles("~/global-scripts.js");
    bundle.AddFiles("~/global-scripts.css");
    

    to

    bundle.AddFiles("/global-scripts.js");
    bundle.AddFiles("/global-scripts.css");
    

    Also, remove the code below:

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on December 03, 2025, 13:19
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.