Importing the OpenConsole.psm1 module should display an error message when used on Windows PowerShell 5 #21927

Closed
opened 2026-01-31 07:58:31 +00:00 by claunia · 5 comments
Owner

Originally created by @ghost on GitHub (Jul 2, 2024).

Windows Terminal version

1.20.11381.0

Windows build number

10.0.22631.0

Other Software

No response

Steps to reproduce

Under Developer Guidance, I made sure that I had the prerequisites:

  • Running Windows 11 Home, 10.0.22631 N/A Build 22631
  • Developer Mode has been enabled
  • Powershell build: 22621, revision: 3672
  • Windows 11 (10.0.22621.0) SDK is installed
  • Installed Build Tools for Visual (VS without the IDE)
  • Skipped .NET framework targeting pack

I updated the repository with git submodule update --init --recursive

In Powershell, Import-Module .\tools\OpenConsole.psm1 works since I updated the Execution policy for my LocalMachine to run scripts. However, Set-MsBuildDevEnvironment and Invoke-OpenConsoleBuild don't work and return a CommandNotFoundException.

Expected Behavior

The following commands from Building the Code should build the application

Import-Module .\tools\OpenConsole.psm1
Set-MsBuildDevEnvironment
Invoke-OpenConsoleBuild

Actual Behavior

Instead both return:

Set-MsBuildDevEnvironment : The term 'Set-MsBuildDevEnvironment' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Set-MsBuildDevEnvironment
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Set-MsBuildDevEnvironment:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Invoke-OpenConsoleBuild : The term 'Invoke-OpenConsoleBuild' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Invoke-OpenConsoleBuild
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Invoke-OpenConsoleBuild:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Originally created by @ghost on GitHub (Jul 2, 2024). ### Windows Terminal version 1.20.11381.0 ### Windows build number 10.0.22631.0 ### Other Software _No response_ ### Steps to reproduce Under **Developer Guidance**, I made sure that I had the prerequisites: - Running Windows 11 Home, 10.0.22631 N/A Build 22631 - Developer Mode has been enabled - Powershell build: 22621, revision: 3672 - Windows 11 (10.0.22621.0) SDK is installed - Installed Build Tools for Visual (VS without the IDE) - Skipped .NET framework targeting pack I updated the repository with `git submodule update --init --recursive` In Powershell, `Import-Module .\tools\OpenConsole.psm1` works since I updated the Execution policy for my LocalMachine to run scripts. However, `Set-MsBuildDevEnvironment` and `Invoke-OpenConsoleBuild` don't work and return a `CommandNotFoundException`. ### Expected Behavior The following commands from [Building the Code](https://github.com/microsoft/terminal/tree/2fa7445b003068cf433a388015cc1f1b01a0a6cd?tab=readme-ov-file#building-the-code) should build the application ``` Import-Module .\tools\OpenConsole.psm1 Set-MsBuildDevEnvironment Invoke-OpenConsoleBuild ``` ### Actual Behavior Instead both return: ``` Set-MsBuildDevEnvironment : The term 'Set-MsBuildDevEnvironment' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + Set-MsBuildDevEnvironment + ~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Set-MsBuildDevEnvironment:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException ``` ``` Invoke-OpenConsoleBuild : The term 'Invoke-OpenConsoleBuild' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + Invoke-OpenConsoleBuild + ~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Invoke-OpenConsoleBuild:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException ```
Author
Owner

@zadjii-msft commented on GitHub (Jul 10, 2024):

Which version of PowerShell are you using? "Windows PowerShell" (powershell.exe), version 5? Or PowerShell "Core" (pwsh.exe), version 7+/? (you can find this with $PSVersionTable.PSVersion)

@zadjii-msft commented on GitHub (Jul 10, 2024): Which version of PowerShell are you using? "Windows PowerShell" (`powershell.exe`), version 5? Or PowerShell "Core" (`pwsh.exe`), version 7+/? (you can find this with `$PSVersionTable.PSVersion`)
Author
Owner

@ghost commented on GitHub (Jul 11, 2024):

@zadjii-msft, I am using Windows PowerShell version 5:

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      22621  3672
@ghost commented on GitHub (Jul 11, 2024): @zadjii-msft, I am using Windows PowerShell version 5: ``` Major Minor Build Revision ----- ----- ----- -------- 5 1 22621 3672 ```
Author
Owner

@zadjii-msft commented on GitHub (Jul 11, 2024):

Well yep that explains it. You need to use PowerShell 7+.

I'll convert this issue to "the powershell module should display an error if you try to import it in Powershell 5"

@zadjii-msft commented on GitHub (Jul 11, 2024): Well yep that explains it. You need to use PowerShell 7+. I'll convert this issue to "the powershell module should display an error if you try to import it in Powershell 5"
Author
Owner

@ghost commented on GitHub (Jul 11, 2024):

I've installed PowerShell 7+. So I reattempted these commands:

Import-Module .\tools\OpenConsole.psm1
Set-MsBuildDevEnvironment
Invoke-OpenConsoleBuild

When I use Import-Module .\tools\OpenConsole.psm1, it works fine. However, Set-MsBuildDevEnvironment returns

Import-Module: The specified module '\Common7\Tools\Microsoft.VisualStudio.DevShell.dll' was not loaded because no valid module file was found in any module directory.

. I've included to my environment variables C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools and C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\ for MSBuild. But, still, I don't know why the above error is happening.

Invoke-OpenConsoleBuild returns

Error parsing solution file at C:\Users\<user>\Desktop\v1-logic\options-tactical\eng-cmp--dev_sec_ops\.desktop-instance\4-projects-workflow\dev_sec_ops__native\_terminal\OpenConsole.sln: Exception has been thrown by the target of an invocation.
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
msbuild.exe: The term 'msbuild.exe' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
@ghost commented on GitHub (Jul 11, 2024): I've installed PowerShell 7+. So I reattempted these commands: ``` Import-Module .\tools\OpenConsole.psm1 Set-MsBuildDevEnvironment Invoke-OpenConsoleBuild ``` When I use `Import-Module .\tools\OpenConsole.psm1`, it works fine. However, `Set-MsBuildDevEnvironment` returns ``` Import-Module: The specified module '\Common7\Tools\Microsoft.VisualStudio.DevShell.dll' was not loaded because no valid module file was found in any module directory. ``` . I've included to my environment variables `C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools` and `C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\` for MSBuild. But, still, I don't know why the above error is happening. `Invoke-OpenConsoleBuild` returns ``` Error parsing solution file at C:\Users\<user>\Desktop\v1-logic\options-tactical\eng-cmp--dev_sec_ops\.desktop-instance\4-projects-workflow\dev_sec_ops__native\_terminal\OpenConsole.sln: Exception has been thrown by the target of an invocation. The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. msbuild.exe: The term 'msbuild.exe' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. ```
Author
Owner

@DHowett commented on GitHub (Oct 11, 2024):

You know, I actually don't think this module requires PowerShell 7! I just tried it on 5.1 and it works fine... /cc @michaeljsxu

@DHowett commented on GitHub (Oct 11, 2024): You know, I actually don't think this module requires PowerShell 7! I just tried it on 5.1 and it works fine... /cc @michaeljsxu
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#21927