I have a simple ASP.NET Core React JS web app. I've been publishing it directly to Azure just fine.
Recently I introduced a 2nd environment (prod vs dev).
How can I publish it to Prod using .env
, and publish to Dev using .env.dev
?
Notes:
- I build using VS Enterprise.
- I deploy using VS Enterprise (right-click -> Publish).
- I know I can update the 'scripts' section in packages.json. But I dont believe this script(s) are called when I do a Publish from VS IDE.
Perhaps there is a way to specify the script??
Ex: build:dev would build using .env.development, and build:prod would build using .env
Thanks
Update
I found this in the .csproj file:
<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>wwwroot\%(RecursiveDir)%(FileName)%(Extension)</RelativePath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</ResolvedFileToPublish>
</ItemGroup>
</Target>