Resetting Sitefinity Project Name
sitefinity | 2022-10-20
How to Change the Project Name
Error: "Invalid root node configured for pages."
Intro
If you're trying to reset or change your Sitefinity project's name (for example, from "name" to "SitefinityWebApp"), you might encounter the error: "Invalid root node configured for pages."
This guide will walk you through the steps to successfully change the project name and fix any issues that arise during the process.
✅ Steps to Execute Script:
Pre-requisite: Create a backup of the site database before proceeding with the following steps
-
Change the name in the App_Data/Sitefinity/Configuration folder:
Modify the file ProjectConfig.config to the new desired project name (in this example, "SitefinityWebApp").
-
Ensure there is no duplicate ProjectConfig.config in the database:
Execute the following SQL query to check for duplicates:
select * from sf_xml_config_items where path = 'ProjectConfig.config'
If there is another copy of ProjectConfig.config in the sf_xml_config_items table, and it contains the projectName property, make sure to apply the changes there as well.
-
Find the current project name saved in the database:
Run the following query to retrieve the actual project name that needs to be changed:
select app_name from sf_schema_vrsns
The result of the query will show what is the current project name that must be changed. Note, the name will be followed by ' / '. The project name follows the naming convention "any name" there is a slash at the end.
-
Automate the process of changing the project name:
Use the following SQL script to change the project name in all database tables:
SET NOCOUNT ON DECLARE @stringToFind VARCHAR(100) DECLARE @stringToReplace VARCHAR(100) DECLARE @schema sysname DECLARE @table sysname DECLARE @count INT DECLARE @sqlCommand VARCHAR(8000) DECLARE @where VARCHAR(8000) DECLARE @columnName sysname DECLARE @object_id INT SET @stringToFind = 'cwp-sf-base' SET @stringToReplace = 'SitefinityWebApp' DECLARE TAB_CURSOR CURSOR FOR SELECT B.NAME AS SCHEMANAME, A.NAME AS TABLENAME, A.OBJECT_ID FROM sys.objects A INNER JOIN sys.schemas B ON A.SCHEMA_ID = B.SCHEMA_ID WHERE TYPE = 'U' ORDER BY 1 OPEN TAB_CURSOR FETCH NEXT FROM TAB_CURSOR INTO @schema, @table, @object_id WHILE @@FETCH_STATUS = 0 BEGIN DECLARE COL_CURSOR CURSOR FOR SELECT A.NAME FROM sys.columns A INNER JOIN sys.types B ON A.SYSTEM_TYPE_ID = B.SYSTEM_TYPE_ID WHERE OBJECT_ID = @object_id AND IS_COMPUTED = 0 AND B.NAME IN ('char','nchar','nvarchar','varchar','text','ntext') OPEN COL_CURSOR FETCH NEXT FROM COL_CURSOR INTO @columnName WHILE @@FETCH_STATUS = 0 BEGIN SET @sqlCommand = 'UPDATE ' + @schema + '.' + @table + ' SET [' + @columnName + '] = REPLACE(convert(nvarchar(max),[' + @columnName + ']),''' + @stringToFind + ''',''' + @stringToReplace + ''')' SET @where = ' WHERE [' + @columnName + '] LIKE ''%' + @stringToFind + '%''' EXEC( @sqlCommand + @where) SET @count = @@ROWCOUNT IF @count > 0 BEGIN PRINT @sqlCommand + @where PRINT 'Updated: ' + CONVERT(VARCHAR(10),@count) PRINT '----------------------------------------------------' END FETCH NEXT FROM COL_CURSOR INTO @columnName END CLOSE COL_CURSOR DEALLOCATE COL_CURSOR FETCH NEXT FROM TAB_CURSOR INTO @schema, @table, @object_id END CLOSE TAB_CURSOR DEALLOCATE TAB_CURSOR
-
Restart the sitefinity
After running the script, restart your Sitefinity site to apply the changes.
-
Test Sitefinity Modules:
Ensure that all modules on the site open and function properly. Changing the project name can impact Sitefinity modules.
-
Verify Modules in the Sitefinity Backend:
Open all backend screens in Sitefinity to check for any errors. If no errors are shown, the process is completed successfully.