1

I have followed this tutorial: https://learn.microsoft.com/en-us/visualstudio/javascript/tutorial-asp-net-core-with-angular?view=vs-2022

I have created a solution containing a backend ASP.NET Core and angular client application.

For publish, I tried publishing to a folder and to a remote IIS server, but in both instances, only the ASP.NET is packed. In the publish output, I see that the angular app is being built, and I can run both from Visual Studio, but it just doesn't pack the files in the publish.

I also tried setting the output of angular into wwwroot folder of the backend app, it didn't do anything.

3
  • Hi, what do you mean it didn't do anything? Does it mean that you can't interact with the background when you use Angular? If so you can refer to stackoverflow.com/questions/56394751/…. If not, please state clearly. Commented Mar 14, 2023 at 9:55
  • It still didn't add the angular folder into the published folder. Commented Mar 15, 2023 at 20:17
  • About you want to set the output of angular to the wwwroot folder of the backend application can refer to this post <stackoverflow.com/questions/66161734/… asp-net-core-project>. Commented Mar 20, 2023 at 9:45

1 Answer 1

1

If your frontend Angular project does not get published, you can manually build the Angular project in Production mode and copy the contents of dist folder to your wwwroot folder. Also, did you configure your .NET project to serve ANgular from wwwroot folder? You can do it like this in your Startup.cs file -

app.UseSpa(spa =>
{
    spa.Options.SourcePath = "ClientApp";
    if (env.IsDevelopment())
    {
        spa.UseAngularCliServer(npmScript: "start");
    }
});
Sign up to request clarification or add additional context in comments.

2 Comments

I didn't do it manually. This tutorial explains it as it's all done together. That's why I'm asking, I'm trying to avoid manual copying each time I want to deploy.
Try adding these lines in your projects .csproj file, inside PropertyGroup section: ` <SpaRoot>ClientApp\</SpaRoot> <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules**</DefaultItemExcludes> ` This should add your angular app in dotnet build process. The SpaRoot property tells the dotnet publish command where to find the Angular app, and the DefaultItemExcludes property tells it to exclude the node_modules folder from the published output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.