PentiaLabs / generator-helix

Generate Helix compliant solutions with Yeoman.
MIT License
40 stars 22 forks source link

ADD throws error - the term 'x86' is not recognized as the name of a cmdlet #94

Closed edouardr closed 7 years ago

edouardr commented 7 years ago

User story

I am using nodist that is installed under C:\Program Files (x86)\Nodist As specified, to use the module I have installed yoeman and generator-helix an both were installed correctly.

After setting up the solution with $ yo helix In an empty folder, I tried to create a new project.

Expected behavior

A new project should be created under the specified folder and added to the solution. No error should display in the terminal.

Actual behavior

Terminal displays the following output:

Powershell - running: C:\Program Files (x86)\Nodist\bin\node_modules\generator-helix\powershell\add-project.ps1 -SolutionFile 'C:\projects\sample-project\Sample-project.sln' -Name Foundation.ORM -Type Foundation -ProjectPath 'src\Foundation\ORM\code' -SolutionFolderName ORM
   create src\Foundation\ORM\code\Foundation.ORM.csproj
   create src\Foundation\ORM\code\Properties\AssemblyInfo.cs
Error: x86 : The term 'x86' 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:21

Error: + C:\Program` Files` (x86)\Nodist\bin\node_modules\generator-helix\powe ...
    +                     ~~~
    + CategoryInfo          : ObjectNotFound: (x86:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Powershell - done running C:\Program Files (x86)\Nodist\bin\node_modules\generator-helix\powershell\add-project.ps1-SolutionFile 'C:\projects\sample-project\Sample-project.sln' -Name Foundation.ORM -Type Foundation -ProjectPath 'src\Foundation\ORM\code' SolutionFolderName ORM

Project is actually created but not added to the solution.

Steps to reproduce the behavior

Within an admin bash I run the following command $ yo add:helix ORM

After answering all steps, I press enter to create the project.

Saturate commented 7 years ago

The problem here seems to be the path that nodist tries to read from C:\Program Files(x86)\ this goes wrong somehow, unfortunately it cuts off the error message so I can't see the full error path. It looks like it's one of the powershell modules.

For my machine node modules are located in C:\Program Files\nodejs\node_modules so maybe it's a 32bit issue or a nodist issue.

I'll do a bit more searching when it's weekdays again, if you can get the full error message, please add it here as it will help a lot.

Thanks for your report!

TakeitEasyAlan commented 7 years ago

@Hafeok Do you have time to look at this with @Saturate ?

Saturate commented 7 years ago

@edouardr can you try with a normal version of node? I suspect it's nodist, and would be nice to know if it's that.

edouardr commented 7 years ago

@Saturate I uninstalled Nodist and installed Node.js 32bit. Here are the tools and versions:

So now project is created and added to the solution, but I am getting an error that seems to be related to VS2017:

Powershell - running: C:\Users\Dev\AppData\Roaming\npm\node_modules\generator-helix\powershell\add-project.ps1 -SolutionFile 'C:\projects\sc-framework\Sc-Framework.sln' -Name Sc.Foundation.Sample -Type Foundation -ProjectPath 'src\Foundation\Sample\code' -SolutionFolderName Sample
   create src\Foundation\Sample\code\Sc.Foundation.Sample.csproj
   create src\Foundation\Sample\code\Properties\AssemblyInfo.cs
adding project Sc.Foundation.Sample

Error: Get-ItemProperty : Property MSBuildToolsPath does not exist at path
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0.
At C:\Users\Dev\AppData\Roaming\npm\node_modules\generator-helix\powershell\Get-MSBuildPath.ps1:5 char:69
+ ... ild\ToolsVersions\* | Get-ItemProperty -Name MSBuildToolsPath | where ...
+                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (MSBuildToolsPath:String) [Get-ItemProperty], PSArgumentException
    + FullyQualifiedErrorId : System.Management.Automation.PSArgumentException,Microsoft.PowerShell.Commands.GetItemPr
   opertyCommand

Error: Add-Type : Cannot bind parameter 'Path' to the target. Exception setting "Path": "Cannot find path
'C:\Microsoft.Build.dll' because it does not exist."
At C:\Users\Dev\AppData\Roaming\npm\node_modules\generator-helix\powershell\Get-SolutionConfigurations.ps1:10
char:20
+     Add-Type -Path "$msbuildPath\Microsoft.Build.dll"
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Add-Type], ParameterBindingException
    + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.AddTypeCommand

