When creating an Angular or React frontend for an ASP.NET Core WebAPI project, the production build static files need to be included in the WebAPI project. To ensure these files are copied to the output or publish directory during the WebAPI build process, the project file must be configured appropriately.
One approach is to manually set the properties of each file in the wwwroot
folder using Visual Studio. However, this method is cumbersome, as it requires reconfiguration whenever new files are added or renamed within the wwwroot
folder.
A more efficient approach is to modify the project file by adding a single line, ensuring all files in the wwwroot
folder are always copied to the output and publish directories.
<ItemGroup>
<Content Update="wwwroot\**\*" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" />
</ItemGroup>
ยฉ 2025 juniyunapapa@gmail.com.