PentiaLabs / generator-helix

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

Error: Add-Type : Cannot bind parameter 'Path' to the target. #107

Closed edouardr closed 6 years ago

edouardr commented 7 years ago

User story

In PS console, after having created an empty helix solution, I want to add a new project using yo helix add:ProjectName

Expected behavior

Project being created with the correct template without errors in the PS console.

Actual behavior

Error is thrown right after executing the command. *.csproj file is created with the App_Config folder, but that's it.

Steps to reproduce the behavior

Create an empty solution:

PS C:\_\test> yo helix

     _-----_
    |       |    ╭──────────────────────────╮
    |--(o)--|    │  Welcome to the kickass  │
   `---------´   │     Helix generator!     │
    ( _´U`_ )    ╰──────────────────────────╯
    /___A___\   /
     |  ~  |
   __'.___.'__
 ´   `  |° ´ Y `

? What type of solution do you want to create? Empty Helix solution
? Name of your Helix solution test
? Source code folder name src
? Choose target .net framework version? .net 4.6.1
? Enter the local website URL http://test.local
   create src\Project\Project-layer.md
   create src\Feature\Feature-layer.md
   create src\Foundation\Foundation-layer.md
   create test.sln

Add a new project:

PS C:\_\test> yo helix:add Coffee.Website

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

? Name of your project. (Excluding layer prefix, name can not be empty) Coffee.Website
? Would you like to include Unicorn (serialization)? Yes
? Source code folder name src
? Enter optional vendor prefix
? What layer do you want to add the project too? Project 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 'C:\_\test\test.sln' -Name Project.Coffee.Website -Type Project -ProjectPath 'src\Project\Coffee.Website\code' -SolutionFolderName Coffee.Website
   create src\Project\Coffee.Website\code\Project.Coffee.Website.csproj
   create src\Project\Coffee.Website\code\Properties\AssemblyInfo.cs
   create src\Project\Coffee.Website\code\App_Config\Include\Project.Coffee.Website\serialization.config
adding project Project.Coffee.Website

The following error is thrown:

Error: Add-Type : Cannot bind parameter 'Path' to the target. Exception setting "Path": "Cannot find path 'C:\Microsoft.Build.dll' because it

Error: does not exist."

Error: At C:\Program Files (x86)\Nodist\bin\node_modules\generator-helix\powershell\Get-SolutionConfigurations.ps1:10 char:20

Error: +     Add-Type -Path "$msbuildPath\Microsoft.Build.dll"
Error: +                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Error:     + CategoryInfo          : WriteError: (:) [Add-Type], ParameterBindingException
Error:     + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.AddTypeCommand

Error:
Error: Unable to find type [Microsoft.Build.Construction.SolutionFile].
Error: At C:\Program Files (x86)\Nodist\bin\node_modules\generator-helix\powershell\Get-SolutionConfigurations.ps1:11 char:5

Error: +     $solution = [Microsoft.Build.Construction.SolutionFile]::Parse($S ...
Error: +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Error:     + CategoryInfo          : InvalidOperation: (Microsoft.Build...on.SolutionFile:TypeName) [], RuntimeException
Error:     + FullyQualifiedErrorId : TypeNotFound

Environment

Name : ConsoleHost Version : 5.0.10240.17443 InstanceId : 271dbffe-62b6-4188-9cfd-bc30e5ca132d UI : System.Management.Automation.Internal.Host.InternalHostUserInterface CurrentCulture : en-AU CurrentUICulture : en-US PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy DebuggerEnabled : True IsRunspacePushed : False Runspace : System.Management.Automation.Runspaces.LocalRunspace

* NPM v 4.0.5
* Node v 6.10.2
* Windows 10
* Generator Helix

PS C:_\test> npm list -g C:\Program Files (x86)\Nodist\bin +-- generator-helix@1.3.2


* Yeoman yo@2.0.0
TakeitEasyAlan commented 7 years ago

Sorry to hear that, I am out of the office today and will be back after lunch tomorrow when I hope I will get time to look at this, unless @Hafeok you have time today?

netojoa commented 7 years ago

Have you guys sorted this out? I am getting the same error.

Cannot bind parameter 'Path' to the target. Exception setting "Path": "Cannot find path 'X:\Microsoft.Build.dll' because it does not exist."

edouardr commented 7 years ago

@JANeto87 unfortunately no. Could I ask what's your environment?

Because I tried in another computer with similar config and could not reproduce. I am trying to find the difference between working and non working environment.

netojoa commented 7 years ago

@edouardr, I am using:

Please see the images below:

System Information system information

Visual Studio visual studio

Microsoft.Net Framework folder microsoft net framework folder

Microsoft.Build in Framework folder microsoft build in framework folder

Microsoft.Build disassembled, SolutionFile class not found microsoft build disassembled solutionfile class not found

Hafeok commented 7 years ago

Hey,

Can you try and run this form a powershell console? Resolve-Path HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions* | Get-ItemProperty -Name MSBuildToolsPath

This is the way we are resolving the paths to the msbuild directories right now. And i think that if you only have VS 2017 installed it might not support that.

netojoa commented 7 years ago

Please, find below:

untitled

Hafeok commented 7 years ago

Yeah, okay - so we need to enable a better way to find the msbuild path, that works with the new VS 2017 structure.

If you want it to work right now, you can install the Microsoft Build Tools 2015 https://www.microsoft.com/en-us/download/details.aspx?id=48159

And ill add a new Issue so that we can it fixed.

The issue is that with the new 2017 installer Microsoft changed the entire eco system of the msbuild installation paths. So we used to lookup the latest installs from the registry, which they changed now.

Anyways the installation of the Microsoft Build Tools should fix it for you.

netojoa commented 7 years ago

I've installed MSBuild Tools 2015, but it still doesn't work.

addproject

msbuidl

TakeitEasyAlan commented 6 years ago

Actually the ability to add visual studio specific modules is not being used, so we will review if this feature should be removed

TakeitEasyAlan commented 6 years ago

Discussion moved to #109