Change Angular output directory from wwwroot to another folder in ASP.NET

Discussão em 'Angular' iniciado por Swrena, Dezembro 31, 2024.

  1. Swrena

    Swrena Guest

    Currently my ASP .NET project with angular frontend (inside one Project) is putting the Angular output folder (dist content) inside /wwwroot folder when published.

    Website_ASP.exe
    web.config
    wwwroot
    index.html
    scripts ....
    etc..


    Now I don't want the output inside wwwroot folder at all. this way it's just not tidy and clean. I want it inside a different folder in root like ClientApp/dist and serve that when opening base url : http://localhost:5000.

    I don't know which and how many files I need to edit for this to happen, I've tried setting a staticfile directory on said folder but then the Angular doesn't work properly.

    Currently:

    app.UseDefaultFiles();
    app.UseStaticFiles();


    and I have tried :

    app.UseStaticFiles(new StaticFileOptions
    {
    FileProvider = new PhysicalFileProvider(
    Path.Combine(builder.Environment.ContentRootPath, "ClientApp")),
    RequestPath = "/"
    });


    How many files do I need to edit in Angular and ASP to completely change the frontend path to a different folder outside wwwroot, or at the very least inside wwwroot/dist.

    Continue reading...

Compartilhe esta Página