My new blog present here.

Featured Post

Insights into Sitecore Search: A Definitive Introduction

A key component of digital experience management is effective information retrieval. A simplified approach is required for websites, applications, and platforms containing a lot of material so that consumers can easily get the data they require. This need is met by Sitecore, a well-known name in the field of digital experience platforms (DXPs), which provides powerful and comprehensive search functionality. We will travel into the realm of Sitecore Search in this article, learning about its capabilities, architecture , and the enormous value it offers both developers and end users. Introduction to Sitecore Search    A headless content discovery platform powered by AI , Sitecore Search enables you to build predictive and custom search experiences across various content sources. To extract and index you

Speed Up Sitecore Upgrade with PackageReference

Now a day’s most of the organizations are following the path of Sitecore upgrade due to increase demand from Business side and organizations not able to execute demand using the old Sitecore version. 

In this case, organization need to go with Sitecore Upgrade, and I tried to explain the Sitecore Upgrade path at Sitecore Upgrade Process which includes:

Sitecore Upgrade Articles:
Sitecore Upgrade Process
Sitecore Content Migration Using Sitecore Express Migration Tool
Sitecore Content Migration Using Sitecore Content Serialization Tool
Sitecore xDB Migration Using Sitecore xDB Data Migration Tool

To do the Sitecore Upgrade, we also need to look into the code base upgrade (Solution Upgrade) part also, and this piece of work required lot of effort because legacy code base may have:
o Many Projects for which assemblies reference need to be changed to matched with latest .NET and Sitecore Version Framework
o Many Project can have references of assemblies from physical folder instead of Nuget Packages
o Unnecessary assemblies references

By considering some items from above list, it’s going to have FUN while doing Sitecore Upgrade every time 😊.

To avoid these issues and save time every time during Sitecore Upgrade, its better to switch your code base to PackageReference format with Central Package Versions.

PackageReference not provide official support for ASP.NET Web Application (.NET Framework) based projects, but you can use it 😊:
Package references, using the PackageReference node, manage NuGet dependencies directly within project files (as opposed to a separate packages.config file).
By default, PackageReference is used for .NET Core projects, .NET Standard projects. .NET Framework projects support PackageReference, but currently default to packages.config. To use PackageReference, migrate the dependencies from packages.config into your project file, then remove packages.config.
The Microsoft.Build.CentralPackageVersions MSBuild project SDK allows project tree owners to manage their NuGet package versions in one place. Stock NuGet requires that each project contain a version. You can also use MSBuild properties to manage versions.

You can convert your solution to use PackageReference instead of packages.config by following the article Migrate to PackageReference from packages config but I faced issue (please find below screenshot of error) so I followed the MANUAL approach:

In this article, we will explore:

Manual steps to convert your Sitecore Visual Studio Solution into PackageReference 
To proceed with MANUAL steps for converting your code base with use of PackageReference  and Central Package Versions at High-Level you have to follow below steps:
            
I will be explaining some steps which are annotated with numbers in the above flow diagram: To implement the Microsoft.Build.CentralPackageVersions the first step is to create the MSBuild project at the root of your repository named Packages.props that declares PackageReference items that set the versions for projects: The above Packages.props is an example, and we need to update Packages.props based on Step-6. In the Packages.props file PropertyGroup > SitecoreVersion and PropertyGroup > SitecorePreVersion used as a variable to store the specific versions of assemblies.

Now we will create a Directory.Build.targets at the root of your repository to use Microsoft.Build.CentralPackageVersions (use the latest version):
We have to remove the Import tag above which are marked with RED, and there are some Import related to some assemblies e.g. BuildBundlerMinifier which also needs to be removed: 

And for above type of Import assembly tag, we must insert PackageReference item for specific assembly in the Packages.props file after removing from .csproj file:


Reference tag’s which are not having HintPath you can keep it as is and remove rest of the Reference tag’s.
 
It’s always good to keep Reference tag’s and PackageReference tag’s separately in individual ItemGroup tag’s as a child elements:
Some assemblies references e.g., Microsoft.CodeDom.Providers.DotNetCompilerPlatform you can remove because once you remove it and reload the Project again then automatically VS Solution will add if required because these types of assemblies loads on the basis of Project Type.
The assemblies references which added in .csproj file as Reference under ItemGroup tag’s as a child elements will load without Nuget sign as highlighted with BLUE border in above image and assemblies references which added in .csproj file as PackageReference under ItemGroup tag’s as a child elements will load with Nuget sign as highlighted with GREEN border in above image.

If we have any assembly from \packages folder then we have to move those references from .csproj file to Packages.props if not present and in .csproj file change tag with PackageReference tag’s:

In step-6, we identified some assemblies which referenced from the \packages folder and we have moved those references from .csproj file to Packages.props if not present:

