File tree Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,27 @@ private void AddPnPApp()
121121 }
122122 WriteObject ( result ) ;
123123 }
124+ catch ( ServerException ex ) when ( ex . Message . Contains ( "CSPConfig" ) && ex . Message . Contains ( "100000" ) )
125+ {
126+ // Handle the specific CSPConfig error when deploying to site collection app catalog
127+ // This is a known SharePoint service-side limitation where tenant-level script sources
128+ // are incorrectly included in site-level CSP validation
129+ manager . Remove ( result , Scope ) ;
130+
131+ var errorMessage = "Failed to deploy the app due to a SharePoint limitation. " +
132+ "The error 'Value of: [CSPConfig] cannot exceed: [100000]' occurs when there are too many " +
133+ "Trusted Script Sources configured at the tenant level, and SharePoint incorrectly includes " +
134+ "them when validating site collection app catalog deployments.\n \n " +
135+ "Workarounds:\n " +
136+ "1. Add the app without publishing (remove the -Publish parameter) and manually publish it later through the SharePoint UI.\n " +
137+ "2. Reduce the number of Trusted Script Sources at the tenant level.\n " +
138+ "3. Contact Microsoft Support to request a fix for this service-side issue.\n \n " +
139+ "For more information, see:\n " +
140+ "- https://github.com/SharePoint/sp-dev-docs/issues/10412\n " +
141+ "- https://github.com/SharePoint/sp-dev-docs/issues/10369" ;
142+
143+ throw new Exception ( errorMessage , ex ) ;
144+ }
124145 catch
125146 {
126147 // Exception occurred rolling back
Original file line number Diff line number Diff line change @@ -91,7 +91,29 @@ private void PublishPnPApp()
9191 var app = Identity . GetAppMetadata ( ClientContext , Scope ) ;
9292 if ( app != null )
9393 {
94- manager . Deploy ( app , SkipFeatureDeployment , Scope ) ;
94+ try
95+ {
96+ manager . Deploy ( app , SkipFeatureDeployment , Scope ) ;
97+ }
98+ catch ( ServerException ex ) when ( ex . Message . Contains ( "CSPConfig" ) && ex . Message . Contains ( "100000" ) )
99+ {
100+ // Handle the specific CSPConfig error when deploying to site collection app catalog
101+ // This is a known SharePoint service-side limitation where tenant-level script sources
102+ // are incorrectly included in site-level CSP validation
103+ var errorMessage = "Failed to publish the app due to a SharePoint limitation. " +
104+ "The error 'Value of: [CSPConfig] cannot exceed: [100000]' occurs when there are too many " +
105+ "Trusted Script Sources configured at the tenant level, and SharePoint incorrectly includes " +
106+ "them when validating site collection app catalog deployments.\n \n " +
107+ "Workarounds:\n " +
108+ "1. Manually publish the app through the SharePoint UI (navigate to Site Contents > App Catalog).\n " +
109+ "2. Reduce the number of Trusted Script Sources at the tenant level.\n " +
110+ "3. Contact Microsoft Support to request a fix for this service-side issue.\n \n " +
111+ "For more information, see:\n " +
112+ "- https://github.com/SharePoint/sp-dev-docs/issues/10412\n " +
113+ "- https://github.com/SharePoint/sp-dev-docs/issues/10369" ;
114+
115+ throw new Exception ( errorMessage , ex ) ;
116+ }
95117 }
96118 else
97119 {
You can’t perform that action at this time.
0 commit comments