@@ -25,7 +25,7 @@ using System.Text.Json;
2525// GLOBAL VARIABLES
2626///////////////////////////////////////////////////////////////////////////////
2727
28- var projectName = "Polly.Caching.MemoryCache " ;
28+ var projectName = "Polly.Caching.Memory " ;
2929var keyName = "Polly.snk" ;
3030
3131var solutions = GetFiles ( "./**/*.sln" ) ;
@@ -38,30 +38,27 @@ var testResultsDir = artifactsDir + Directory("test-results");
3838
3939// NuGet
4040var nuspecExtension = ".nuspec" ;
41- var signed = "-Signed" ;
4241var nuspecFolder = "nuget-package" ;
4342var nuspecSrcFile = srcDir + File ( projectName + nuspecExtension ) ;
4443var nuspecDestFile = buildDir + File ( projectName + nuspecExtension ) ;
45- var nuspecSignedDestFile = buildDir + File ( projectName + signed + nuspecExtension ) ;
4644var nupkgDestDir = artifactsDir + Directory ( nuspecFolder ) ;
4745var snkFile = srcDir + File ( keyName ) ;
4846
4947var projectToNugetFolderMap = new Dictionary < string , string [ ] > ( ) {
50- { "Net45" , new [ ] { "net45" } } ,
51- { "NetStandard13" , new [ ] { "netstandard1.3" } } ,
52- { "Net40Async" , new [ ] { "net40" } } ,
53- { "Net45-Signed" , new [ ] { "net45" } } ,
54- { "NetStandard13-Signed" , new [ ] { "netstandard1.3" } } ,
55- { "Net40Async-Signed" , new [ ] { "net40" } } ,
48+ { "NetStandard13" , new [ ] { "netstandard1.3" } } ,
49+ { "NetStandard20" , new [ ] { "netstandard2.0" } } ,
5650} ;
5751
58- var netStandard = "NetStandard" ;
59- var specs = "Specs" ;
60-
6152// Gitversion
6253var gitVersionPath = ToolsExePath ( "GitVersion.exe" ) ;
6354Dictionary < string , object > gitVersionOutput ;
6455
56+ // Versioning
57+ string nugetVersion ;
58+ string appveyorBuildNumber ;
59+ string assemblyVersion ;
60+ string assemblySemver ;
61+
6562// StrongNameSigner
6663var strongNameSignerPath = ToolsExePath ( "StrongNameSigner.Console.exe" ) ;
6764
@@ -72,12 +69,13 @@ var strongNameSignerPath = ToolsExePath("StrongNameSigner.Console.exe");
7269
7370Setup ( _ =>
7471{
75- Information ( @"" ) ;
76- Information ( @" ____ __ __ __ _ _ ___ __ ___ _ _ __ __ _ ___ _ _ ____ _ _ __ ____ _ _ ___ __ ___ _ _ ____ " ) ;
77- Information ( @"( _ \ / \ ( ) ( ) ( \/ ) / __) / _\ / __)/ )( \( )( ( \ / __) ( \/ )( __)( \/ ) / \( _ \( \/ )/ __) / _\ / __)/ )( \( __)" ) ;
78- Information ( @" ) __/( O )/ (_/\/ (_/\ ) /_( (__ / \( (__ ) __ ( )( / /( (_ \ _ / \/ \ ) _) / \/ \( O )) / ) /( (__ / \( (__ ) __ ( ) _) " ) ;
79- Information ( @"(__) \__/ \____/\____/(__/(_)\___)\_/\_/ \___)\_)(_/(__)\_)__) \___/(_)\_)(_/(____)\_)(_/ \__/(__\_)(__/ \___)\_/\_/ \___)\_)(_/(____)" ) ;
80- Information ( @"" ) ;
72+ Information ( "" ) ;
73+ Information ( @" ____ __ __ __ _ _ ____ _ _ ____ ____ __ _ ____ __ __ __ _ ____ _ _ ____ ____ ____ " ) ;
74+ Information ( @"( _ \ / \ ( ) ( ) ( \/ ) ( __)( \/ )(_ _)( __)( ( \/ ___)( )/ \ ( ( \/ ___) / )( \(_ _)(_ _)( _ \" ) ;
75+ Information ( @" ) __/( O )/ (_/\/ (_/\ ) /_ ) _) ) ( )( ) _) / /\___ \ )(( O )/ /\___ \ _ ) __ ( )( )( ) __/" ) ;
76+ Information ( @"(__) \__/ \____/\____/(__/(_)(____)(_/\_) (__) (____)\_)__)(____/(__)\__/ \_)__)(____/(_)\_)(_/ (__) (__) (__) " ) ;
77+
78+ Information ( "" ) ;
8179} ) ;
8280
8381Teardown ( _ =>
@@ -134,38 +132,62 @@ Task("__UpdateAssemblyVersionInformation")
134132 gitVersionOutput = new JsonParser ( ) . Parse < Dictionary < string , object > > ( output ) ;
135133
136134 Information ( "Updated GlobalAssemblyInfo" ) ;
137- Information ( "AssemblyVersion -> {0}" , gitVersionOutput [ "AssemblySemVer" ] ) ;
138- Information ( "AssemblyFileVersion -> {0}" , gitVersionOutput [ "MajorMinorPatch" ] ) ;
139- Information ( "AssemblyInformationalVersion -> {0}" , gitVersionOutput [ "InformationalVersion" ] ) ;
135+
136+ Information ( "" ) ;
137+ Information ( "Obtained raw version info for package versioning:" ) ;
138+ Information ( "NuGetVersion -> {0}" , gitVersionOutput [ "NuGetVersion" ] ) ;
139+ Information ( "FullSemVer -> {0}" , gitVersionOutput [ "FullSemVer" ] ) ;
140+ Information ( "AssemblySemVer -> {0}" , gitVersionOutput [ "AssemblySemVer" ] ) ;
141+
142+ appveyorBuildNumber = gitVersionOutput [ "FullSemVer" ] . ToString ( ) ;
143+ nugetVersion = gitVersionOutput [ "NuGetVersion" ] . ToString ( ) ;
144+ assemblyVersion = gitVersionOutput [ "Major" ] . ToString ( ) + ".0.0.0" ;
145+ assemblySemver = gitVersionOutput [ "AssemblySemVer" ] . ToString ( ) ;
146+
147+ Information ( "" ) ;
148+ Information ( "Mapping versioning information to:" ) ;
149+ Information ( "Appveyor build number -> {0}" , appveyorBuildNumber ) ;
150+ Information ( "Nuget package version -> {0}" , nugetVersion ) ;
151+ Information ( "AssemblyVersion -> {0}" , assemblyVersion ) ;
152+ Information ( "AssemblyFileVersion -> {0}" , assemblySemver ) ;
153+ Information ( "AssemblyInformationalVersion -> {0}" , assemblySemver ) ;
140154} ) ;
141155
142156Task ( "__UpdateDotNetStandardAssemblyVersionNumber" )
143157 . Does ( ( ) =>
144158{
145- // NOTE: TEMPORARY fix only, while GitVersionTask does not support .Net Standard assemblies. See https://github.com/App-vNext/Polly/issues/176.
146- // This build Task can be removed when GitVersionTask supports .Net Standard assemblies.
147- var assemblySemVer = gitVersionOutput [ "AssemblySemVer" ] . ToString ( ) ;
148- Information ( "Updating NetStandard AssemblyVersions to {0}" , assemblySemVer ) ;
159+ Information ( "Updating Assembly Version Information" ) ;
160+
161+ var attributeToValueMap = new Dictionary < string , string > ( ) {
162+ { "AssemblyVersion" , assemblyVersion } ,
163+ { "AssemblyFileVersion" , assemblySemver } ,
164+ { "AssemblyInformationalVersion" , assemblySemver } ,
165+ } ;
166+
149167 var assemblyInfosToUpdate = GetFiles ( "./src/**/Properties/AssemblyInfo.cs" )
150168 . Select ( f => f . FullPath )
151- . Where ( f => f . Contains ( netStandard ) )
152- . Where ( f => ! f . Contains ( specs ) ) ;
153-
154- foreach ( var assemblyInfo in assemblyInfosToUpdate ) {
155- var replacedFiles = ReplaceRegexInFiles ( assemblyInfo , "AssemblyVersion[(]\" .*\" [)]" , "AssemblyVersion(\" " + assemblySemVer + "\" )" ) ;
156- if ( ! replacedFiles . Any ( ) )
157- {
158- throw new Exception ( "AssemblyVersion could not be updated in " + assemblyInfo + "." ) ;
169+ . Where ( f => ! f . Contains ( "Specs" ) ) ;
170+
171+ foreach ( var attributeMap in attributeToValueMap ) {
172+ var attribute = attributeMap . Key ;
173+ var value = attributeMap . Value ;
174+
175+ foreach ( var assemblyInfo in assemblyInfosToUpdate ) {
176+ var replacedFiles = ReplaceRegexInFiles ( assemblyInfo , attribute + "[(]\" .*\" [)]" , attribute + "(\" " + value + "\" )" ) ;
177+ if ( ! replacedFiles . Any ( ) )
178+ {
179+ throw new Exception ( $ "{ attribute } attribute could not be updated in { assemblyInfo } .") ;
180+ }
159181 }
160182 }
183+
161184} ) ;
162185
163186Task ( "__UpdateAppVeyorBuildNumber" )
164187 . WithCriteria ( ( ) => AppVeyor . IsRunningOnAppVeyor )
165188 . Does ( ( ) =>
166189{
167- var fullSemVer = gitVersionOutput [ "FullSemVer" ] . ToString ( ) ;
168- AppVeyor . UpdateBuildVersion ( fullSemVer ) ;
190+ AppVeyor . UpdateBuildVersion ( appveyorBuildNumber ) ;
169191} ) ;
170192
171193Task ( "__BuildSolutions" )
@@ -188,33 +210,18 @@ Task("__BuildSolutions")
188210Task ( "__RunTests" )
189211 . Does ( ( ) =>
190212{
191- XUnit2 ( "./src/**/bin/" + configuration + "/**/*.Net4*.Specs.dll" , new XUnit2Settings {
192- OutputDirectory = testResultsDir ,
193- XmlReportV1 = true
194- } ) ;
195- } ) ;
196-
197- Task ( "__RunDotnetTests" )
198- . Does ( ( ) =>
199- {
200- foreach ( var specsProj in GetFiles ( "./src/**/*.Specs.csproj" )
201- . Select ( f => f . FullPath )
202- . Where ( f => f . Contains ( netStandard ) )
203- ) {
204- DotNetCoreTest ( specsProj , new DotNetCoreTestSettings {
205- Configuration = configuration ,
206- NoBuild = true
213+ foreach ( var specsProj in GetFiles ( "./src/**/*.Specs.csproj" ) ) {
214+ DotNetCoreTest ( specsProj . FullPath , new DotNetCoreTestSettings {
215+ Configuration = configuration ,
216+ NoBuild = true
207217 } ) ;
208218 }
209219} ) ;
210220
211-
212- Task ( "__CopyNonSignedOutputToNugetFolder" )
221+ Task ( "__CopyOutputToNugetFolder" )
213222 . Does ( ( ) =>
214223{
215- foreach ( var project in projectToNugetFolderMap . Keys
216- . Where ( p => ! p . Contains ( signed ) )
217- ) {
224+ foreach ( var project in projectToNugetFolderMap . Keys ) {
218225 var sourceDir = srcDir + Directory ( projectName + "." + project ) + Directory ( "bin" ) + Directory ( configuration ) ;
219226
220227 foreach ( var targetFolder in projectToNugetFolderMap [ project ] ) {
@@ -228,49 +235,6 @@ Task("__CopyNonSignedOutputToNugetFolder")
228235 CopyFile ( nuspecSrcFile , nuspecDestFile ) ;
229236} ) ;
230237
231- Task ( "__CopySignedOutputToNugetFolder" )
232- . Does ( ( ) =>
233- {
234- foreach ( var project in projectToNugetFolderMap . Keys
235- . Where ( p => p . Contains ( signed ) )
236- ) {
237- var sourceDir = srcDir + Directory ( projectName + "." + project ) + Directory ( "bin" ) + Directory ( configuration ) ;
238-
239- foreach ( var targetFolder in projectToNugetFolderMap [ project ] ) {
240- var destDir = buildDir + Directory ( "lib" ) ;
241-
242- Information ( "Copying {0} -> {1}." , sourceDir , destDir ) ;
243- CopyDirectory ( sourceDir , destDir ) ;
244- }
245- }
246-
247- CopyFile ( nuspecSrcFile , nuspecSignedDestFile ) ;
248-
249- var replacedFiles = ReplaceRegexInFiles ( nuspecSignedDestFile , "dependency id=\" (Polly\\ S*)\" " , "dependency id=\" $1-Signed\" " ) ;
250- if ( ! replacedFiles . Any ( ) )
251- {
252- throw new Exception ( "Could not set Polly dependency to Polly-Signed, for -Signed nuget package." ) ;
253- }
254- } ) ;
255-
256- Task ( "__CreateNonSignedNugetPackage" )
257- . Does ( ( ) =>
258- {
259- var nugetVersion = gitVersionOutput [ "NuGetVersion" ] . ToString ( ) ;
260- var packageName = projectName ;
261-
262- Information ( "Building {0}.{1}.nupkg" , packageName , nugetVersion ) ;
263-
264- var nuGetPackSettings = new NuGetPackSettings {
265- Id = packageName ,
266- Title = packageName ,
267- Version = nugetVersion ,
268- OutputDirectory = nupkgDestDir
269- } ;
270-
271- NuGetPack ( nuspecDestFile , nuGetPackSettings ) ;
272- } ) ;
273-
274238Task ( "__StronglySignAssemblies" )
275239 . Does ( ( ) =>
276240{
@@ -290,8 +254,7 @@ Task("__StronglySignAssemblies")
290254Task ( "__CreateSignedNugetPackage" )
291255 . Does ( ( ) =>
292256{
293- var nugetVersion = gitVersionOutput [ "NuGetVersion" ] . ToString ( ) ;
294- var packageName = projectName + signed ;
257+ var packageName = projectName ;
295258
296259 Information ( "Building {0}.{1}.nupkg" , packageName , nugetVersion ) ;
297260
@@ -302,10 +265,9 @@ Task("__CreateSignedNugetPackage")
302265 OutputDirectory = nupkgDestDir
303266 } ;
304267
305- NuGetPack ( nuspecSignedDestFile , nuGetPackSettings ) ;
268+ NuGetPack ( nuspecDestFile , nuGetPackSettings ) ;
306269} ) ;
307270
308-
309271//////////////////////////////////////////////////////////////////////
310272// BUILD TASKS
311273//////////////////////////////////////////////////////////////////////
@@ -318,10 +280,7 @@ Task("Build")
318280 . IsDependentOn ( "__UpdateAppVeyorBuildNumber" )
319281 . IsDependentOn ( "__BuildSolutions" )
320282 . IsDependentOn ( "__RunTests" )
321- . IsDependentOn ( "__RunDotnetTests" )
322- . IsDependentOn ( "__CopyNonSignedOutputToNugetFolder" )
323- . IsDependentOn ( "__CreateNonSignedNugetPackage" )
324- . IsDependentOn ( "__CopySignedOutputToNugetFolder" )
283+ . IsDependentOn ( "__CopyOutputToNugetFolder" )
325284 . IsDependentOn ( "__StronglySignAssemblies" )
326285 . IsDependentOn ( "__CreateSignedNugetPackage" ) ;
327286
0 commit comments