In step-6, we have seen some assemblies which added with Reference tags and would be added again when we reload the Project Solution again on the basis of Project Type.
After all, above steps if required assemblies reloaded then either remove or rename packages.config file from Project Solution.


Items that require your attention 
1 If you proceed with MANUAL steps for converting your code base with use of PackageReference (https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files) and Central Package Versions, then

 you must remove the Import tag above which are marked with RED, and there are some Import related to some assemblies e.g., BuildBundlerMinifier which also needs to be removed.
2 Don’t check-in your \packages into code repository.
3 After completing all the steps, you will find that \packages folder will not be having any assemblies:


4 To convert Sitecore Project Visual Studio solution from Sitecore 9.1 to Sitecore 10.0.0, I have used Microsoft Visual Studio Community 2019 (Version 16.11.6)

Sitecore Project Solution on GitHub 
I have upgraded Sitecore 9.1 Project Solution to Sitecore 10.0.0 Project Solution, and available for use at
Credit/References:


Pingback:

Sitecore public NuGet feed FAQ Nugetify your Sitecore References - Kam Figy How to reference and deploy Sitecore hotfix DLLs?
Excluding Sitecore assemblies using NuGet sc-packages - Sitecore.Assemblies.Platform Issue with Sitecore NuGet Package Install - XCentium
Sitecore How-To: Add Sitecore NuGet Packages to Your Project Save time updating Sitecore Nuget Packages Migrate to PackageReference from packages config
NuGet: To Reference, or to NoReference? That is the question what is sitecore project sitecore project example
sitecore project in visual studio sitecore project architecture sitecore helix project structure
sitecore sample project create sitecore project sitecore demo project
NuGet Package sitecore mvc example project sitecore feature foundation project
sitecore helix project template sitecore helix project layer sitecore habitat project
sitecore create helix project create sitecore mvc project setup sitecore mvc project
sitecore helix new project sitecore visual studio project setup c# project assembly reference
project missing assembly reference .net project assembly references project reference vs assembly reference
visual studio project assembly reference migrate to packagereference asp.net migrate solution to packagereference
nuget migrate to packagereference asp.net migrate packages.config to packagereference asp.net migrate all projects to packagereference
migrate packages.config to packagereference missing migrate packages.config to packagereference not working migrate nuget format to packagereference transitive dependencies
migrate nuget format to packagereference how to migrate to packagereference migrate to packagereference manually
nuget migrate to packagereference .net migrate to packagereference migrate packages.config to packagereference solution
visual studio migrate to packagereference migrate packages.config to packagereference visual studio 2019 sitecore 10 tutorial
sitecore .net developer sitecore for developers Sitecore kafka
Sitecore Hardware and software requirements Sitecore Sitecore Sizing Calculations Sitecore GraphQL Examples
How to use Sitecore SwitchOnRebuildSolrSearchIndex on Solr slave Indexes which are replicated from Master Index
Start using Sitecore GraphQL API Sitecore Helix Recommendation and Conventions - Helix 2.0 What’s new in Sitecore 10
Sitecore Graphql tutorial Sitecore Performance Tuning Sitecore GraphQl Examples
Upgrade to Sitecore 9 Sitecore Version 10 Sitecore 10 Upgrade
Sitecore Upgrade 9.0 to 9.3 Sitecore Upgrade Approach sitecore content migration
How to upgrade Sitecore CD environment Sitecore custom logs not working since upgrade Sitecore upgrade from 8.2 to 9.3
Sitecore upgrade from 8.2 to 9.2 Sitecore upgrade to 9.3 Sitecore upgrade 9.0 to 9.2
Sitecore upgrade from 8.2 to 9.1 Sitecore upgrade from 8.2 to 10 Sitecore upgrade azure
What is a Sitecore upgrade Sitecore content migration tools Content migration in Sitecore
Sitecore update center Sitecore upgrade from 6.6 to 10.1 Sitecore Migration
Sitecore upgrade guide Sitecore 10 upgrade guide Sitecore 9 upgrade guide
Sitecore upgrade book Sitecore 10 upgrade issues Sitecore JSS Upgrade
Sitecore update license file Sitecore powershell update Sitecore update package
Sitecore upgrade to 10 Sitecore 10 update installation Sitecore upgrade tool
Sitecore version upgrade Sitecore 9 why upgrade Sitecore 10 why upgrade
What is Sitecore upgrade How to upgrade Sitecore How to install Sitecore upgrade

Comments

Popular posts from this blog

Sitecore GraphQL Queries

Configuring Sitecore Next.js Headless SXA Multisite App in a Sitecore Container

Sitecore Experience Manager Cloud (XM Cloud) Building blocks