ligershark / side-waffle

A collection of Item- and Project Templates for Visual Studio
Other
656 stars 205 forks source link

cannot generate scaffolded in visual studio 2015 #330

Open phamthaithinh opened 8 years ago

phamthaithinh commented 8 years ago

Without Sidewaffle all generate well. But after install T4 template to project cannot generate anymore

sayedihashimi commented 8 years ago

What happens then? Do you get an error?

phamthaithinh commented 8 years ago

Yes it show error as below: Severity Code Description Project File Line Error Compiling transformation: Invalid expression term 'else' mvctemplate c:\Users\phamt\Documents\Visual Studio 2015\Projects\WebApplication3\WebApplication3\CodeTemplates\MvcView\Create.cs.t4 2

wkrasl commented 8 years ago

I have the same problem while following MVA course "Build Responsive UI with Bootstrap," module 4 "Visual Studio and ASP.NET Integration," near timestamp 00:33:45. To follow along, I installed SideWaffle today, modified "CodeTemplates/MvcView/List.cs.t4" as shown in the presentation, and tried to add the AlbumsController scaffold. However I got a similar error in the unmodified Create.cs.t4 file.

I spent some time trying to debug Create.cs.t4 without success, so I started over: deleted the entire CodeTemplates folder, saved and closed the solution to get rid of the persistent MvcView error, reopened the solution, added SideWaffle back in, and tried again to add the AlbumsController scaffold without modifying List.cs.t4. No luck... same error in Create.cs.t4.

So I started over again: deleted the entire CodeTemplates folder, saved and closed the solution to get rid of the persistent MvcView error, reopened the solution, added SideWaffle back in, and deleted Create.cs.t4. This time, when trying to add AlbumsController scaffold, the error moved to Edit.cs.t4. I am attaching a screen shot of the error.

2016-03-19 5

I posted the problem in the MVA forum for "Building Responsive UI with Bootstrap" in a thread started by someone else (who could proceed by deleting both Create.cs.t4 and Edit.cs.t4). See http://trainingsupport.microsoft.com/en-us/tcmva/forum/tcmvacoursefdbk-tcmvavisual/part-4-of-the-building-responsive-ui-with/92b2d873-8338-4f11-af53-f400a4c371da?auth=1.

But otherwise I am giving up and just editing my views manually until you guys fix this issue.

brgrz commented 8 years ago

Even the most simple use case doesn't work. Installing SideWaffle ASP.NET T4 templates to a project then trying to add a Create view for a view model.

Error

There was an error running the selected code generator:

'Failed to render template because of the following errors:

''Compiling transformation: } expected' at line number '168' and column number '33','Compiling transformation: } expected' at line number '537' and column number '33''.'

sidewaffle

brgrz commented 8 years ago

Using templates for Details view does work however.

sayedihashimi commented 8 years ago

Here is what I tried

  1. File New Project - ASP.NET MVC
  2. Add ASP.NET T4 files
  3. Modify Empty controller t4 file
  4. Add New Scaffolded Item - Empty Controller

The controller was added with my customizations fine.

I went ahead and refreshed the t4 files and created a new vsix at https://ci.appveyor.com/project/sayedihashimi/side-waffle/build/1.21.404/artifacts.

I'm wondering what's different from what I'm doing versus you. Are you running VS Community edition by chance?

brgrz commented 8 years ago

@sayedihashimi as you can see from the screenshot @wkrasl attached and my posting we were both having issues wtih the View templates. Please also give it a try with MvcView templates.

Other than that, I am in fact using VS Community. I am also VS Enterprise user but I'll be only able to try it out with VS Enterprise tomorrow. Will let you know how it goes.

brgrz commented 8 years ago

I just tried the latest vsix build with VS Community and it results in the following error when I try to add the ASP.NET T4 Scaffolding files

image

sayedihashimi commented 8 years ago

Thanks for the notes.

This sounds like a bug in Visual Studio community edition and not SideWaffle. I would expect that you get the same result if you copied .t4 template files from C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding\Templates\ into CodeTemplates in your project.

When you use SideWaffle in that scenario all it is doing is dropping the files in the right folder. When you invoke the Add New Scaffolded item dialog from there it's responsible for what happens after that.

I'll open a bug on in https://github.com/aspnet/Tooling for this.

sayedihashimi commented 8 years ago

OK I've opened https://github.com/aspnet/Tooling/issues/585. Let's us that for follow up going forward.

I'd be interested in hearing over there if any .t4 file works with VS Community edition, maybe that's the issue?

brgrz commented 8 years ago

@sayedihashimi Do you think this should be reported to VS's Connect rather than on ASP.NET Core tooling site?

sayedihashimi commented 8 years ago

No this is better in the repo put it in. My team should do initial investigation since we own ASP.NET scaffolding. If T4 doesn't work at all in Community that's good for Connect.

AudeR commented 8 years ago

The following error occurs after the ASP.net scaffolding T4 files are in the project while attempting to add a new scaffolding item in Visual studio 2015 community MVC project.

image

This error does not occur if the THE T4 files have not been added

sayedihashimi commented 8 years ago

Reopening based on https://github.com/ligershark/side-waffle/issues/384#issuecomment-231462578 for discoverability here.

habyphael commented 8 years ago

had a similar problem with the model that I was trying to use. I commented out the OnModelCreating override, then I could add the scaffolded item, and uncommented the OnModelCreating ovveride and ran the program it worked.

rdskill-dev commented 7 years ago

so... here we are in Q1 of 2017 and this is still and issue. Fricken amazing.

VS 2015 Community and Sidewaffle v1.21.400

Compiling transformation: } expected (Lines 169 and 538)