简体   繁体   中英

dotnet core 2.1 angular app - rename ClientApp folder

I had to redesign an angular app in a dotnet core 2.1 single page application template.

I did it in a new folder "Frontend" next to the normal "ClientApp" folder. Locally it works fine, but when I deploy it or try to publish it by "dotnet publish" it always takes the ClientApp folder.

It is possible to replace respectively rename the ClientApp folder?

I'm fairly certain you can accomplish this by changing the Startup.cs

spa.Options.SourcePath = "ClientApp";

...and change the production build path:

services.AddSpaStaticFiles(configuration =>
{
    configuration.RootPath = "ClientApp/dist";
});

...then modify your path in project_name.csproj:

<SpaRoot>ClientApp\</SpaRoot>

There are 2 sections in the Startup.cs folder where you register the path to the single page app files, I'm guessing you changed the folder name but not the configuration settings to match.

In configure services method:

 services.AddSpaStaticFiles(configuration =>
 {
     configuration.RootPath = "ClientApp/dist";
 });

And in the configure http pipeline method:

app.UseSpa(spa =>
{
    spa.Options.SourcePath = "ClientApp";

    if (env.IsDevelopment())
    {
         spa.UseAngularCliServer(npmScript: "start");
    }
});

Also in the .csproj file there is a property group to register the Client side directory name

<SpaRoot>ClientApp\</SpaRoot>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM