An Example of Creating a Orchard Core Content Management System Application using NuGet packages with Visual Studio
In this article, you're going to see how easy it is to get Orchard Core running in your very own ASP.NET Core Web Application using Visual Studio. You’ll be using the power of the Orchard Core NuGet packages to simplify the process.
First, launch Visual Studio, and create a new ASP.NET Core Web Application:
Select the box button at the lower left of the screen, “Create a new project”.
Select the ASP.NET Core Web Application that is highlighted in blue and press the “Next” button.
Enter a project name, location, and a solution name. It’s customary to add a “.Web” to specify the project is a web application. The Solution can be whatever you decide. Anther customary practice is to put all the source code in a root “src” folder. Again, it’s up to you to decide how you want to structure your code.
At the time of writing this article, Orchard Core is based on ASP.NET Core version 3.0. Make sure you select “ASP.NET Core 3.0” in the top right combo. Select the “Empty” template and then press the “Create” button.
In order to utilized the latest code, use the dev packages, by adding the Orchard Core Preview Feed. Create the fie “NuGet.config” in the root folder and add the following configuration.
Nuget.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="Orchard Core Preview Feed" value="https://www.myget.org/F/orchardcore-preview/api/v3/index.json" />
</packageSources>
</configuration>
Modify Startup Code and Add the Orchard Core Preview Feed to your NuGet Package Manager Package Sources
Update code block to add Orchard Core CMS.
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace MyOrchardCoreCMS.Web
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddOrchardCms();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseOrchardCore();
}
}
}
Right Click on "Dependemncies" and select "Manage NuGets Packages".
Click on the gear icon in the Nuget Package Manager.
Verify the Orchard Core Preview Feed package source is the first entry and that the URL is correct. Name: Orchard Core Preview Feed Source: https://www.myget.org/F/orchardcore-preview/api/v3/index.json Press "OK" to continue.
Select the “Browse” tab in the NuGet Package Manager Window. Enter “OrchardCore.Application.CMS.Targets” in the Search edit box. Make sure the check box “Include prereleases is checked.
Select the package “OrchardCore.Application.CMS.Targets”
Press the “install” button.
Wait until all the packages are installed.
Allow Visual Studio to make changes by selecting the “OK” button.
Select the “I Accept” button to accept the license agreement.
Select “MyOrchardCoreCMS.Web” and click on the green play button to run the application.
Select “Yes” button to trust the self-signed certificate.
Select “Yes” button to install certificate.
A logging window will appear displaying debug information.
Congratulations! Your Orchard Core Web Application will now be running in the default web browser.
A Setup page will be displayed. Enter the “name of your site”, “Blog” for Recipe, your “default time zone”, “Sqlite” for the database, a “user name” and password. Press the “Finish Setup” button to complete the process.
Navigate to the admin dashboard page by specifying “/admin” at the end of the URL. i.e. https://localhost:5001/admin. Login with your credentials.
Enter in your credentials and press the "Log in" button.
You are now ready to configure and create content for your Orchard Core Web Application.
With just a new few lines of code and some configuration, it is easy to create a Content Management System with ASP.NET Core and Orchard Core CMS.
The complete source code is located here.