Search⌘ K

Publishing Process

Explore the publishing process for React and ASP.NET Core applications. Learn to build production-ready artifacts, use npm commands for dependency management and app bundling, and publish your app from Visual Studio to a folder. Understand best practices for deployment including the importance of build servers.

We'll cover the following...

The publishing process is the process of building artifacts to run an application in a production environment.

Let’s continue and inspect the csproj ASP.NET Core project file by looking at the Target element, which has a Name attribute of PublishRunWebPack. The following code executes a set of tasks when the Visual Studio project is published:

Node.js
<Target Name="PublishRunWebpack"
AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are
freshly built in production mode -->
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install"
/>
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run
build" />
<!-- Include the newly-built files in the publish output -->
<ItemGroup>
<DistFiles Include="$(SpaRoot)build\**" />
<ResolvedFileToPublish Include="@(DistFiles-
>'%(FullPath)')"
Exclude="@(ResolvedFileToPublish)">
<RelativePath>%(DistFiles.Identity)</RelativePath>
<CopyToPublishDirectory>PreserveNewest
</CopyToPublishDirectory>
</ResolvedFileToPublish>
</ItemGroup>
</Target>

The first task that is run is the execution of the npm install command via an Exec task. This will ensure that all the dependencies are downloaded and installed. Obviously, if we’ve already run our project in ...