MaxMelcher / AzureDevOps.WikiPDFExport

Export Azure DevOps Wiki to PDF
MIT License
186 stars 62 forks source link

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

Closed PBoog closed 1 year ago

PBoog commented 2 years ago

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 commented 2 years ago

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

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

PBoog commented 2 years ago

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 commented 2 years ago

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 commented 1 year ago

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 ;)

MaxMelcher commented 1 year ago

do you run it on windows or linux?

PBoog commented 1 year ago

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:

stale[bot] commented 1 year ago

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.

PBoog commented 1 year ago

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

PBoog commented 1 year ago

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

MaxMelcher commented 1 year ago

Fixed in af0a226d787fe91314b2ab0a387ffbe754ba4d54

stale[bot] commented 1 year ago

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.