Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Substitute use of IsPathFullyQualified to restore Windows PowerShell compatibility #60

Merged
merged 2 commits into from
Sep 16, 2022

Conversation

joshooaj
Copy link
Contributor

Description

The Initialize-PSBuild function was not compatible with .NET Framework / PowerShell 5.1 due to the use of the System.IO.Path.IsPathFullyQualified() method, introduced with the fix for #27. I changed the function to check if the value of OutDir already started with BHProjectPath rather than testing if OutDir was a fully qualified path on its own.

This seems to have solved the issue and tests are passing. Also, changing the value of $PSBPreference.Build.OutDir seems to result in the same behavior before and after the change introduced in this PR, though I don't think any tests were introduced to specifically test the original fix so I'm not 100% certain this is the best solution.

Related Issue

Issue #53

Motivation and Context

I still regularly work with PowerShell 5.1 due to legacy .NET Framework dependencies that I'm required to use. I began to use the Stucco module for setting up my modules, but I cannot call .\build.ps1 from Windows PowerShell because the PowerShellBuild Initialize-PSBuild command calls a method that is not available in .NET Framework. I am now using this modified version of PowerShellBuild.

How Has This Been Tested?

I verified that I can build modules using the Stucco template on Windows using Windows PowerShell, and PowerShell 7, as well as Ubuntu on WSL2 using PowerShell 7. I tested these builds with and without a custom $PSBPreference.Build.OutDir value set in my psakefile.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

The Initialize-PSBuild function was not compatible with .NET Framework / PowerShell 5.1 due to the use of the System.IO.Path.IsPathFullyQualified method. I changed the function to check if the value of OutDir already started with BHProjectPath rather than testing if OutDir was a fully qualified path on it's own. This seems to have solved the issue and tests are passing.
@HeyItsGilbert
Copy link
Contributor

I was using a dummy VM for a demo (on how to use Stucco) and it looks like I ran into the same issue.

@devblackops
Copy link
Member

Thanks for the fix @joshooaj!

Copy link

@LarryWisherMan LarryWisherMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appears to fix error thrown when using Powershell 5.1

@joshooaj joshooaj deleted the remove-ispathfullyqualified branch March 15, 2024 13:58
HeyItsGilbert added a commit that referenced this pull request Oct 6, 2024
### Changed

- Bump Pester to latest 5.6.1

### Fixed

- [**#52**](#52) Pester
object wasn't being passed back after running tests, causing the Pester
task to never fail (via [@webtroter](https://github.com/webtroter))
- [**#55**](#55) Add
`-Module` parameter to `Build-PSBuildUpdatableHelp` (via
[@IMJLA](https://github.com/IMJLA))
- [**#60**](#60) Fix
Windows PowerShell compatibility in `Initialize-PSBuild` (via
[@joshooaj](https://github.com/joshooaj))
- [**#62**](#62) Fix code
coverage output fle format not working (via
[@OpsM0nkey](https://github.com/OpsM0nkey))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants