I am trying to do some processing inside a C# console application and that file has to be saved:
File.WriteAllText("C:\JSONOutput\output.md"), htmlResult);
I want save it to Azure DevOps folder like '/home/vsts/work/1/s/' so that it can be accessed again in the next step where I am uploading the file to artifacts using a statement like below:
Write-Host "##vso[artifact.upload containerfolder=testresult;artifactname=worksoftHTML;]/home/vsts/work/1/s/output.html"
So far I have tried by writing the following but it is not working:
File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"/home/vsts/work/1/s/output.md"), htmlResult);
and this also:
File.WriteAllText("../home/vsts/work/1/s/output.md", htmlResult);
It is also not working.Please help. I have tried the following as well in the pipeline where I am passing the filepath as a parameter to the program in command line:
- task: CmdLine@2
env:
InputJSON: $(testJSON)
inputs:
script:
echo $(testJSON)
'jsonProcessor.exe $(Build.ArtifactStagingDirectory)\dropfile\,%INPUTJSON%'
workingDirectory: './jsonProcExe/'
Inside the exe I am writing the file like below:
File.WriteAllText(Path.Combine(filePath, @"output.html"), finalHtml);
And then in the next step I am reading the files like this:
- 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"
But still I am getting the error
Path does not exist: C:\agent\_work\1\a\dropfile\output.html
Please note that I am using a self hosted agent.