@@ -140,8 +140,8 @@ public override bool Execute()
140
140
141
141
string [ ] assetFiles = Directory
142
142
. GetFiles ( RootDir , "project.assets.json" , SearchOption . AllDirectories )
143
- . Except ( IgnoredProjectAssetsJsonFiles . NullAsEmpty ( ) )
144
- . Select ( path => path . Substring ( RootDir . Length ) )
143
+ . Select ( GetPathRelativeToRoot )
144
+ . Except ( IgnoredProjectAssetsJsonFiles . NullAsEmpty ( ) . Select ( GetPathRelativeToRoot ) )
145
145
. ToArray ( ) ;
146
146
147
147
if ( ! string . IsNullOrEmpty ( ProjectAssetsJsonArchiveFile ) )
@@ -230,7 +230,7 @@ public override bool Execute()
230
230
Usages = usages . ToArray ( ) ,
231
231
NeverRestoredTarballPrebuilts = neverRestoredTarballPrebuilts ,
232
232
ProjectDirectories = ProjectDirectories
233
- ? . Select ( dir => dir . Substring ( RootDir . Length ) )
233
+ ? . Select ( GetPathRelativeToRoot )
234
234
. ToArray ( )
235
235
} ;
236
236
@@ -244,6 +244,16 @@ public override bool Execute()
244
244
return ! Log . HasLoggedErrors ;
245
245
}
246
246
247
+ private string GetPathRelativeToRoot ( string path )
248
+ {
249
+ if ( path . StartsWith ( RootDir ) )
250
+ {
251
+ return path . Substring ( RootDir . Length ) . Replace ( Path . DirectorySeparatorChar , '/' ) ;
252
+ }
253
+
254
+ throw new ArgumentException ( $ "Path '{ path } ' is not within RootDir '{ RootDir } '") ;
255
+ }
256
+
247
257
private static string [ ] ReadRidsFromRuntimeJson ( string path )
248
258
{
249
259
var root = JObject . Parse ( File . ReadAllText ( path ) ) ;
0 commit comments