As part of the Sitecore codebase upgrade series, in this blog, we are going to deal with unused references and packages. It is worth to cleanup the unused references and nuget packages to reduce the complexity, dependencies and effort to upgrade to be compatible with target Sitecore version.
Remove Unused References:
Visual Studio 2019 has the inbuilt "Remove Unused References" option for .NET framework projects with .NET SDK project format and .NET core projects. If the project type is already in .NET SDK format, then right click on project or on the references and select Remove Unused References. Then select the list of references to remove and click Apply. As of Visual Studio 2019 v16.10.0, this option is turned off by default. To enable it, you can go to menu Tools > Options > Text Editor > C# > Advanced. Select the Remove Unused References command in Solution Explorer.
To remove Unused packages, you may want to get ReSharper which can clean up the unused references and also remove the unused packages. If ReSharper is installed, you can refactor the entire solution or a particular project. Right Click on the Solution > Refactor > Remove Unused References. This opens up a window with the list of references and packages and you can select and remove it. This will remove the entry from Packages.config or from PackageReferences if it is used.
There are other open source extensions in Visual Studio Gallery and few proprietary tools like CoreRush or Telerik® JustCode™ are available in the market which must be doing the same tasks.
No comments:
Post a Comment