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

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

Closed
ghost opened this issue Jul 2, 2024 · 5 comments · Fixed by #18021
Labels
Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Help Wanted We encourage anyone to jump in on these. In-PR This issue has a related PR Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Tag-Fix Doesn't match tag requirements Product-Meta The product is the management of the products.
Milestone

Comments

@ghost
Copy link

ghost commented 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
@ghost ghost added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Jul 2, 2024
@zadjii-msft
Copy link
Member

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)

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jul 10, 2024
@ghost
Copy link
Author

ghost commented Jul 10, 2024

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

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      22621  3672

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Jul 10, 2024
@zadjii-msft
Copy link
Member

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 zadjii-msft added Help Wanted We encourage anyone to jump in on these. Product-Meta The product is the management of the products. Issue-Task It's a feature request, but it doesn't really need a major design. Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. and removed Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Attention The core contributors need to come back around and look at this ASAP. labels Jul 11, 2024
@zadjii-msft zadjii-msft added this to the Backlog milestone Jul 11, 2024
@zadjii-msft zadjii-msft changed the title Unable to build Windows Terminal in Powershell Importing the OpenConsole.psm1 module should display an error message when used on Windows PowerShell 5 Jul 11, 2024
@ghost
Copy link
Author

ghost commented 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.

@microsoft-github-policy-service microsoft-github-policy-service bot added the In-PR This issue has a related PR label Oct 10, 2024
@DHowett
Copy link
Member

DHowett commented Oct 10, 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

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Tag-Fix Doesn't match tag requirements label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Help Wanted We encourage anyone to jump in on these. In-PR This issue has a related PR Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Tag-Fix Doesn't match tag requirements Product-Meta The product is the management of the products.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants