@@ -70,19 +70,22 @@ public Task<bool> ExecuteAsync()
7070 // Deploy config file
7171 EmbeddedFileHelper . DeployEmbeddedFileToTargetFile ( currentDirectory , DefaultConfigFileName , ConfigName ) ;
7272
73- // search .csproj
74- Console . WriteLine ( $ "Search your .csproj to add the needed { ConfigName } ...") ;
75- var projectFile = Directory . EnumerateFiles ( currentDirectory , "*.csproj" , SearchOption . TopDirectoryOnly ) . FirstOrDefault ( ) ;
76-
77- // update config file with the name of the csproj
78- // ToDo: If the csproj name != application name, this will fail
73+ // search .csproj/.fsproj (.csproj has higher precedence)
74+ Console . WriteLine ( $ "Search your .csproj/fsproj to add the needed { ConfigName } ...") ;
75+ var projectFile = Directory . EnumerateFiles ( currentDirectory , "*.csproj" , SearchOption . TopDirectoryOnly )
76+ . Union ( Directory . EnumerateFiles ( currentDirectory , "*.fsproj" , SearchOption . TopDirectoryOnly ) )
77+ . FirstOrDefault ( ) ;
78+
79+ // update config file with the name of the csproj/fsproj
80+ // ToDo: If the csproj/fsproj name != application name, this will fail
7981 string text = File . ReadAllText ( targetFilePath ) ;
8082 text = text . Replace ( "{{executable}}" , Path . GetFileNameWithoutExtension ( projectFile ) ) ;
8183 File . WriteAllText ( targetFilePath , text ) ;
8284
83- Console . WriteLine ( $ "Found your .csproj: { projectFile } - check for existing config or update it.") ;
85+ var extension = Path . GetExtension ( projectFile ) ;
86+ Console . WriteLine ( $ "Found your { extension } : { projectFile } - check for existing config or update it.") ;
8487
85- if ( ! EditCsProj ( projectFile ) ) return false ;
88+ if ( ! EditProjectFile ( projectFile ) ) return false ;
8689
8790 // search launchSettings.json
8891 Console . WriteLine ( $ "Search your .launchSettings to add our electron debug profile...") ;
@@ -158,7 +161,7 @@ private static void EditLaunchSettings(string currentDirectory)
158161 }
159162 }
160163
161- private static bool EditCsProj ( string projectFile )
164+ private static bool EditProjectFile ( string projectFile )
162165 {
163166 using ( var stream = File . Open ( projectFile , FileMode . OpenOrCreate , FileAccess . ReadWrite ) )
164167 {
@@ -174,11 +177,11 @@ private static bool EditCsProj(string projectFile)
174177
175178 if ( xmlDocument . ToString ( ) . Contains ( $ "Content Update=\" { ConfigName } \" ") )
176179 {
177- Console . WriteLine ( $ "{ ConfigName } already in csproj.") ;
180+ Console . WriteLine ( $ "{ ConfigName } already in csproj/fsproj .") ;
178181 return false ;
179182 }
180183
181- Console . WriteLine ( $ "{ ConfigName } will be added to csproj.") ;
184+ Console . WriteLine ( $ "{ ConfigName } will be added to csproj/fsproj .") ;
182185
183186 string itemGroupXmlString = "<ItemGroup>" +
184187 "<Content Update=\" " + ConfigName + "\" >" +
@@ -204,7 +207,7 @@ private static bool EditCsProj(string projectFile)
204207
205208 }
206209
207- Console . WriteLine ( $ "{ ConfigName } added in csproj!") ;
210+ Console . WriteLine ( $ "{ ConfigName } added in csproj/fsproj !") ;
208211 return true ;
209212 }
210213 }
0 commit comments