Publishing Process
Learn to publish our application by following step-by-step instructions.
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:
Press + to interact
<Target Name="PublishRunWebpack"AfterTargets="ComputeFilesToPublish"><!-- As part of publishing, ensure the JS resources arefreshly built in production mode --><Exec WorkingDirectory="$(SpaRoot)" Command="npm install"/><Exec WorkingDirectory="$(SpaRoot)" Command="npm runbuild" /><!-- 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 ...