Azure devops 如何预防FtpUpload@2在使用Azure DevOps时在ftp服务器上创建额外的根文件夹?

Azure devops 如何预防FtpUpload@2在使用Azure DevOps时在ftp服务器上创建额外的根文件夹?,azure-devops,Azure Devops,FtpUpload@2上载时正在我的ftp服务器上创建一个额外文件夹。它使用项目名称创建文件夹,而不只是创建根文件结构 e、 g.在ftp服务器上创建/wwwroot/..而不是创建/projectname/wwwroot/..。因此,当我查看文件夹时,我看到(下图)一个带有项目名称的文件夹,我希望看到一个wwwroot文件夹和一些文件 举个例子,我以 http://domain/projectname/page.html 当我真正想要的时候 http://domain/page.htm

FtpUpload@2上载时正在我的ftp服务器上创建一个额外文件夹。它使用项目名称创建文件夹,而不只是创建根文件结构

e、 g.在ftp服务器上创建
/wwwroot/..
而不是创建
/projectname/wwwroot/..
。因此,当我查看文件夹时,我看到(下图)一个带有项目名称的文件夹,我希望看到一个
wwwroot
文件夹和一些文件

举个例子,我以

http://domain/projectname/page.html
当我真正想要的时候

http://domain/page.html
下面的目录树是正确的,但我不需要/想要额外的文件夹

我可以使用什么设置来停止此操作?我的YAML在下面

-任务:DotNetCoreCLI@2
显示名称:发布
投入:
命令:发布
publishWebProjects:正确
参数:'--configuration$(BuildConfiguration)--输出$(build.artifactstagingdirectory)'
zipAfterPublish:错误
-任务:FtpUpload@2
displayName:“FTP上载”
投入:
凭证选项:输入
服务器URL:'ftp://ftp.xxxxxxx.com'
用户名:“XXXXXXXX”
密码:“XXXXXXXX”
remoteDirectory:“/”
trustSSL:对
内容:正确
根目录:$(Build.artifactstagingdirectory)
答案:对

我无法重现上述问题。FtpUpload任务对我来说很好。看起来
wwwroot
文件夹不直接位于
$(Build.artifactstagingdirectory)
文件夹中。它的路径很可能是
$(Build.artifactstagindirectory)/projectname/wwwroot

或者您可能错误地将ftp服务器的物理路径设置为包含如下
c:\site\projectname

- task: DotNetCoreCLI@2
          displayName: Publish
          inputs:
            command: publish
            publishWebProjects: True
            arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
            zipAfterPublish: false
            
    
    - task: FtpUpload@2
      displayName: 'FTP Upload'
      inputs:
          ....
          cleanContents: true
          rootDirectory: $(Build.artifactstagingdirectory)/projectname 
          preservePaths: true     
您可以将powershell任务添加到
ls
您的
$(Build.artifactstagindirectory)
目录,以检查您的
$(Build.artifactstagindirectory)
文件夹结构。并相应地更改FtpUpload任务的
rootDirectory
字段

- powershell: |
   
   ls  $(Build.artifactstagingdirectory)
我对我的管道进行了测试。一切正常。见下文:

1,下面是
$(Build.artifactstagingdirectory)

2,我的FtpUpload任务具有完全相同的配置

- task: FtpUpload@2
  displayName: 'FTP Upload'
  inputs:
    credentialsOption: inputs
    serverUrl: '..'
    username: '..'
    password: '..'
    rootDirectory: '$(Build.artifactstagingdirectory)'
    remoteDirectory: /
    cleanContents: true
    preservePaths: true 
3,见下面的结果截图。未创建提取文件夹

更新:

我发现你使用了dotnet发布任务来发布你的应用程序。dotnet发布任务有一个
modifyOutputPath
字段。它的默认值是
true
,当在参数中明确指定输出路径时,该值将在文件夹名称的前面加上项目文件名。看

您可以更改dotnet发布任务以禁用modifyOutputPath字段
modifyOutputPath:false

- task: DotNetCoreCLI@2
      displayName: Publish
      inputs:
        command: publish
        publishWebProjects: True
        arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
        zipAfterPublish: false
        modifyOutputPath: false  #add this field

- task: FtpUpload@2
  displayName: 'FTP Upload'
  inputs:
      ....
      cleanContents: true
      rootDirectory: $(Build.artifactstagingdirectory) 
      preservePaths: true     
或者将FTPupload任务的
rootDirectory
字段更改为
$(Build.artifactstagindirectory)/projectname

- task: DotNetCoreCLI@2
          displayName: Publish
          inputs:
            command: publish
            publishWebProjects: True
            arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
            zipAfterPublish: false
            
    
    - task: FtpUpload@2
      displayName: 'FTP Upload'
      inputs:
          ....
          cleanContents: true
          rootDirectory: $(Build.artifactstagingdirectory)/projectname 
          preservePaths: true     

我已经更新了YAML以显示发布任务,这是前面的步骤。我坦率地承认,我可能有设置错误,因为我不得不将其拼凑起来,因为文档对我来说并不清楚。知道怎么回事吗?不可能!我也在研究这个参数,但我确信它不会达到我想要的效果。谢谢你的帮助。直到下一个问题,哈哈