1-
21#tool nuget : ? package= xunit . runner . console & version = 2.3 .1
32#tool nuget: ? package = xunit . runner . visualstudio & version = 2.3 .1
43#tool nuget: ? package = OpenCover & version = 4.6 .519
@@ -19,36 +18,37 @@ var configuration =
1918 HasArgument ( "Configuration") ? Argument<string>(" Configuration") :
2019 EnvironmentVariable ( "Configuration" ) != null ? EnvironmentVariable ( "Configuration" ) : "Release" ;
2120
21+ var parameters = BuildParameters. GetParameters( Context , target , configuration ) ;
22+ var paths = BuildPaths . GetPaths ( Context , parameters ) ;
23+
2224// The build number to use in the version number of the built NuGet packages.
2325// There are multiple ways this value can be passed, this is a common pattern.
2426// 1. If command line parameter parameter passed, use that.
2527// 2. Otherwise if running on AppVeyor, get it's build number.
2628// 3. Otherwise if running on Travis CI, get it's build number.
2729// 4. Otherwise if an Environment variable exists, use that.
2830// 5. Otherwise default the build number to 0.
31+ BuildVersion buildVersion= ReadVersionNumberFromProject( Context , paths . Files . VersionFile ) ;
32+ var tempVersionSuffix = buildVersion . VersionSuffix ;
33+
2934var preReleaseSuffix =
3035 HasArgument( "PreReleaseSuffix" ) ? Argument < string > ( "PreReleaseSuffix ") :
3136 ( AppVeyor . IsRunningOnAppVeyor && AppVeyor . Environment . Repository . Tag . IsTag ) ? null :
3237 EnvironmentVariable ( "PreReleaseSuffix") != null ? EnvironmentVariable ( "PreReleaseSuffix" ) :
33- "beta" ;
38+ tempVersionSuffix ;
3439var buildNumber = HasArgument( "BuildNumber" ) ?
3540 Argument < int > ( "BuildNumber" ) :
3641 AppVeyor . IsRunningOnAppVeyor ? AppVeyor . Environment . Build . Number :
3742 EnvironmentVariable ( "BuildNumber" ) != null ? int . Parse ( EnvironmentVariable ( "BuildNumber" ) ) :
3843 0 ;
3944
40- var parameters = BuildParameters. GetParameters( Context , target , configuration ) ;
41- var paths = BuildPaths . GetPaths ( Context , parameters ) ;
42-
43- BuildVersion buildVersion= ReadVersionNumberFromProject ( Context , paths . Files . VersionFile ) ;
44- var revision = buildNumber . ToString ( "D4" ) ;
45- var versionElement = string . IsNullOrEmpty ( preReleaseSuffix ) ? null : $ "-{ preReleaseSuffix } -{ revision } ";
4645
4746var finalVersionPrefix = buildVersion. VersionPrefix;
48- var finalVersionSuffix = buildVersion . VersionSuffix . Replace ( "-*" , versionElement ) ;
47+ var finalVersionSuffix = string . IsNullOrEmpty ( preReleaseSuffix ) ? null : $ "- { preReleaseSuffix } - { buildNumber . ToString ( "D4" ) } " ;
4948
5049var finalVersion= $"{finalVersionPrefix}{finalVersionSuffix}" ;
5150
51+
5252 var msBuildSettings = new DotNetCoreMSBuildSettings ( )
5353 . WithProperty ( "Version" , finalVersion )
5454 . WithProperty ( "AssemblyVersion" , finalVersionPrefix )
@@ -114,6 +114,7 @@ Task("Clean")
114114Task( "NuGet-Restore" )
115115 . IsDependentOn ( "Clean" )
116116 . Does ( ( ) => NuGetRestore ( paths . Files . Solution . ToString ( ) ) ) ;
117+
117118// NuGet restore packages for .NET Core projects only
118119Task( "DotNet-Core-Package-Restore" )
119120 . IsDependentOn ( "NuGet-Restore" )
@@ -124,17 +125,7 @@ Task("DotNet-Core-Package-Restore")
124125 Verbosity = DotNetCoreVerbosity . Minimal ,
125126 } ) ;
126127 } ) ;
127- /*
128- Task("Create-Version-Info").Does(() =>
129- {
130- CreateAssemblyInfo(File("AssemblyVersionInfo.cs"), new AssemblyInfoSettings
131- {
132- Version = parameters.AssemblyVersion,
133- FileVersion = parameters.Version,
134- InformationalVersion = parameters.FullVersion
135- });
136- });
137- */
128+
138129Task( "Build" )
139130 . Does ( ( ) => DotNetCoreBuild ( paths . Files . Solution . ToString ( ) , dotNetCoreBuildSettings ) ) ;
140131// Look under a 'Tests' folder and run dotnet test against all of those projects.
@@ -171,7 +162,7 @@ Task("Test-OpenCover")
171162 . WithFilter ( "+[*]* -[*.UnitsTests]*" )
172163 . WithFilter ( "-[xunit.*]*" )
173164 . WithFilter ( "-[*.*Tests]*" )
174- // .ExcludeByAttribute("*.ExcludeFromCodeCoverage*")
165+ . ExcludeByAttribute ( "*.ExcludeFromCodeCoverage*" )
175166 ;
176167
177168 foreach ( var project in paths . Files . TestProjects )
@@ -183,7 +174,6 @@ Task("Test-OpenCover")
183174 var projectFile = MakeAbsolute ( project ) . ToString ( ) ;
184175 var dotNetTestSettings = new DotNetCoreTestSettings
185176 {
186- /* Configuration = "Debug",*/
187177 Configuration = configuration ,
188178 NoBuild = true ,
189179 NoRestore = true ,
@@ -294,6 +284,7 @@ Task("Copy-Files")
294284 //CopyFileToDirectory("./LICENSE", outputDirectory21);
295285
296286 } ) ;
287+
297288// Run dotnet pack to produce NuGet packages from our projects. Versions the package
298289// using the build number argument on the script which is used as the revision number
299290// (Last number in 1.0.0.0). The packages are dropped in the Artifacts directory.
@@ -304,33 +295,9 @@ Task("Package-NuGet")
304295 . IsDependentOn ( "Copy-Files" )
305296 . DoesForEach ( paths . Files . AllNuspecsProjects , projectNuSpecToPack =>
306297 {
307- /*
308- var nuspecFile = projectNuSpecToPack.FullPath;
309- var nuspecContent = System.IO.File.ReadAllText(nuspecFile);
310- var nuspecDocument = XDocument.Parse(nuspecContent);
311- var ns = XNamespace.Get("http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd");
312- var versionElement = nuspecDocument.Element(ns + "package").Element(ns + "metadata").Element(ns + "version");
313- var finalVersion= versionElement.Value.Replace("-*", finalVersionSuffix);
314- versionElement.Value = finalVersion;
315- System.IO.File.WriteAllText(nuspecFile, nuspecDocument.ToString());
316- */
317-
318298 // .NET Core
319299 var nuspecFile = projectNuSpecToPack . FullPath ;
320300 var fullBasePath = GetOutputArtifactFromProjectFile ( paths . Directories . ArtifactsBinNetCoreapp21 , nuspecFile ) ;
321-
322- /*DotNetCorePack(projectNuSpecToPack.ChangeExtension(".csproj").FullPath,new DotNetCorePackSettings()
323- {
324- NoBuild = true,
325- NoRestore = true,
326- Configuration = configuration,
327- OutputDirectory = paths.Directories.ArtifactNugetsDirectory,
328- VersionSuffix = finalVersionSuffix,//finalVersion,
329- MSBuildSettings= msBuildSettings,
330- ArgumentCustomization = args => args
331- .AppendSwitch("/p:NuspecFile","=",$"{nuspecFile}")
332- });*/
333-
334301 // normal
335302 NuGetPack ( nuspecFile , new NuGetPackSettings {
336303 Version = finalVersion ,
@@ -339,9 +306,6 @@ Task("Package-NuGet")
339306 Symbols = false ,
340307 NoPackageAnalysis = true
341308 } ) ;
342-
343-
344- //System.IO.File.WriteAllText(nuspecFile, nuspecContent);
345309 } ) ;
346310
347311//////////////////////////////////////////////////////////////////////
0 commit comments