简体   繁体   中英

VSTS deploy to non-Azure cloud platform

I've currently got an ASP.NET Core web application with EF that I am deploying to GearHost (a non-Azure cloud platform that was recommended by a user here) using a web deploy publish profile directly from Visual Studio. I'm looking to get CI/CD set up via VSTS so that the publish ability isn't restricted to one machine.

So far I've got the build stage set up, as the .NET Core template is all that's really needed. It's the deploy part that has got me stuck - all the templates (and indeed articles) that I can find relating specifically to .NET Core are focused on Azure or an IIS deployment, neither of which are really applicable here, and indeed Azure uses deploy tasks that are created specifically for it.

If it's relevant, GearHost provides FTP credentials which could potentially be used for a manual copy. Alternatively, is there any way I could use the VS2017 publish profile to create a release definition including appsettings.json transforms and EF migrations?

There are many ways to deploy app to GearHost server, such as FTP, Publish Profile.

So, you can upload the published files (eg Create a publish profile with file system publish method) to GearHost server by using FTP Upload task .

You also could download the publish profile with Web Deploy method and import to VS , then deploy app by using this publish profile. (MSBuild Arguments: /p:DeployOnBuild=true /p:PublishProfile=[publish profile file name] )

Regarding appsettings.json transforms, you don't need to transform appsettings.json file, the .net core project can retrieve the values from appsettings.[environment].json file per to the value of ASPNETCORE_ENVIRONMENT system environment variable. Working with multiple environments

Regarding EF migrations, you can configure it in publish profile and publish/deploy app with that publish profile.

Update:

Steps to call GearHost cloudsite:

  1. Log in GearHost
  2. Click API tab >Create a new API Key
  3. Using Invoke-RestMethod

Simple code:

$url="https://api.gearhost.com/v1/cloudsites/[could site id]/stop"
 $APIID="[step 2]"
 $result=Invoke-RestMethod -Method POST -Uri $url -Headers @{Authorization=("bearer {0}" -f $APIID)} -ContentType "application/json"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM