How do I configure a build on VSTS to FTP deploy

做~自己de王妃 提交于 2020-01-06 05:34:08

问题


I want to use VSTS to build and deploy my app (to FTP) when Update the master branch of my project. I have the script below. It works in that it triggers and builds but then fails to deploy because it can't find the files and I don't know what values to enter. I get the error below.

When VSTS builds, where does it put the build files?

I've watched youtube but all the examples are old and don't reflect how VSTS works right now so I'm totally stuck. There are no articles here that reflect how VSTS works right now and the Microsoft pages are no help either.

I'm running out of articles to review and am now pretty much guessing, so any help would be very much appreciated.

# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

variables:
  buildConfiguration: 'Release'

steps:
- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build $(buildConfiguration)'

- task: FtpUpload@2
  inputs:
    credentialsOption: 'inputs'
    serverUrl: 'ftp://xxxxxxx.xxxxxxxx.xxxxx/'
    username: 'xxxxxxxxx'
    password: 'xxxxxxxxxx'
    rootDirectory: '/'
    filePatterns: '**'
    remoteDirectory: '/'
    clean: false
    cleanContents: true
    preservePaths: false
    trustSSL: false

I changed to this

rootDirectory: $(Agent.BuildDirectory)

and tried this

rootDirectory: $(Build.StagingDirectory)

And now the build succeeds but now I get this error/warning. Nothing is deployed.


回答1:


When you set system.debug=true, then open the log for detailed compile process, you could see:

It is looking for directory '/' which you specified in the task. But, unfortunately, the content obtained with / is not any part of your repos. Then the server tell you sorry, can not find such file or directory in your repos.

This parameter is getting files or folders from your VSTS repos, so here you need use some words to let server know what you want to take from Repos.


(1) Since this task is in your build pipeline, you could use $(Build.SourcesDirectory) to represent for your whole repos.

(2) Also, if you just want to copy part of repos, such as folder or file, just input them with relative path. For example:

  • Upload the file upload.json which under the folder jobs, just input rootDirectory: jobs/upload.json.
  • Upload one folder or file which in the root path of Repos, just input rootDirectory: {folder name}, or rootDirectory: {folder name}. Like: rootDirectory: jobs, or rootDirectory: web.config


来源:https://stackoverflow.com/questions/58966579/how-do-i-configure-a-build-on-vsts-to-ftp-deploy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!