This project is read-only.

Visual Studio Extension for Orchard

Topics: Announcements, General
Dec 1, 2014 at 9:10 PM
Edited Dec 11, 2014 at 9:24 PM
Code available on GitHub:

Hey guys,

For the last few months I've been using a visual studio extension for Orchard development. I built it 6 months ago and haven't really changed it since then. I meant to release it but.... it is full of bugs, and then some more bugs. And I haven't really felt the motivation to improve on it, EnvDTE and the whole extension development is a bit of a pain in the ass to be honest. But I've found it to be a little useful, so I thought I'd just mention it on here... would be cool to get any feedback if anyone is interested I guess. Might get me off my ass and complete it :)


Create a module from visual studio.



It builds it from a template, if you are running an older version of Orchard it will try to run the codegen command.


Allows you to create a theme from the UI.




You may say, what the hell is really the point, just use codegen. Well, I'm lazy. And I don't like the command line. That's basically it. The theme one gives you a few extra options, like a help file full of links to random docs and blog posts about theming in Orchard. I like to be reminded sometimes. And for the slackers at work to read, but they never do. Bastards.


You can add a new "Scaffolded item":


I've managed to get that into a sub menu called Orchard now. (Yay?) Select that and you get...


Tick some boxes, write down your fields, bish bash bosh, generates all your bits and bobs. You can select either: Record storage, infoset storage, or both. You can also select a migrations file to use from a cool drop down that crashes visual studio for a few seconds to populate itself. Totally worth it. So yeah, this just generates:
  • Driver
  • Handler
  • Editor view
  • Display view
  • Placement (new file or an entry in the existing file, totally fucks up if your placement file is invalid)
  • Migrations (if you choose to)
Cuts out a little bit of boilerplate stuff I guess. I used to use Piotr's awesome Codegen Extensions module but I don't think it has been updated to support the new infoset syntax. And god forbid taking the easy route and updating his module with that tiny change. No siree, we need a new motherfucking visual studio extension for that shit.


Generate content type settings from the ui via the scaffolded item menu again


Pretty simple, select the part you want to create settings for and write in your settings. Part dropdown is populated in some cool way that I cant remember that is probably prone to failing to find your parts so I may add a text box that lets you write in your part name manually, just in case...


Select a class, click Generate Migrations, and it'll pop up this window:


Choose the class you want to generate migrations for and pick a migrations class/create a new one, then you get this screen:


This finds all the properties and displays them in this grid that you can then customize. It tries to be smart by deselecting things that probably are not going to go into the database, like lists. And it will try to anticipate when you are referencing another model and add the nhibernate mapping syntax (eg. SecondModel_Id). Show details offers a few more customizations, letting you make it nullable or not null and selecting a default value. It then generates the migrations from these. Sometimes. As you can imagine, it's a bit retarded and flaky.

