Deployment without the Xperience by Kentico administration is currently not supported when deploying to SaaS. The scenario described on this page applies only to private cloud deployments.
Xperience and all related dependencies are installed via NuGet packages. The installed packages dictate the features available to each project. However, not all packages are required for Xperience sites to run in production environments.
The Xperience administration interface (installed via the Kentico.Xperience.Admin NuGet package) and all related customizations can be removed when publishing to production. In these types of environments, you can have:
Advantages |
|
Disadvantages |
|
Limitations and workarounds |
|
In the most basic scenario, you can set up and deploy Xperience without the administration manually:
However, in most cases, we recommend that you integrate the separation into an automated publishing script or pipeline.
This section outlines an approach that modifies the application's build process to remove the Kentico.Xperience.Admin NuGet package and all related dependencies, including custom code intended only for the administration. The demonstrated approach is suitable for use in publishing scripts or automation pipelines.
Edit your Xperience application's .csproj file and add a new AdminAttached MSBuild property (opens in a new tab):
<PropertyGroup>
<TargetFramework> <!-- ... --> </TargetFramework>
<RootNamespace> <!-- ... --> </RootNamespace>
<!-- Defines an MSBuild property that defaults to true
if not explicitly passed to MSBuild as a parameter -->
<AdminAttached Condition="'$(AdminAttached)' == ''">true</AdminAttached>
</PropertyGroup>Add the following condition to the Kentico.Xperience.AspNetCore.Admin package reference using the Condition attribute:
<ItemGroup>
...
<!-- If the specified condition evaluates to true (true by default), the project maintains this package reference -->
<PackageReference Include="kentico.xperience.admin" Version="..." Condition="'$(AdminAttached)' == 'true'" />
</ItemGroup>Follow a similar process to remove any custom code when customizing the administration interface or some of its components. Assuming your code follows best practices for admin UI customization outlined in Admin UI customization model overview, your administration-related code is located in isolated assemblies/NuGet packages, making the process straightforward. Repeatedly add the Condition attribute to all relevant references:
<!-- Project assembly references -->
<ItemGroup>
...
<ProjectReference Include="..\Acme.Web.AdminCustomCode.csproj" Condition="'$(AdminAttached)' == 'true'" />
</ItemGroup>
<!-- Project package references -->
<ItemGroup>
...
<PackageReference Include="Emca.Web.AdminCustomCode" Version="..." Condition="'$(AdminAttached)' == 'true'" />
</ItemGroup>If you also need to make specific code outside dedicated assemblies run only when the administration is attached, declare a conditional compilation constant and use it as required:
<PropertyGroup Condition="'$(AdminAttached)' == 'true'">
<DefineConstants>$(DefineConstants);ADMIN_ATTACHED</DefineConstants>
</PropertyGroup>#if ADMIN_ATTACHED
// Surrounded code only compiles when administration dependencies are present
#endifYou can also invert this condition to run code only when the administration is detached. However, do not use such conditions to remove your project's live site implementation or presentation logic from the administration instance. Such logic is required by certain administration features, such as the preview mode for website channel pages.
When you need to publish the project without admin UI packages and dependencies, pass AdminAttached=false as a parameter to MSBuild:
dotnet publish -c Release -p:AdminAttached=false --output <OUTPUT_DIRECTORY>The output directory now contains the published application minus the dependencies marked by the AdminAttached condition.