T4MVC / R4MVC

R4MVC is a Roslyn code generator for ASP.NET Core MVC apps that creates strongly typed helpers that eliminate the use of literal strings in many places
Apache License 2.0
159 stars 48 forks source link

Hi! Sorry but , I have tha same error.... with version v1.0.0-alpha2-00365 #142

Open romanreal89 opened 4 years ago

romanreal89 commented 4 years ago

Hi! Sorry but , I have tha same error.... with version v1.0.0-alpha2-00365 What can I do, to fix it? Thank you!

PM> Generate-R4MVC -verbose R4Mvc Generator Tool v1.0.0-alpha2-00365 Using: Visual Studio Professional 2017 - 15.9.28307.858 Project: E:\Projects\Git Vero.Tenders\Vero.TendersNetCore.Web\Vero.TendersNetCore.Web.csproj Creating Workspace ... Loading project ... Compiling project ... The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: System.Management.Automation.RemoteException

Originally posted by @romanreal89 in https://github.com/T4MVC/R4MVC/issues/79#issuecomment-542119158

artiomchi commented 4 years ago

I'll make a patch this week so that it outputs any errors in powershell mode. There's most likely a project build or dependency error, which is why it's erroring out

artiomchi commented 4 years ago

Hi @romanreal89

I just pushed a CI build (377) that should finally display proper error messages from the Powershell script. Hopefully this will shed some light on why it's failing to generate the files in your project.

Please note that this is a CI build, so you will have to pull it from the CI repo (see instructions here) and restart Visual Studio for the new version to be picked up. You'll see the version of the script that runs in the first line of the output, to make sure you're running the new version.

Please let me know if this solved this issue (the lack of proper errors from Powershell) so that I know to merge this to production

romanreal89 commented 4 years ago

Hi, @artiomchi ! Thank you, but I didn't see this build. Last build is 369.

IanKemp commented 4 years ago

It's worse with the CI build (even less output, LOL):

PM> generate-r4mvc
  R4Mvc Generator Tool v1.0.0-ci-00377

Using: Visual Studio Enterprise 2019 - 16.6.30320.27
Project: <removed>.csproj

Creating Workspace ...
Loading project ...
Compiling project ...
Detected MVC version: 3.1.0.0

Processing controller ControllerName

Running the command manually (i.e. via .\R4Mvc.Tools.exe generate -p "<path\to\removed>.csproj") does yield output (see #154).

The reason is the $ErrorActionPreference = 'Stop' at the top of R4MVC.psm1. Stop means PS will immediately terminate the script on any error, which means the catch block is never entered (see https://stackoverflow.com/a/41518997/70345). I'd suggest just removing that $ErrorActionPreference = 'Stop' setting.

Alternatively, you can add -ErrorAction 'Continue' to the Write-Error in the catch block, but that output is far from useful:

Processing controller ControllerName
generate-r4mvc : 
At line:1 char:1
+ generate-r4mvc
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Generate-R4MVC