Pre/Post Install scripts need to have LF line endings #33

Open
opened 2026-01-29 16:27:44 +00:00 by claunia · 2 comments
Owner

Originally created by @clemensv on GitHub (Sep 4, 2018).

The install scripts lifted from the XML build info need to have LF endings. Currently, CRLF from Windows authors csproj gets carried over and causes syntax errors

The conversion should also strip trailing/leading whitespace that's an artifact of XML formatting, e.g.

<PostInstallScript>
   statement
   statement
   if [ cond ]; then
       statement
   fi
</PostInstallScript>

should strip

  • the first line break and any whitespace leading up to it (right after )
  • "shared whitespace" of all statements (i.e. the first three spaces of each line)
  • any trailing whitespace of any line
  • the final line break and any whitespace leading up to it and after it
Originally created by @clemensv on GitHub (Sep 4, 2018). The install scripts lifted from the XML build info need to have LF endings. Currently, CRLF from Windows authors csproj gets carried over and causes syntax errors The conversion should also strip trailing/leading whitespace that's an artifact of XML formatting, e.g. ``` xml <PostInstallScript> statement statement if [ cond ]; then statement fi </PostInstallScript> ``` should strip * the first line break and any whitespace leading up to it (right after <PostInstallScript>) * "shared whitespace" of all statements (i.e. the first three spaces of each line) * any trailing whitespace of any line * the final line break and any whitespace leading up to it and after it
Author
Owner

@qmfrederik commented on GitHub (Sep 4, 2018):

Regarding CRLF/LF, we can/should probably do a string.Replace to always normalize to LF.

On the other hand, regarding whitespace, I have a feeling that doing too much 'magic' (like removing 'shared whitespace') can have unintended side-effects.

What about:

  • Just wrapping the PostInstallScript contents in a CDATA element, like this:
<PostInstallScript><![CDATA[statement
statement
if [ cond ]; then
    statement
fi]]></PostInstallScript>
  • Instead of inlining the script in the .csproj file, sourcing it from another file (e.g. <PostInstallScript Path="myfile.sh"/>)?
@qmfrederik commented on GitHub (Sep 4, 2018): Regarding CRLF/LF, we can/should probably do a `string.Replace` to always normalize to LF. On the other hand, regarding whitespace, I have a feeling that doing too much 'magic' (like removing 'shared whitespace') can have unintended side-effects. What about: - Just wrapping the PostInstallScript contents in a `CDATA` element, like this: ```xml <PostInstallScript><![CDATA[statement statement if [ cond ]; then statement fi]]></PostInstallScript> ``` - Instead of inlining the script in the `.csproj` file, sourcing it from another file (e.g. `<PostInstallScript Path="myfile.sh"/>`)?
Author
Owner

@clemensv commented on GitHub (Sep 5, 2018):

I like sourcing from another file best. That's what I effectively resort to now by including a script and calling it. The step should ideally copy the content but not require the file to be included in the output.

@clemensv commented on GitHub (Sep 5, 2018): I like sourcing from another file best. That's what I effectively resort to now by including a script and calling it. The step should ideally copy the content but not require the file to be included in the output.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/dotnet-packaging#33