@@ -16,26 +16,30 @@ public class InitCommand : ICommand
1616 public const string COMMAND_ARGUMENTS = "<Path> from ASP.NET Core Project." ;
1717 public static IList < CommandOption > CommandOptions { get ; set ; } = new List < CommandOption > ( ) ;
1818
19- private const string ConfigName = "electron.manifest.json" ;
20-
21- private string [ ] _args ;
19+ private static SimpleCommandLineParser _parser = new SimpleCommandLineParser ( ) ;
20+ private static string ConfigName = "electron.manifest.json" ;
21+ private const string DefaultConfigFileName = "electron.manifest.json" ;
2222
2323 public InitCommand ( string [ ] args )
2424 {
25- _args = args ;
25+ _parser . Parse ( args ) ;
2626 }
2727
28+ private static string _aspCoreProjectPath = "project-path" ;
29+ private static string _manifest = "manifest" ;
30+
2831 public Task < bool > ExecuteAsync ( )
2932 {
3033 return Task . Run ( ( ) =>
3134 {
3235 string aspCoreProjectPath = "" ;
3336
34- if ( _args . Length > 0 )
37+ if ( _parser . Arguments . ContainsKey ( _aspCoreProjectPath ) )
3538 {
36- if ( Directory . Exists ( _args [ 0 ] ) )
39+ string projectPath = _parser . Arguments [ _aspCoreProjectPath ] . First ( ) ;
40+ if ( Directory . Exists ( projectPath ) )
3741 {
38- aspCoreProjectPath = _args [ 0 ] ;
42+ aspCoreProjectPath = projectPath ;
3943 }
4044 }
4145 else
@@ -45,7 +49,15 @@ public Task<bool> ExecuteAsync()
4549
4650 var currentDirectory = aspCoreProjectPath ;
4751
48- Console . WriteLine ( "Adding our config file to your project..." ) ;
52+ if ( _parser . Arguments . ContainsKey ( _manifest ) )
53+ {
54+ ConfigName = "electron.manifest." + _parser . Arguments [ _manifest ] . First ( ) + ".json" ;
55+ Console . WriteLine ( $ "Adding your custom { ConfigName } config file to your project...") ;
56+ }
57+ else
58+ {
59+ Console . WriteLine ( "Adding our config file to your project..." ) ;
60+ }
4961
5062 var targetFilePath = Path . Combine ( currentDirectory , ConfigName ) ;
5163
@@ -56,7 +68,7 @@ public Task<bool> ExecuteAsync()
5668 }
5769
5870 // Deploy config file
59- EmbeddedFileHelper . DeployEmbeddedFile ( currentDirectory , ConfigName ) ;
71+ EmbeddedFileHelper . DeployEmbeddedFileToTargetFile ( currentDirectory , DefaultConfigFileName , ConfigName ) ;
6072
6173 // search .csproj
6274 Console . WriteLine ( $ "Search your .csproj to add the needed { ConfigName } ...") ;
@@ -99,7 +111,32 @@ private static void EditLaunchSettings(string currentDirectory)
99111
100112 string launchSettingText = File . ReadAllText ( launchSettingFile ) ;
101113
102- if ( launchSettingText . Contains ( "\" executablePath\" : \" electronize\" " ) == false )
114+ if ( _parser . Arguments . ContainsKey ( _manifest ) )
115+ {
116+ string manifestName = _parser . Arguments [ _manifest ] . First ( ) ;
117+
118+ if ( launchSettingText . Contains ( "start /manifest " + ConfigName ) == false )
119+ {
120+ StringBuilder debugProfileBuilder = new StringBuilder ( ) ;
121+ debugProfileBuilder . AppendLine ( "profiles\" : {" ) ;
122+ debugProfileBuilder . AppendLine ( " \" Electron.NET App - " + manifestName + "\" : {" ) ;
123+ debugProfileBuilder . AppendLine ( " \" commandName\" : \" Executable\" ," ) ;
124+ debugProfileBuilder . AppendLine ( " \" executablePath\" : \" electronize\" ," ) ;
125+ debugProfileBuilder . AppendLine ( " \" commandLineArgs\" : \" start /manifest " + ConfigName + "\" ," ) ;
126+ debugProfileBuilder . AppendLine ( " \" workingDirectory\" : \" .\" " ) ;
127+ debugProfileBuilder . AppendLine ( " }," ) ;
128+
129+ launchSettingText = launchSettingText . Replace ( "profiles\" : {" , debugProfileBuilder . ToString ( ) ) ;
130+ File . WriteAllText ( launchSettingFile , launchSettingText ) ;
131+
132+ Console . WriteLine ( $ "Debug profile added!") ;
133+ }
134+ else
135+ {
136+ Console . WriteLine ( $ "Debug profile already existing") ;
137+ }
138+ }
139+ else if ( launchSettingText . Contains ( "\" executablePath\" : \" electronize\" " ) == false )
103140 {
104141 StringBuilder debugProfileBuilder = new StringBuilder ( ) ;
105142 debugProfileBuilder . AppendLine ( "profiles\" : {" ) ;
0 commit comments