RestCode / WebApiProxy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changeset added bin\debug for loading WebApiProxy.Tasks.dll

onionhammer opened this issue · comments

On WebApiProxy-Generate-CSharp command:

Changeset

Add-Type -Path (Join-Path $projectPath "bin\Debug\WebApiProxy.Tasks.dll")

This can lead to errors as WebApiProxy.Tasks.dll isn't built/added to the bin/debug folder

\bin\Debug\WebApiProxy.Tasks.dll' because it does not exist.

Now I'm getting this

PM> WebApiProxy-Generate-CSharp
Cannot bind argument to parameter 'Path' because it is null.
    + CategoryInfo          : InvalidData: (:) [Add-Type], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddTypeCommand
    + PSComputerName        : localhost

Unable to find type [WebApiProxy.Tasks.Models.Configuration]. Make sure that the assembly that contains this type is loaded.
    + CategoryInfo          : InvalidOperation: (WebApiProxy.Tasks.Models.Configuration:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound
    + PSComputerName        : localhost

Cannot find type [WebApiProxy.Tasks.Infrastructure.CSharpGenerator]: verify that the assembly containing this type is loaded.
    + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
    + PSComputerName        : localhost

Generating proxy code...
You cannot call a method on a null-valued expression.
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
    + PSComputerName        : localhost

What version of Powershell & VS are you using?

Visual Studio 2015 on windows 8.1?

Weird I cannot seem to reproduce this. Just tested it on your config as well and it works. I did however make changes to the package file to include the libs on the correct build configuration inside the project

@onionhammer did you ever resolve this? I've now started getting this error as well despite it previously working fine?

Problem identified.

This will occur if you have multiple projects in your VS Solution. I have 3 projects in my Solution:

  • API
  • Class Library
  • MVC Application

The MVC app is the one on which i am trying to generate the proxy code however when i edited the WebApiProxyCSharp.psm1 file to print out the project path it is returning the path for my API project not the path of the MVC project the package is installed on and which has the references to WebApiProxy.Core and WebApiProxy.Tasks.

Anyone any advice on how to fix? I did try adding references to WebApiProxy.Core and WebApiProxy.Tasks to the other projects in my solution and but WebApiProxyCSharp.psm1 uses the project path to identify the config and output paths which are obviously in the API project not the MVC project where the package is installed.

The only solution i can think of at the moment is to install the package on the API project, generate the proxy code there and manually copy the generated file to the correct project but it doesn't make it particularly friendly to work with.