The DeploySite utility is necessary because Visual Studio Publish and dotnet publish are insufficient to deploy a YetaWF site. YetaWF uses symlinks heavily which can't be deployed by other tools.
For first-time deployment and more information about Blue/Green deployment, see Deploying To A Server (FTP, Blue/Green). The deployment method shown here offers an automatic way to deploy the Blue or Green site, based on the currently active site.
Deploying to a server using FTP is a two step process. First, the site is backed up locally, including SQL databases, and uploaded. The second step takes place on the server where the site is restored, again using DeploySite. All tools and config settings are uploaded so no tools need to be installed.
A yaml file (named DeploySite.Windows.yaml in this example) is used to define all the deployment attributes. The following is an example of a yaml file used to deploy via FTP to a server. It also backups up the SQL database yetawf which is used by the site. Multiple databases can be defined if necessary.
Databases: - DevDB: yetawf DevServer: localserver DevUsername: theuser DevPassword: thepassword ProdDB: yetawf-production ProdServer: productionserver ProdUsername: theuser ProdPassword: thepassword Deploy: Type: zip To: C:\Temp\Website.zip BaseFolder: C:\Development\YetaWF From: C:\Temp\PublishOutput ConfigParm: Windows.Prod DetermineBlueGreen: https://yoursite.com/_hc.html BlueRegex: \<body\>Blue\<\/body\> GreenRegex: \<body\>Green\<\/body\> FTP: Server: ftp://yourftpserver Port: 21 User: ftpuser Password: ftppassword Copy: - From: .\DeploySite.Windows.yaml To: /DeploySite.yaml ReplaceBG: true # The following is the health check file - From: .\Website\wwwroot\Maintenance\_hc.html To: /_hc.html ReplaceBG: true # The following is the web.config file for the IIS proxy - From: .\web-BLUEGREEN.config To: /web-BLUEGREEN.config ReplaceBG: true # This is the ZIP file we're uploading - From: C:\Temp\Website.zip To: /Website.zip # The following are required so you can run DeploySite on the server - From: .\PublicTools\DeploySite\Bin\Windows\Softelvdm.DeploySite.exe To: /PublicTools/DeploySite/Bin/Softelvdm.DeploySite.exe Conditional: true - From: .\Restore.bat To: /Restore.bat Site: Location: C:\Sites\YetaWF-BLUEGREEN Zip: C:\Sites\Website.zip RunFirst: - Command: C:\windows\system32\inetsrv\appcmd.exe stop site /site.name:YetaWF-BLUEGREEN - Command: C:\windows\system32\inetsrv\appcmd.exe stop apppool /apppool.name:YetaWF-BLUEGREEN IgnoreErrors: true Run: - Command: C:\windows\system32\inetsrv\appcmd.exe start apppool /apppool.name:YetaWF-BLUEGREEN - Command: C:\windows\system32\inetsrv\appcmd.exe start site /site.name:YetaWF-BLUEGREEN - Command: Copy /Y "Web-BLUEGREEN.config" "YetaWF-BlueGreen\Web.config" - Command: Del "YetaWF-Blue\wwwroot\_hc.html" IgnoreErrors: true - Command: Del "YetaWF-Green\wwwroot\_hc.html" IgnoreErrors: true - Command: Copy /Y "_hc.html" "YetaWF-BLUEGREEN\wwwroot\_hc.html"
In this example, the root of the FTP server is C:\Sites. This means when we upload file DeploySite.Windows.yaml to /DeploySite.yaml it is saved at C:\Sites\DeploySite.yaml.
The Deploy:DetermineBlueGreen URL is used to find which site (Blue or Green) is currently running. YetaWF uses a healthcheck file (_hc.html) which contains the current site mode (Blue or Green).
For information about available options see the topic DeploySite yaml File.
The first step in deploying a site is to run Visual Studio Publish or dotnet publish. In this example, the solution file is located at C:\Development\YetaWF and the published (partial) site is created at C:\Temp\PublishOutput.
Softelvdm.DeploySite Backup yourfile.yaml
Once everything is uploaded to the server, run the DeploySite utility on the server:
Softelvdm.DeploySite Restore yourfile.yaml
The Site tag in the yaml file is used determine how the site is restored to the server. In this example the ZIP file C:\Sites\Website.zip is unzipped and the site is created in the folder C:\Sites\YetaWF.
The Site tag offers additional options, particularly the ability to run commands before and after creating the site can be useful. It could be used to start/stop IIS application pools, update database permissions, etc. For information about available options see the topic DeploySite yaml File.