I think most will agree this is the most boring code to write...
private readonly IOrchardServices _orchardServices;
public AdminController(IOrchardServices orchardServices) {
    _orchardServices = orchardServices;
So I made a small extension using Roslyn that will inject the dependency into the constructor for you. I haven't merged it into the main stuff, and I'm not sure it will work well because you need the Roslyn preview stuff to run it and I don't know how that will affect the extension as a whole, I'll have to look into it.

I also looked into resolving dependencies that live in unreferenced projects, as you get quite a lot of that with Orchard. However, it was extremely slow because it searched everything in the solution, which is a shit ton of files, so I think I need to do some sort of indexing thing when Orchard is loaded into VS to make it faster. But I'm retarded so don't think I'll ever complete that one. Or maybe Roslyn will provide such functionality out of the box? That would be nice.

Some ideas for improving things:
  • Add another page to the migrations generation wizard for foreign keys, that syntax always confuses me in the code
  • Add a preview page of the migrations code it will generate so you can fix it/laugh at the pathetic attempt it made to write code and then just do it yourself
  • Add side waffle templates (although I have just found Orchard Seeds extension so maybe this is pointless: Orchard Seeds
  • Give up?
So, yeah, if you've reached this far and gone, what a dick, just use the bloody orchard command line and stop fucking around, then I have good news for you.


Right click your Orchard solution and you can open the Orchard command interface!

You may also notice the "build precompiled" command there. I'm not sure how people deploy Orchard, I'm really fucking inexperienced here but that is the command I use, then I ftp it to the server and winmerge it (my boss has a habit of changing views and style sheets without telling me and bitter experience has taught me to be better safe than sorry... I'm also terrified of accidentally fucking everything up and winmerge never fucks my shit up :D ). So yeah, having that command there seemed to make sense for me :)

Let me know your thoughts! Or just say hi, that's cool too.

PS Fucking codeplex is a pain in the ass. No image uploader? Preview wiped my discussion twice? +1 for moving to discourse and GitHub from me, and I'm the biggest Microsoft ass kissing whore you'll ever meet.
Dec 2, 2014 at 12:12 AM
Whoah!! This is awesome, really cool dude.

Is the code somewhere?
Dec 2, 2014 at 3:41 PM
Seems great! Will check it out!
Dec 2, 2014 at 4:34 PM
You should demo it during the Weekly Steering Committee.
Dec 2, 2014 at 4:58 PM
Took a look and tried to run a compile -- the vsix manifest shows a project called ThemeCreator that it couldn't find, so I couldn't get a build. Can you add that to the source repository as well, or should I just yank that from the manifest?

Leading to that, though, I had to make a small tweak to tag the platform targets as x86 (rather than the default MSIL) to match wth Microsoft.AspNetScaffolding.12.0. That, and I told it to not embed the stdole interop module, since that made it too dependent on compiler version.
Dec 2, 2014 at 5:20 PM
Hey guys, I didn't even realise I had uploaded the code on my codeplex, that is pretty old, and looks very broken haha. I will upload a newer version sometime this week. Sorry for the confusion.
Dec 9, 2014 at 1:19 AM
Hey, just a little update, I'm annoyingly busy at the moment, and I tried to upload it last week but I discovered way too many bugs, so many. I couldn't face the embarrassment of uploading something so bloody broken. And then the time I meant to spend fixing all the bugs... I actually spent playing around with Roslyn. Sorry about that. But it's getting there. I really do hope to get something up for anyone who wants to play with it by the end of this working week.

On a side note, Roslyn. It really is pretty sweet. I've been using EF a bit recently and do rather like their commands for updating the database. So I was like, let's build that for Orchard. So I sort of tried gutting out the migrations files with Roslyn, and running them in my own little workspace with my own references to build a sort of map of what the database would look like at the end of the migrations and then compare that to all the models available to see how they match up and then offer any additions/deletions via a ui. That was the plan. Unfortunately, I don't think I have the brains to pull it off. And since people can write whatever shit they like in migrations files well, that can fuck everything up haha. Why am I telling you this? Mainly because no one else I have excitedly told about this awesome plan has really shared my enthusiasm for it, so I'm resorting to boring you guys with my immature rambling ideas.

Anyway... I'll post a link to a download (of the extension, not my retarded orchlyn-migration-builder-extreme-pro-automatron (patent pending)) soon!
Dec 9, 2014 at 8:12 AM
Hazza, your posts crack me up everytime.... :)
Dec 9, 2014 at 2:11 PM
It's a sneaky ploy to use bad jokes to distract you from the fact I have produced absolutely nothing, unless bombastic promises count.
Dec 11, 2014 at 9:23 PM
So, I have fixed a few of the bugs. There are still quite a lot of outstanding issues, and by that I mean a shit ton. I have uploaded the code to GitHub, since it seems Codeplex is not receiving any love from Microsoft anymore.

I'd beg you to not judge me by the awful mess and general disgusting standard of my coding, but well I guess that is the whole point of putting yourself out there in the big open source world. And I have no excuses, I'm a retarded evil little bastard of a coder.

I've also uploaded a zip containing the vsix installer if you just want to dive right in. I think all you need to do is unzip, double click the vsix file and it should install. I tried to work out what msawczyn was saying in his comment about platform targets and I'm sure I should heed his advice but... I don't really understand what I'm doing so I've sort of not done anything about that stuff.!32900&authkey=!AKyQmPTFCr6-Trc&ithint=file%2czip

So what is up there? Pretty much all the stuff I've blathered on about, apart from the Roslyn stuff. I've improved a few little bits, like adding environment variables so build commands can be run. Hopefully I did more than that, but I cant really remember

Frustrating, known bugs:
  • Migrations don't seem to save after they've been edited by the extension
  • I think I broke the theme generation command and the project files it creates are missing the rootnamespace
  • Generate Migrations command appears everywhere, on so many files... my bad
  • I spazzed out and made the ui for the module creator tiny. Damn draggable editors ><
  • The UIs in general need some work, especially the migrations ones. I've never used the WPF stuff before. I suck at it. Sorry
  • General broken state of it all
What I'm working on:
  • Option to generate parts etc. for a specific feature
  • Foreign key UI for migrations
  • Option to skip the migration preview screen (maybe?)
  • Scaffold fields (not sure how useful this would be, I don't think I've ever made my own field haha)
  • Include a few more templates that Orchard Seeds does not contain (I tried unsuccessfully to contact the author and made an extremely useless attempt to send a PR on github, then gave up because I felt retarded)
In terms of Roslyn:
  • I'm not 100% sure but I think including Roslyn with the extension and trying to run it without the Roslyn CTP installed causes it to fail, which sucks.
  • I have the Dependency Injection code fixer working okay, I'll put that online next week as a separate extension
  • Resolving dependencies from other unreferenced projects is sort of going somewhere, it is incredibly slow first time, but I guess it is then in memory or something and is very quick to find classes and stuff. However, I haven't quite worked out the right place to inject the UI, so when an error occurs because it cant find a referenced codetype. Meh, I'm sure it is very obvious.
  • I gave up on building EF for Orchard with Roslyn, I was getting too obsessed with doing lots of work with Visual Studio development to save myself very little work in Orchard development. /sigh
Anyway, I guess give it a try. It works sporadically. Moan about bugs on GitHub, or here, I'll probably ignore them regardless of where you report them.

Dec 13, 2014 at 11:27 AM
Im proud of you Harry. Migrating from Wally on Dilbert to something more ... (less lazy!), unless this is your plan to get back to being lazy ... which, sounds like you?!
Jan 27, 2015 at 4:31 PM
The moment I'm sure you have all been waiting for has finally arrived, it is now live on the Visual Studio Gallery. Yay?

So what has changed? Nothing, I just kind of forgot to push it to the gallery.

Enjoy! And ignore the retardedly shaped Create Module box, I still haven't fixed that. Report any problems on GitHub!
Jan 29, 2015 at 6:59 PM
It looks great!!

The code Orchadizer generates is compatible with Orchard 1.7.1?
Jan 29, 2015 at 8:05 PM
Yeah, should be. So long as you choose record only storage, not info set of course ^_^ the module and theme stuff should also work as it falls back to the codegen commands if you're orchard version is too old, though I believe 1.7 doesn't need that fall back stuff

Sent from my Windows Phone

Feb 17, 2015 at 9:21 AM
Cool stuff Hazza! I had exactly the same issues (being lazy)

One note for creating a theme based on another theme, it adds the following line to Theme.txt:
BasedOn: TheOtherTheme
While it should be:
BaseTheme: TheOtherTheme
Feb 18, 2015 at 10:06 AM

Thanks, yeah someone reported that on GitHub and I'll push a fix for it shortly. Planning to provide a few additional features in the next release:
  • OrchardFeature support
  • Import/Export generation
Feb 20, 2015 at 2:26 PM
Edited Feb 20, 2015 at 2:26 PM
Thanks, yeah someone reported that on GitHub
It was I also :)
Feb 24, 2015 at 5:25 PM
Aha, cheers for that ^_^ I've released a small update to address a few bugs, can get the latest version from the gallery here :