1- using System . Diagnostics ;
2- using System . IO . Compression ;
3- using System . Text . RegularExpressions ;
1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Diagnostics ;
4+ using System . IO ;
5+ using System . Linq ;
46
57namespace Cleipnir . Flows . Cli ;
68
79internal static class Program
810{
911 private static int Main ( string [ ] args )
1012 {
11- var ( repoPath , dotnetPath ) = PathResolver . ResolvePaths ( OperatingSystem . Windows ) ;
13+ var ( repoPath , dotnetPath ) = PathResolver . ResolvePaths ( OperatingSystem . MacOs ) ;
14+
1215 var root = repoPath ;
1316 var output = Path . GetFullPath ( "./nugets" ) ;
1417
1518 if ( Directory . Exists ( output ) )
1619 Directory . Delete ( output , recursive : true ) ;
17-
20+
1821 Directory . CreateDirectory ( output ) ;
1922
2023 Console . WriteLine ( $ "Root path: { root } ") ;
2124 Console . WriteLine ( $ "Output path: { output } ") ;
22-
25+
2326 Console . WriteLine ( "Processing projects: " ) ;
24-
25- //update version
27+
2628 foreach ( var projectPath in FindAllProjects ( root ) . Where ( IsPackageProject ) )
2729 {
30+ Console . WriteLine ( "---------------------------------------------------------" ) ;
2831 Console . WriteLine ( "Updating package version: " + LeafFolderName ( projectPath ) ) ;
2932 Console . WriteLine ( "Project path: " + Path . GetDirectoryName ( projectPath ) ! ) ;
3033 UpdatePackageVersion ( projectPath ) ;
34+ Console . WriteLine ( ) ;
3135 }
3236
33- //compile & publish source generator
34- PublishSourceGenerator ( $ "{ root } /SourceGeneration/Cleipnir.Flows.SourceGenerator", output , dotnetPath ) ;
35-
36- //pack
3737 foreach ( var projectPath in FindAllProjects ( root ) . Where ( IsPackageProject ) )
3838 {
39+ Console . WriteLine ( "---------------------------------------------------------" ) ;
3940 Console . WriteLine ( "Packing nuget package: " + LeafFolderName ( projectPath ) ) ;
4041 Console . WriteLine ( "Project path: " + Path . GetDirectoryName ( projectPath ) ! ) ;
4142 PackProject ( Path . GetDirectoryName ( projectPath ) ! , output , dotnetPath ) ;
43+ Console . WriteLine ( ) ;
4244 }
4345
44- //add source generator to core flow nuget packages
45- var nugetPackages = Directory . GetFiles ( output , "*.nupkg" ) ;
46- var coreProjectNugetPackage = nugetPackages
47- . Single ( nugetPackage => Regex . IsMatch ( nugetPackage , @"Cleipnir.Flows.\d*.\d*.\d*.nupkg" ) ) ;
48- AddSourceGeneratorToNugetPackage (
49- coreProjectNugetPackage ,
50- $ "{ output } /Cleipnir.Flows.SourceGenerator.dll"
51- ) ;
52-
53- foreach ( var outputFile in Directory . GetFiles ( output ) )
54- if ( ! outputFile . EndsWith ( ".nupkg" ) && ! outputFile . EndsWith ( ".snupkg" ) )
55- File . Delete ( outputFile ) ;
56-
5746 return 0 ;
5847 }
5948
@@ -108,34 +97,7 @@ private static void PackProject(string projectPath, string outputPath, string do
10897
10998 p . WaitForExit ( ) ;
11099 }
111-
112- private static void PublishSourceGenerator ( string sourceGeneratorProjectPath , string outputPath , string dotnetPath )
113- {
114- //dotnet publish -c Release -o Output
115- var p = new Process ( ) ;
116- p . StartInfo . RedirectStandardInput = true ;
117- p . StartInfo . RedirectStandardOutput = true ;
118- p . StartInfo . RedirectStandardError = true ;
119- p . StartInfo . UseShellExecute = false ;
120- p . StartInfo . FileName = dotnetPath ;
121- p . StartInfo . WorkingDirectory = sourceGeneratorProjectPath ;
122- p . StartInfo . Arguments = $ "dotnet publish -c Release -o { outputPath } ";
123- p . Start ( ) ;
124-
125- while ( ! p . StandardOutput . EndOfStream )
126- Console . WriteLine ( p . StandardOutput . ReadLine ( ) ) ;
127-
128- p . WaitForExit ( ) ;
129- }
130100
131101 private static string LeafFolderName ( string path )
132102 => Path . GetDirectoryName ( path ) ! . Split ( '/' ) . Last ( ) ;
133-
134- private static void AddSourceGeneratorToNugetPackage ( string nugetPath , string sourceGeneratorDllPath )
135- {
136- using var zipArchive = ZipFile . Open ( nugetPath , ZipArchiveMode . Update ) ;
137-
138- var fileInfo = new FileInfo ( sourceGeneratorDllPath ) ;
139- zipArchive . CreateEntryFromFile ( sourceGeneratorDllPath , $ "analyzers/dotnet/cs/{ fileInfo . Name } ") ;
140- }
141103}
0 commit comments