Deploying an Angular 2 application from Visual Studio 2017

前端 未结 5 1210
走了就别回头了
走了就别回头了 2021-02-03 13:04

I use Visual Studio 2017 and have developed two Angular 2 applications. The first is pure Angular 2 with no backend code (Data comes from wcf services). The second is an Angul

5条回答
  •  孤城傲影
    2021-02-03 13:26

    In addition to the accepted solution, I'd like to add a suggestion for anyone who is using IIS Web deploy (or any of the other methods in the VS publishing tool) and has more than one environment to deploy to: It's pretty neat to use the VS solution configurations.

    • Add one configuration per environment you wish to deploy to.
    • Edit the .csproj file and change the "Exec Command", adding "$(ConfigurationName)" to the script name:

      
      
      
      
        
        
          %(DistFiles.Identity)
          PreserveNewest
        
      
      
      
    • Edit your package.json to contain a script called buildYourSolutionConfigName:

      {
          "scripts": {
              "buildYourSolutionConfigName": "ng build --someFlagNeeded",
              "ng": "ng",
              "start": "ng serve",
              "build": "ng build",
              ...
          }
          ...
      }
      

    Now you have everything you need to get the app built according to the requirements of the target environment. This allows you to simply select the correct config in VS and push publish.

提交回复
热议问题