@@ -40,7 +40,7 @@ class Setup {
4040
4141 private void PrintHelp ( )
4242 {
43- Console . WriteLine ( "USAGE: dotnet script Setup.csx -- <Target-Path> [-vs|-vscode] [-debug|-release]" ) ;
43+ Console . WriteLine ( "USAGE: Setup.[sh|cmd] -- <Target-Path> [-vs|-vscode] [-debug|-release]" ) ;
4444 Console . WriteLine ( "" ) ;
4545 Console . WriteLine ( "\t <Target-Path> is the path to the VS Code C/C++ Extension or root path of Visual Studio." ) ;
4646 Console . WriteLine ( "\t For Example:" ) ;
@@ -58,7 +58,7 @@ class Setup {
5858
5959 foreach ( string arg in args )
6060 {
61- if ( arg . StartsWith ( "-" ) || arg . StartsWith ( "/" ) )
61+ if ( arg . StartsWith ( "-" ) )
6262 {
6363 switch ( arg . Substring ( 1 ) . ToLower ( ) )
6464 {
@@ -69,6 +69,10 @@ class Setup {
6969 break ;
7070 case "vs" :
7171 Client = Client . VS ;
72+ if ( ! RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
73+ {
74+ throw new InvalidOperationException ( "Patching MIEngine with VS bits is not applicable for non-Windows Platforms." ) ;
75+ }
7276 break ;
7377 case "vscode" :
7478 Client = Client . VSCode ;
@@ -182,7 +186,15 @@ class Setup {
182186 {
183187 if ( Client == Client . VSCode )
184188 {
185- string vscodeExtensionPath = Environment . ExpandEnvironmentVariables ( "%USERPROFILE%\\ .vscode\\ extensions" ) ;
189+ string vscodeExtensionPath = string . Empty ;
190+ if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
191+ {
192+ vscodeExtensionPath = Environment . ExpandEnvironmentVariables ( "%USERPROFILE%\\ .vscode\\ extensions" ) ;
193+ }
194+ else
195+ {
196+ vscodeExtensionPath = Path . Join ( Environment . GetEnvironmentVariable ( "HOME" ) , ".vscode/extensions" ) ;
197+ }
186198 IEnumerable < string > extensions = Directory . EnumerateDirectories ( vscodeExtensionPath ) ;
187199
188200 foreach ( string extension in extensions )
@@ -237,18 +249,25 @@ class Setup {
237249 }
238250 string destPath = Path . Join ( TargetPath , lff . InstallDir , lff . FileName ) ;
239251
252+ // Normalize Paths for OS
253+ if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
254+ {
255+ srcPath = srcPath . Replace ( '/' , '\\ ' ) ;
256+ destPath = destPath . Replace ( '/' , '\\ ' ) ;
257+ }
258+ else
259+ {
260+ srcPath = srcPath . Replace ( '\\ ' , '/' ) ;
261+ destPath = destPath . Replace ( '\\ ' , '/' ) ;
262+ }
263+
240264 Console . WriteLine ( string . Format ( "Copying {0} to {1}." , srcPath , destPath ) ) ;
241265
242266 // TODO: Support symlinking
243267 File . Copy ( srcPath , destPath , overwrite : true ) ;
244268 }
245269 }
246270
247- }
248-
249- if ( ! RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
250- {
251- throw new InvalidOperationException ( "This script is only supported for Windows." ) ;
252271}
253272
254273Setup setup = new Setup ( ) ;
0 commit comments