I have a project consisting of few projects (one MVC Application and 3 class libraries for business logic and data access).
I am new to building scaffolding extension and was wondering if I can create a Custom Scaffolder which can generate
Controller, ViewModel and Views in my MVC Application Project
Add some files and folders in Other Projects, that are of type Class Library.
Until now, I have achieved the 1st target (it was fairly easy) but I am unable to find any method to add files to other projects.
I was wondering if there is no direct way of doing it, maybe I can just navigate to the folders in the directories of other projects and create the files. Then include them in my project manually.
P.S. I am using the basic scaffolder template by SideWaffle
Thanks for all the answers in advance.
Sorry, but this extension is no longer available, I have discontinued it
I created an extension for Visual Studio that lets you accomplish this with T4 Templates. You should be able to hit both targets but for number one you will need to do some extra work. I don't integrate with existing scaffolding stuff so you will have to write your own but my extension makes it easy. Its up on Visual Studio gallery and I have a demo/training video you can watch to see how to generate multiple files across multiple projects. Full disclaimer, I charge for this but do offer a free community version.
Related
I typically work on ASP.NET Core MVC projects, but am currently working on an Umbraco site. A difference I noticed, and don't understand, is that the .cshtml files in the Views folder (which are the Umbraco Templates) are only visible in the Folder View of the Solution Explorer. Why aren't they included in the project and visible in the normal Solution Explorer view like they are in a normal MVC project?
Example:
Folder View:
Normal Solution Explorer View:
It's typically because no one added them ;-) Joking aside, views can also be created via the Umbraco back office (in the browser) in which case the VS project doesn't really know about them until they are included.
The answer to this is because whatever is not included in your project, will not be released when you deploy through Visual Studio.
In a scenario where Continuous Integration exists and there are one click deployments going on with 'release' configurations (aka live environment configurations), when you right click on the project and click 'Publish' anything that's not included will be ignored from the release. That goes for models, Views, controllers, you name it.
It basically helps with big projects that have older views that you no longer needed (but for some reason the code should remain there).
How do I make a MVC project appear properly in Visual Studio? I understand the logic of this sort of structure. I have seen some blogs and explanations and even code segments explaining how a program can use MVC. But I want to know what is a good way to represent a Model-View-Controller program in the Visual Studio.
For example, in an ASP.NET program, the asp.net file is associated with a C# file. THey have the same name and, in the Solution Explorer window of the Visual Studio development environment, they are shown linked together where one is a tree branch of the other. Should the same sort of thing be done for a MVC solution? I can remember a few years ago, I worked on a MVVM project, and a developer who first put the solution file together actually had view and the view-model files arranged like this. In order to make this happen, he had to download some sort of patch that allowed him to edit the .sln (solution) file.
Is that the way to go for a Model-View-Controller program? Should each be its own workspace in the solution, or should the solution file be edited such that each Model-View-Controller coupling be handled as a tree structure file representation kind of like it is done for an ASP.NET solution?
Here is another question. What is a good template to use in Visual Studio to create an example of a Model-View-Controller program? I tried this route but when I clicked to "get new templates", it did not work:
http://i67.photobucket.com/albums/h292/Athono/Embedded/Capture_02_zps6vn4ri07.png
http://i67.photobucket.com/albums/h292/Athono/Embedded/Capture_zpscdczk1b4.png
From your screenshots, it looks like you're using an old version of Visual Studio (either 2008 or 2010, there isn't enough showing to be sure, but I see the default .NET framework listed as 3.5 up there).
The latest versions of the ASP.NET MVC framework requires .NET 4.5. Visual Studio 2010 doesn't support this, so the solution is to upgrade to a newer version of Visual Studio which includes support and project templates specifically for the latest versions of ASP.NET MVC.
I want to programmatically add class files to a c# project. Right now I'm thinking the fastest route may be to simply edit the xml file directly but I know there are api's for working with the project.
The thing is that I want to run an exe that just updates the file. I don't want to have to have the target project open in Visual Studio which is what it seems like is necessary with the automation interfaces used by add-ins.
So does anyone know how to do this with an api or am I stuck with working directly with the xml?
There is comprehensive support for T4 files which allow you programmatically generate files in the project, good example is Entity Framework templates for Self-Tracking entities and POCO, which you can get in the VS Gallery.
Also there are several good editors for T4 which allow you to have intellisence while editing templates
I want to create a VS2010 c# solution template generator and I'm looking for free/open tools to achieve this.
An example of what I'm trying to do is a winform application takes project name, namespace and database connectionstring and produce a c# customized solution with my custom classes, namespace and references.
I found those:
EnvDTE
Code Generation and T4 Text Templates
Is this the right way to do this? Do you know better tools?
You need to look at project templates. Normally you only get prompted for a project name (used as the solution name as well if creating a solution at the same time).
However the project template system can run code (as seen with C++ and ASP.NET MVC Projects).
There is a lot of information in the VS SDK, but you might find examining project templates that launch wizards useful to isolate the useful bits of documentation.
I have a VSPackage for Visual Studio 2008 that I created for adding some editor and custom language functionality. I also have a need to add a new project/solution wizard to create a new Solution and a complex series of C++ projects to the solution. I know I can do this using a "Custom Wizard", but I would be much happier if I can implement this within my VSPackage using C# instead.
So I guess the main question is, is it possible to add an entry to the Project Types dialogs in Visual Studio from a VSPackage? Or is the "Custom Wizard" and JScript my only option here?
And if it's possible, where can I find information and/or samples on how to accomplish this?
To add an entry to the Project Types dialog, you need to install a project template (a zip file containing a .vstemplate file) as part of your installation. You will want to do this from your setup routine rather than from the VSPackage itself.
However, your .vstemplate can invoke a wizard written in C#. Although this is indeed a "custom wizard," you can provide a reference to a .NET assembly. There is no need to use a scripting language.
For an example, see IronPython > C# Example.IronPythonProject in the VS2008 SDK browser. Unfortunately this demonstrates only limited wizard functionality and only for project items rather than projects, but I hope it will be useful all the same.