AzureDevOps.WikiPDFExport icon indicating copy to clipboard operation
AzureDevOps.WikiPDFExport copied to clipboard

Links between markdown pages don't work on DevOps pipeline build

Open PBoog opened this issue 3 years ago • 9 comments

Expected behaviour On my laptop I clone my wiki, put the WikiPDFExport binary in the root and run an export for a specific sub folder of the wiki using the following instruction:

./azuredevops-export-wiki.exe --b --path .\Index\Application-Troubleshooting --attachments-path .\.attachments

This generates an export.pdf in which links between my markdown pages work. For example in page /Index/Application-Troubleshooting/database.md I can specify a link like this

[Back to checklist](/Index/Application-Troubleshooting/checklist.md)

In the PDF it becomes a clickable link.

Issue If I do the same thing in an Azure devops pipeline the export.pdf is generated but none of the links between different markdown pages work.

Side note I have also noticed that running the WikiPDFExport binary without any parameters will correctly include images from .attachments on my laptop. However in the Azure pipeline I need to specify --attachments-path ./.attachments to get the images to show up.

Looks like a difference in run time environment but no idea what it could be ;) I have tried looking at the verbose output but that didn't help. Any thoughts on what could be causing this?

PBoog avatar Jun 20 '22 14:06 PBoog

Small update: I have tried a few different approaches in my devops pipeline

  • Powershell build task on Windows 2022 build agent
  • Bash build task on Ubuntu 22.04 build agent
  • WIKI PDF Exporter build task on both windows and ubuntu build agents

For all of them the links between markdown pages are not working.

PBoog avatar Jun 20 '22 15:06 PBoog

Further investigation: I have also tried with a build agent in a private pool but it suffers from the same issue. Looks like it might be something related to the environment of the Azure DevOps build agent?

PBoog avatar Jun 22 '22 09:06 PBoog

Using debug output I see a difference in the .html files. Locally I get links like this in the .html file: <li><a href="#checklist">Troubleshooting checklist</a></li>

On the build agent I get links like this in the .html file: <li><a href="/Index/Application-Troubleshooting/checklist.md">Troubleshooting checklist</a></li>

So it looks like the pipeline build agent is not able to properly convert the link paths to anchors. With verbose logging I see that there is a different behavior in the generation of the anchors.

Locally I get this output:

checklist.md
    Correcting Links and Images
    Markdown link: camera
    Correcting Links and Images
    Markdown link: redlight
    Correcting Links and Images
    Markdown link: sensorview
    Correcting Links and Images
    Markdown link: actuator
    Correcting Links and Images
      Anchor: checklist

On the build agent it is a bit different, it only creates anchors for the pages but not for the links on the page:

checklist.md
    Correcting Links and Images
    Correcting Links and Images
    Correcting Links and Images
    Correcting Links and Images
    Correcting Links and Images
      Anchor: checklist

Looking at the code in MarkdownConverter.cs I suspect it goes wrong with the path mapping to decide if it is a markdown file or not. The paths on the build agent look relatively normal: D:\a\1\s\Index\Application-Troubleshooting But there might be something else going on ;-)

PBoog avatar Jun 22 '22 13:06 PBoog

Update: To figure out what is going wrong I thought to add some log messages to see what happens. I'm using .NET 6.0 SDK with Visual studio 2022, publishing as a local Windows executable. I just pulled the code, opened the solution, added some log messages and compiled. Turns out my own compiled version does not have the issue.

So I suspect there is a difference in the way the release executable is getting built? I'm stumped as to what is going on but happy to help reproduce or investigate. In any case I have a workaround by using my own compiled version ;)

PBoog avatar Jul 04 '22 15:07 PBoog

do you run it on windows or linux?

MaxMelcher avatar Jul 18 '22 13:07 MaxMelcher

My own build that does not have the issue is done on Windows. It works locally and in a Microsoft Azure DevOps pipeline.

For the release build that I downloaded from github:

  • The windows build works locally on my laptop
  • The windows build does not create links when running in a Microsoft Azure DevOps pipeline
  • The linux build does not create links when running in a Microsoft Azure DevOps pipeline

PBoog avatar Jul 27 '22 08:07 PBoog

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 25 '22 13:09 stale[bot]

Thank you stale bot but this one is still open :)

PBoog avatar Sep 26 '22 07:09 PBoog

Thanks for keeping this on the backlog @MaxMelcher, if you need any further tests from my side please let me know.

PBoog avatar Oct 10 '22 06:10 PBoog

Fixed in af0a226d787fe91314b2ab0a387ffbe754ba4d54

MaxMelcher avatar Nov 17 '22 22:11 MaxMelcher