Error: Unable to find type [Microsoft.Build.Construction.SolutionFile].
At C:\Users\Dev\AppData\Roaming\npm\node_modules\generator-helix\powershell\Get-SolutionConfigurations.ps1:11
char:5
+     $solution = [Microsoft.Build.Construction.SolutionFile]::Parse($S ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Build...on.SolutionFile:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

Error: Get-ItemProperty : Property MSBuildToolsPath does not exist at path
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0.
At C:\Users\Dev\AppData\Roaming\npm\node_modules\generator-helix\powershell\Get-MSBuildPath.ps1:5 char:69
+ ... ild\ToolsVersions\* | Get-ItemProperty -Name MSBuildToolsPath | where ...
+                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (MSBuildToolsPath:String) [Get-ItemProperty], PSArgumentException
    + FullyQualifiedErrorId : System.Management.Automation.PSArgumentException,Microsoft.PowerShell.Commands.GetItemPr
   opertyCommand

Error: Add-Type : Cannot bind parameter 'Path' to the target. Exception setting "Path": "Cannot find path

Error: 'C:\Microsoft.Build.dll' because it does not exist."
At C:\Users\Dev\AppData\Roaming\npm\node_modules\generator-helix\powershell\Get-SolutionFolderId.ps1:12 char:20
+     Add-Type -Path "$msbuildPath\Microsoft.Build.dll"
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Add-Type], ParameterBindingException
    + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.AddTypeCommand

Error: Unable to find type [Microsoft.Build.Construction.SolutionFile].
At C:\Users\Dev\AppData\Roaming\npm\node_modules\generator-helix\powershell\Get-SolutionFolderId.ps1:13 char:5
+     $solution = [Microsoft.Build.Construction.SolutionFile]::Parse($S ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Build...on.SolutionFile:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

Error: Unable to find type [Microsoft.Build.Construction.SolutionProjectType].

Error: At C:\Users\Dev\AppData\Roaming\npm\node_modules\generator-helix\powershell\Get-SolutionFolderId.ps1:14 char:46

Error: + ... ere-object {$_.ProjectType -eq [Microsoft.Build.Construction.Solution ...

Error: +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Error:     + CategoryInfo          : InvalidOperation: (Microsoft.Build...tionProjectType:TypeName) [], RuntimeException

Error:     + FullyQualifiedErrorId : TypeNotFound

Error:

Error: Add-BuildConfigurations : Cannot bind argument to parameter 'Configurations' because it is null.

Error: At C:\Users\Dev\AppData\Roaming\npm\node_modules\generator-helix\powershell\add-project.ps1:39 char:67
+ ... figurations -ProjectPath $projectPath -Configurations $configurations
+                                                           ~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-BuildConfigurations], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Add-BuildConfigurations

Error: Get-ProjectConfigurationPlatformSection : Cannot bind argument to parameter 'Configurations' because it is null.
At C:\Users\Dev\AppData\Roaming\npm\node_modules\generator-helix\powershell\add-project.ps1:45 char:142

Error: + ... tionPlatformSection -Id $projectGuid -Configurations $configurations)

Error: +                                                          ~~~~~~~~~~~~~~~

Error:     + CategoryInfo          : InvalidData: (:) [Get-ProjectConfigurationPlatformSection], ParameterBindingValidationEx

Error:    ception

Error:     + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Get-ProjectConfigurationPlatformSection

Powershell - done running C:\Users\Dev\AppData\Roaming\npm\node_modules\generator-helix\powershell\add-project.ps1-SolutionFile 'C:\projects\sc-framework\Sc-Framework.sln' -Name Sc.Foundation.Sample -Type Foundation -ProjectPath 'src\Foundation\Sample\code' -SolutionFolderName Sample

As you said, it could be due to Nodist. I will try to reinstall and get you the full error message. I might just try to run the powershell directly.

Would you like me to raise a new issue regarding the one I mentioned in this comment?

Saturate commented 7 years ago

@edouardr Could you provide us with your powershell version?

edouardr commented 7 years ago

Hi @Saturate, sorry for my late answer. I did reinstall nodist and got the error message back.

$ yo helix:add Common Sc

     _-----_                                                                                                            
    |       |    ╭──────────────────────────╮                                                                           
    |--(o)--|    │    Lets generate that    │                                                                           
   `---------´   │         project!         │                                                                           
    ( _´U`_ )    ╰──────────────────────────╯                                                                           
    /___A___\   /                                                                                                       
     |  ~  |                                                                                                            
   __'.___.'__                                                                                                          
 ´   `  |° ´ Y `

? Name of your project. (Excluding layer prefix) Common                                                                 
? Would you like to include Unicorn (serialization)? No                                                                 
? Source code folder name src                                                                                           
? Enter optional vendor prefix Sc                                                                               
? What layer do you want to add the project too? Foundation layer?                                                      
? Enter optional Module Group                                                                                           
? Choose target .net framework version? .net 4.6.1                                                                      
Powershell - running: C:\Program Files (x86)\Nodist\bin\node_modules\generator-helix\powershell\add-project.ps1 -SolutionFile 'D:\_\sc-framework\Sc-Framework.sln' -Name Sc.Foundation.Common -Type Foundation -ProjectPath 'src\Foundation\Common\code' -SolutionFolderName Common                                                             
   create src\Foundation\Common\code\Sc.Foundation.Common.csproj                                                
   create src\Foundation\Common\code\Properties\AssemblyInfo.cs                                                         
