This boilerplate will get you started on creating a share-able Kentico MVC Component that you can publish to NuGet and to the marketplace. Everything is preconfigured and thanks to the RenameProject.bat
Setup only takes a couple minutes.
- Use this Template to create your own repostiory.
- Download your repository onto your computer (I highly recommend making a separate
Kentico Repositories
folder that is not connected to your Kentico Admin nor Kentico MVC instance) - Once downloaded, run the
RenameProject.bat
and enter in your project information - Open the Solution file, right click on your solution and Clean Solution
- Rebuild your solution
- note, if you get a Roslyn.exe error, clean and build the Views Web App separately, this sometimes happens
You are now ready to add your code and view files for your component.
It is recommended that for development of shareable content, you have a testing Kentico Instance, however this is not required. You can create a fresh installation of Kentico 12, just make sure it's hotfixed to the Service Pack (hotfix 29) You can also check out Kentico's repository which has it's own guide to creating a test instance.
Once you have your Kentico 12 SP instance set up:
- Open your Kentico MVC Web App's solution
- On the solution, right click and add Existing project, and select your Component Projects (View project is optional)
- On your MVC Web App, right click on references and add a reference to your Component project (not the View, just the code).
- Build your Component project, and the MVC Web Application Project
In the main component project, there is a BuildPackage.bat
file. Run this to create your nuget package. You can then upload it to NuGet.org
NOTE: The BuildPackage.bat is set to build only in release mode. Make sure your solution is set to Release and rebuilt in that mode
You may want or need to modify the following:
When publishing new versions, you will want to open up your Solution, right click on your Component Project, and go to the Properties page. You can click on "Assembly info" to update version and other information.
Modify the XXXX.nuspec file to add things such as Tags, Icons, release notes (you should update your release notes with what the update contains or the bug fixes perhaps). You may also need to add additional elements to include items beyond the Compiled Views library. Please see Microsoft Nuspec Documentation for more info.
Once you have your Repository updated and the NuGet package uploaded, you can perform a pull request to the Kentico Marketplace to include your tool on the listing.
There are 2 .Targets files, these can be modified to (on build) copy files to differnet projects. This is needed for the Compiled Views (which is already pre-configured for you), but you can also modify it to move other files over from your library to your development MVC web app project. Examples are given in the commented area.
Please remember, anything that needs to be exported with the nuget package needs to be handled in the nuspec file by copying the file into the Content location of the nuget package.