44partial class Build
55{
66 Target Pack => _ => _
7- . DependsOn ( Compile )
7+ . DependsOn ( Clean )
88 . Requires ( ( ) => ReleaseVersion )
99 . Executes ( ( ) =>
1010 {
11- foreach ( var configuration in GlobBuildConfigurations ( ) )
11+ var readme = CreateNugetReadme ( ) ;
12+ try
1213 {
13- DotNetPack ( settings => settings
14- . SetConfiguration ( configuration )
15- . SetVersion ( GetPackVersion ( configuration ) )
16- . SetOutputDirectory ( ArtifactsDirectory )
17- . SetVerbosity ( DotNetVerbosity . minimal ) ) ;
14+ var packConfigurations = GlobBuildConfigurations ( )
15+ . Where ( configuration => configuration . Contains ( " R" , StringComparison . OrdinalIgnoreCase ) ) ;
16+
17+ foreach ( var configuration in packConfigurations )
18+ {
19+ DotNetPack ( settings => settings
20+ . SetConfiguration ( configuration )
21+ . SetVersion ( GetPackVersion ( configuration ) )
22+ . SetOutputDirectory ( ArtifactsDirectory )
23+ . SetVerbosity ( DotNetVerbosity . minimal ) ) ;
24+ }
25+ }
26+ finally
27+ {
28+ RestoreReadme ( readme ) ;
1829 }
1930 } ) ;
2031
@@ -23,4 +34,28 @@ string GetPackVersion(string configuration)
2334 if ( PackageVersionsMap . TryGetValue ( configuration , out var version ) ) return version ;
2435 throw new Exception ( $ "Can't find pack version for configuration: { configuration } ") ;
2536 }
37+
38+ string CreateNugetReadme ( )
39+ {
40+ var readmePath = Solution . Directory / "Readme.md" ;
41+ var readme = File . ReadAllText ( readmePath ) ;
42+
43+ const string startSymbol = "<p" ;
44+ const string endSymbol = "</p>\r \n \r \n " ;
45+
46+ var logoStartIndex = readme . IndexOf ( startSymbol , StringComparison . Ordinal ) ;
47+ var logoEndIndex = readme . IndexOf ( endSymbol , StringComparison . Ordinal ) ;
48+
49+ var nugetReadme = readme . Remove ( logoStartIndex , logoEndIndex - logoStartIndex + endSymbol . Length ) ;
50+ File . WriteAllText ( readmePath , nugetReadme ) ;
51+
52+ return readme ;
53+ }
54+
55+ void RestoreReadme ( string readme )
56+ {
57+ var readmePath = Solution . Directory / "Readme.md" ;
58+
59+ File . WriteAllText ( readmePath , readme ) ;
60+ }
2661}
0 commit comments