2
votes

Good day Stackoverflow.

As the title says, I have an issue with Doxygen.

Description

A PowerShell script modify the PROJECT_NUMBER variable of my Doxyfile.

Then it runs Doxygen, but it generates the documentation in HTML and LaTeX like it's reading a Default generated Doxyfile.

If I manually modify the Doxyfile before running this script, via Notepad++, Doxygen works perfectly, but once the script is ran, the issue appears.

I would also mention that my Doxyfile has:

  • GENERATE_HTML = YES
  • GENERATE_LATEX = NO
  • GENERATE_MAN = YES

In practice Doxygen behave like this:

.\doxygen.exe -g

\doxygen.exe .\Doxyfile

The bizzarre behaviour begins now!

Let's call my actual Doxyfile CustomConfig and the default generated DefaultConfig.

If I generate a DefaultConfig through .\doxygen.exe -g and then I overwrite its content with the text of CustomConfig via Notepad++, doxygen accepts the Doxyfile, as it should, and generates a correct output!

So the problem is not the Doxyfile content but PowerShell that modifies the file.

I've verified this by doing a simple copy&paste of the entire content:

  • Copy&Paste through Notepad++: WORK
  • Copy&Paste through PowerShell: DOESN'T WORK

PowerShell Script

# Replace the old PROJECT_NUMBER with the new one
$DOXY_PATH   = $env:FS_OS + "\doc"
$CONFIG_PATH = $DOXY_PATH + "\bin\Doxyfile"
$BIN_PATH    = $DOXY_PATH + "\bin\doxygen.exe"

$GIT_PATH    = $env:FS_OS
$GIT_BRANCH  = "Development"

# Get git commit number on the specified branch
$GIT_HASH   = git log $GIT_BRANCH -1 --pretty=format:%H

$PRJ_CONTENT = Get-Content $CONFIG_PATH
$PRJ_NUM = "PROJECT_NUMBER         = " + $GIT_HASH
$PRJ_CONTENT = $PRJ_CONTENT -replace "PROJECT_NUMBER\s*=\s*[A-z0-9]{40}",$PRJ_NUM
$PRJ_CONTENT | Out-File -FilePath $CONFIG_PATH

Start-Process -FilePath $BIN_PATH -ArgumentList "$CONFIG_PATH" -WorkingDirectory ($DOXY_PATH + "\bin")

Copy&Paste Script

$var = Get-Content "./doc/bin/Doxyfile.bak"
$var | Out-File -FilePath "./doc/bin/Doxyfile"
1
In the lower right hand corner of Notepad++ what does it say the file encoding is?BenH
@BenH thanks for the comment, I've found that PowerShell change the encoding from UTF-8 to UCS 2 BOM. Now I've specified -Encoding utf8 but it adds BOM automatically...Stefano Famà

1 Answers

1
votes

Thanks to @BenH for the comment, I've found the solution.

It looks like PowerShell writes to files automatically with BOM.

I've found a solution with the Accepted Answer from this question:

Using PowerShell to write a file in UTF-8 without the BOM