[ASP.Net] Including Production Build Static Files in an ASP.NET Core WebAPI Project
발행일: Feb, 2025
조회수: 0
단어수: 129
Table of Contents
Introduction
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.
The Problem
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.
The Solution
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>