【发布时间】:2020-06-25 14:22:39
【问题描述】:
我正在尝试在 C# 控制台应用程序中进行一些处理,并且必须保存该文件:
File.WriteAllText("C:\JSONOutput\output.md"), htmlResult);
我想将它保存到 Azure DevOps 文件夹,如“/home/vsts/work/1/s/”,以便在下一步中再次访问它,我将使用如下语句将文件上传到工件:
Write-Host "##vso[artifact.upload containerfolder=testresult;artifactname=worksoftHTML;]/home/vsts/work/1/s/output.html"
到目前为止,我已经尝试编写以下内容,但它不起作用:
File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"/home/vsts/work/1/s/output.md"), htmlResult);
还有这个:
File.WriteAllText("../home/vsts/work/1/s/output.md", htmlResult);
它也不起作用。请帮助。 我在管道中也尝试了以下方法,我将文件路径作为参数传递给命令行中的程序:
- task: CmdLine@2
env:
InputJSON: $(testJSON)
inputs:
script:
echo $(testJSON)
'jsonProcessor.exe $(Build.ArtifactStagingDirectory)\dropfile\,%INPUTJSON%'
workingDirectory: './jsonProcExe/'
在 exe 中,我正在编写如下文件:
File.WriteAllText(Path.Combine(filePath, @"output.html"), finalHtml);
然后在下一步中,我正在读取这样的文件:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
# Write your PowerShell commands here.
Write-Host "##vso[artifact.upload containerfolder=testresult;artifactname=worksoftHTML;]$(Build.ArtifactStagingDirectory)\dropfile\output.html"
但我仍然收到错误
Path does not exist: C:\agent\_work\1\a\dropfile\output.html
请注意,我使用的是自托管代理。
【问题讨论】:
标签: azure azure-devops