๐Ÿ˜œ

์ญˆ๋‚˜์•„๋น  ๋ธ”๋กœ๊ทธ

JUNA
STUDIO

[ASP.Net] Including Production Build Static Files in an ASP.NET Core WebAPI Project

๋ฐœํ–‰์ผ: Feb, 2025
์กฐํšŒ์ˆ˜: 3
๋‹จ์–ด์ˆ˜: 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>

Tags: #ASP.NET Core#WebAPI#Angular#React#Static Files#wwwroot#Production Build#Visual Studio#Project Configuration
JUNA BLOG VISITORS
Today
7
 (
updown
-7
)
Total
657
 (
updown
+7
)

ยฉ 2025 juniyunapapa@gmail.com.