PostInstallScript and PostRemoveScript properties not respecting Condition #82

Open
opened 2026-01-29 16:28:50 +00:00 by claunia · 1 comment
Owner

Originally created by @GROSU1 on GitHub (Jun 11, 2020).

I noticed that the conditions for scripts are not being respected and are not adding the content. The only way to add data in the scripts is to remove the condition attribute altogether. Also tried to use the Path attribute to add a separate file script as mentioned in this issue but getting error MSB4066: The attribute "Path" in element <PostRemoveScript> is unrecognized.

 <PostRemoveScript Condition="$(InstallService.Equals('true', StringComparison.OrdinalIgnoreCase))">systemctl daemon-reload;</PostRemoveScript>

Also tried only with PostInstallScript and PostRemoveScript so I don't know if this is affecting pre scripts as well.

Originally created by @GROSU1 on GitHub (Jun 11, 2020). I noticed that the conditions for scripts are not being respected and are not adding the content. The only way to add data in the scripts is to remove the condition attribute altogether. Also tried to use the `Path` attribute to add a separate file script as mentioned in [this issue](https://github.com/qmfrederik/dotnet-packaging/issues/76) but getting `error MSB4066: The attribute "Path" in element <PostRemoveScript> is unrecognized.` ```xml <PostRemoveScript Condition="$(InstallService.Equals('true', StringComparison.OrdinalIgnoreCase))">systemctl daemon-reload;</PostRemoveScript> ```` Also tried only with `PostInstallScript ` and `PostRemoveScript` so I don't know if this is affecting pre scripts as well.
Author
Owner

@aaronegger commented on GitHub (Nov 19, 2021):

There is a substitute for the not working path attribute at the script tag.
To read files you can use $([System.IO.File]::ReadAllText($path"))

Example:
<PreInstallScript>$([System.IO.File]::ReadAllText("preinst"))</PreInstallScript> <PostInstallScript>$([System.IO.File]::ReadAllText("postinst"))</PostInstallScript> <PreRemoveScript>$([System.IO.File]::ReadAllText("prerm"))</PreRemoveScript> <PostRemoveScript>$([System.IO.File]::ReadAllText("postrm"))</PostRemoveScript>

@aaronegger commented on GitHub (Nov 19, 2021): There is a substitute for the not working path attribute at the script tag. To read files you can use $([System.IO.File]::ReadAllText($path")) Example: ` <PreInstallScript>$([System.IO.File]::ReadAllText("preinst"))</PreInstallScript> <PostInstallScript>$([System.IO.File]::ReadAllText("postinst"))</PostInstallScript> <PreRemoveScript>$([System.IO.File]::ReadAllText("prerm"))</PreRemoveScript> <PostRemoveScript>$([System.IO.File]::ReadAllText("postrm"))</PostRemoveScript> `
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/dotnet-packaging#82