Error: x86 : The term 'x86' 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.                         

Error: At line:1 char:21                                                                                                
+ C:\Program` Files` (x86)\Nodist\bin\node_modules\generator-helix\powe ...                                             
+                     ~~~                                                                                               
    + CategoryInfo          : ObjectNotFound: (x86:String) [], CommandNotFoundException                                 
    + FullyQualifiedErrorId : CommandNotFoundException                                                                  

Powershell - done running C:\Program Files (x86)\Nodist\bin\node_modules\generator-helix\powershell\add-project.ps1-SolutionFile 'D:\_\sc-framework\Sc-Framework.sln' -Name Sc.Foundation.Common -Type Foundation -ProjectPath 'src\Foundation\Common\code' -SolutionFolderName Common

I copied the script path that yeoman is trying to execute and the same happens when running the script in powershell. Please see below output

PS C:\WINDOWS\SysWOW64>  C:\Program Files (x86)\Nodist\bin\node_modules\generator-helix\powershell\add-project.ps1 -SolutionFile 'D:\_\sc-framework\Sc-Framework.sln' -Name Sc.Foundation.Common -Type Foundation -ProjectPath 'src\Foundation\Common\code' -SolutionFolderName Common

x86 : The term 'x86' 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:20                                                                                                       
+  C:\Program Files (x86)\Nodist\bin\node_modules\generator-helix\power ...                                             
+                    ~~~                                                                                                
    + CategoryInfo          : ObjectNotFound: (x86:String) [], CommandNotFoundException                                 
    + FullyQualifiedErrorId : CommandNotFoundException     

Obviously, we can see that quotes are missing for the script path. I then tried adding adding them and got lot more errors. I do expect, though, that it is because we are out of yeoman context in that case.

PS C:\WINDOWS\SysWOW64>  "C:\Program Files (x86)\Nodist\bin\node_modules\generator-helix\powershell\add-project.ps1" -SolutionFile 'D:\_\sc-framework\Sc-Framework.sln' -Name Sc.Foundation.Common -Type Foundation -ProjectPath 'src\Foundation\Common\code' -SolutionFolderName Common                                                        
At line:1 char:94                                                                                                       
+ ... les\generator-helix\powershell\add-project.ps1" -SolutionFile 'D:\_\s ...                                         
+                                                     ~~~~~~~~~~~~~                                                     
Unexpected token '-SolutionFile' in expression or statement.                                                            
At line:1 char:108                                                                                                      
+ ... olutionFile 'D:\_\sc-framework\Sc-Framework.sln' -Nam ...                                         
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                 
Unexpected token ''D:\_\sc-framework\Sc-Framework.sln'' in expression or statement.                     
At line:1 char:161                                                                                                      
+ ... le 'D:\_\sc-framework\Sc-Framework.sln' -Name Sc-Framework ...                                         
+                                             ~~~~~                                                     
Unexpected token '-Name' in expression or statement.                                                                    
At line:1 char:167                                                                                                      
+ ... \Sc-Framework.sln' -Name Sc.Foundation.Common -Type F ...                                         
+                              ~~~~~~~~~~~~~~~~~~~~                                                    
Unexpected token 'Sc.Foundation.Common' in expression or statement.                                             
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException                                   
    + FullyQualifiedErrorId : UnexpectedToken

Would you know a better way to run this?

edouardr commented 7 years ago

I have been digging into the code. I found the following in add/index.js l.239

var pathToAddProjectScript = path.join(this._sourceRoot, '../../../powershell/add-project.ps1');

Couldn't that be fixed with just

var pathToAddProjectScript = path.join('"', this._sourceRoot, '../../../powershell/add-project.ps1"');

?

TakeitEasyAlan commented 7 years ago

@edouardr we have had quite a bit of fun with "" vs ', power-shell vs JS, vs windows. but I will check it out, thanks for the feedback, look like it will be first Monday i can look at this .-)

TakeitEasyAlan commented 7 years ago

@edouardr, when i create a folder with (x86) and link to it using npm link, I can now also reproduce this issue :-(

TakeitEasyAlan commented 7 years ago

@edouardr unfortunately the change you suggest only causes outer issues :-(

TakeitEasyAlan commented 7 years ago

it is in fact the space followed by a ( that is causing the error.

Saturate commented 7 years ago

I created a PR, should be fix now :-)

Saturate commented 7 years ago

@TakeitEasyAlan will you release a new patch version aka 1.3.1?

edouardr commented 7 years ago

Awesome guys thanks for that! Will wait for the new release.

TakeitEasyAlan commented 7 years ago

At the dentist this morning, then have a deploy but hope to make a release this evening

Saturate commented 7 years ago

@edouardr it's released! :-)

edouardr commented 7 years ago

Hi guys. I have just tested now and confirm that I no more have the issue.

Thank you for your support!