title: How to publish angular files in production mode?
body: <p>I've been wondering for a while now why my client always needed to clear his browser cache for my website. Turns out the angular files do not get build correctly. Or to be more precise, they get build, but their name does not get hashed which results in the same names as the previous versions and therefore the browser thinks nothing has changed.</p>
  
  <p>Below is my .csproj:</p>
  
  <pre><code>    &lt;Project Sdk="Microsoft.NET.Sdk.Web"&gt;
  
    &lt;PropertyGroup&gt;
      &lt;TargetFramework&gt;netcoreapp2.2&lt;/TargetFramework&gt;
      &lt;TypeScriptCompileBlocked&gt;true&lt;/TypeScriptCompileBlocked&gt;
      &lt;TypeScriptToolsVersion&gt;Latest&lt;/TypeScriptToolsVersion&gt;
      &lt;IsPackable&gt;false&lt;/IsPackable&gt;
      &lt;SpaRoot&gt;ClientApp\&lt;/SpaRoot&gt;
      &lt;DefaultItemExcludes&gt;$(DefaultItemExcludes);$(SpaRoot)node_modules\**&lt;/DefaultItemExcludes&gt;
  
      &lt;!-- Set this to true if you enable server-side prerendering --&gt;
      &lt;BuildServerSideRenderer&gt;false&lt;/BuildServerSideRenderer&gt;
      &lt;UserSecretsId&gt;c69ca95c-16a6-4f76-bb29-b4d09b2a4417&lt;/UserSecretsId&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;PackageReference Include="CsvHelper" Version="12.1.1" /&gt;
      &lt;PackageReference Include="EPPlus" Version="4.5.3.1" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.App" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" /&gt;
      &lt;PackageReference Include="Sendgrid" Version="9.10.0" /&gt;
      &lt;PackageReference Include="WindowsAzure.Storage" Version="9.3.3" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;!-- Don't publish the SPA source files, but do show them in the project files list --&gt;
      &lt;Content Remove="$(SpaRoot)**" /&gt;
      &lt;None Remove="$(SpaRoot)**" /&gt;
      &lt;None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" /&gt;
    &lt;/ItemGroup&gt;
  
  
    &lt;Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') "&gt;
      &lt;!-- Ensure Node.js is installed --&gt;
      &lt;Exec Command="node --version" ContinueOnError="true"&gt;
        &lt;Output TaskParameter="ExitCode" PropertyName="ErrorCode" /&gt;
      &lt;/Exec&gt;
      &lt;Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." /&gt;
      &lt;Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." /&gt;
      &lt;Exec WorkingDirectory="$(SpaRoot)" Command="npm install" /&gt;
    &lt;/Target&gt;
  
    &lt;Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish"&gt;
      &lt;!-- As part of publishing, ensure the JS resources are freshly built in production mode --&gt;
      &lt;Exec WorkingDirectory="$(SpaRoot)" Command="npm install" /&gt;
      &lt;Exec WorkingDirectory="$(SpaRoot)" Command="npm run build --prod" /&gt;
      &lt;Exec WorkingDirectory="$(SpaRoot)" Command="npm run build:ssr --prod" Condition=" '$(BuildServerSideRenderer)' == 'true' " /&gt;
  
      &lt;!-- Include the newly-built files in the publish output --&gt;
      &lt;ItemGroup&gt;
        &lt;DistFiles Include="$(SpaRoot)dist\**; $(SpaRoot)dist-server\**" /&gt;
        &lt;DistFiles Include="$(SpaRoot)node_modules\**" Condition="'$(BuildServerSideRenderer)' == 'true'" /&gt;
        &lt;ResolvedFileToPublish Include="@(DistFiles-&gt;'%(FullPath)')" Exclude="@(ResolvedFileToPublish)"&gt;
          &lt;RelativePath&gt;%(DistFiles.Identity)&lt;/RelativePath&gt;
          &lt;CopyToPublishDirectory&gt;PreserveNewest&lt;/CopyToPublishDirectory&gt;
        &lt;/ResolvedFileToPublish&gt;
      &lt;/ItemGroup&gt;
    &lt;/Target&gt;
  
  &lt;/Project&gt;
  </code></pre>
  
  <p>Turns out the "npm run build --prod" does not get run because angular is not in production mode. How do i make it so my production publish settings in visual studio build angular in production mode, while my development server gets a development build?</p>