Skip to content

Commit ebe925f

Browse files
Revert "Update versioning in build scripts"
This reverts commit b797cff.
1 parent b797cff commit ebe925f

File tree

8 files changed

+71
-113
lines changed

8 files changed

+71
-113
lines changed

build/Program.cs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public class BuildContext : FrostingContext
3333
public string BuildConfiguration { get; set; }
3434
public bool SkipTests { get; set; }
3535
public bool SkipSlowTests { get; set; }
36-
public string TargetVersion { get; set; }
3736

3837
public DirectoryPath RootDirectory { get; }
3938
public DirectoryPath ArtifactsDirectory { get; }
@@ -46,6 +45,8 @@ public class BuildContext : FrostingContext
4645
public DirectoryPath ChangeLogGenDirectory { get; }
4746

4847
public DirectoryPath RedirectRootDirectory { get; }
48+
public DirectoryPath RedirectProjectDirectory { get; }
49+
public DirectoryPath RedirectSourceDirectory { get; }
4950
public DirectoryPath RedirectTargetDirectory { get; }
5051

5152
public FilePath SolutionFile { get; }
@@ -69,7 +70,6 @@ public BuildContext(ICakeContext context)
6970
BuildConfiguration = context.Argument("Configuration", "Release");
7071
SkipTests = context.Argument("SkipTests", false);
7172
SkipSlowTests = context.Argument("SkipSlowTests", false);
72-
TargetVersion = context.Argument("Version", "");
7373

7474
RootDirectory = new DirectoryPath(new DirectoryInfo(Directory.GetCurrentDirectory()).Parent.FullName);
7575
ArtifactsDirectory = RootDirectory.Combine("artifacts");
@@ -82,6 +82,8 @@ public BuildContext(ICakeContext context)
8282
ChangeLogGenDirectory = RootDirectory.Combine("docs").Combine("_changelog");
8383

8484
RedirectRootDirectory = RootDirectory.Combine("docs").Combine("_redirects");
85+
RedirectProjectDirectory = RedirectRootDirectory.Combine("RedirectGenerator");
86+
RedirectSourceDirectory = RedirectRootDirectory.Combine("redirects");
8587
RedirectTargetDirectory = RootDirectory.Combine("docs").Combine("_site");
8688

8789
SolutionFile = RootDirectory.CombineWithFilePath("BenchmarkDotNet.sln");
@@ -94,16 +96,11 @@ public BuildContext(ICakeContext context)
9496
AllPackableSrcProjects = new FilePathCollection(context.GetFiles(RootDirectory.FullPath + "/src/**/*.csproj")
9597
.Where(p => !p.FullPath.Contains("Disassembler")));
9698

97-
MsBuildSettings = new DotNetMSBuildSettings();
98-
if (IsCiBuild)
99+
MsBuildSettings = new DotNetMSBuildSettings
99100
{
100-
MsBuildSettings.MaxCpuCount = 1;
101-
MsBuildSettings.WithProperty("UseSharedCompilation", "false");
102-
MsBuildSettings.WithProperty("CI_BUILD", "true");
103-
}
104-
105-
if (!string.IsNullOrEmpty(TargetVersion))
106-
MsBuildSettings.WithProperty("Version", TargetVersion);
101+
MaxCpuCount = 1
102+
};
103+
MsBuildSettings.WithProperty("UseSharedCompilation", "false");
107104

108105
// NativeAOT build requires VS C++ tools to be added to $path via vcvars64.bat
109106
// but once we do that, dotnet restore fails with:
@@ -413,19 +410,17 @@ public override void Run(BuildContext context)
413410
Configuration = context.BuildConfiguration,
414411
OutputDirectory = context.ArtifactsDirectory.FullPath,
415412
ArgumentCustomization = args => args.Append("--include-symbols").Append("-p:SymbolPackageFormat=snupkg"),
416-
MSBuildSettings = context.MsBuildSettings,
417-
NoBuild = true
413+
MSBuildSettings = context.MsBuildSettings
418414
};
419-
420-
foreach (var project in context.AllPackableSrcProjects)
421-
context.DotNetPack(project.FullPath, settingsSrc);
422-
423415
var settingsTemplate = new DotNetPackSettings
424416
{
425417
Configuration = context.BuildConfiguration,
426418
OutputDirectory = context.ArtifactsDirectory.FullPath,
427419
MSBuildSettings = context.MsBuildSettings
428420
};
421+
422+
foreach (var project in context.AllPackableSrcProjects)
423+
context.DotNetPack(project.FullPath, settingsSrc);
429424
context.DotNetPack(context.TemplatesTestsProjectFile.FullPath, settingsTemplate);
430425
}
431426
}

build/common.props

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,41 +23,47 @@
2323
</PropertyGroup>
2424

2525
<ItemGroup>
26-
<None Include="$(MSBuildThisFileDirectory)package-icon.png" Pack="True" PackagePath=""/>
26+
<None Include="$(MSBuildThisFileDirectory)package-icon.png" Pack="True" PackagePath="" />
2727
</ItemGroup>
2828

2929
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
3030
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)strongNameKey.snk</AssemblyOriginatorKeyFile>
3131
<SignAssembly>true</SignAssembly>
3232
<GenerateDocumentationFile>true</GenerateDocumentationFile>
3333
</PropertyGroup>
34-
34+
3535
<PropertyGroup Condition=" '$(IsVisualBasic)' != 'true' AND '$(IsFsharp)' != 'true' ">
3636
<LangVersion>9.0</LangVersion>
37-
</PropertyGroup>
37+
38+
<Major>0</Major>
39+
<Minor>13</Minor>
40+
<Revision>5</Revision>
3841

39-
<PropertyGroup Condition=" '$(VersionPrefix)' == '' ">
40-
<VersionPrefix>0.13.5</VersionPrefix>
41-
<VersionPrefix Condition=" '$(APPVEYOR_BUILD_NUMBER)' != '' ">$(VersionPrefix).$(APPVEYOR_BUILD_NUMBER)</VersionPrefix>
42-
</PropertyGroup>
42+
<BuildNumber Condition=" '$(APPVEYOR_BUILD_NUMBER)' != '' ">$(APPVEYOR_BUILD_NUMBER)</BuildNumber>
43+
<BuildNumber Condition=" '$(BuildNumber)' == '' ">0</BuildNumber>
4344

44-
<PropertyGroup Condition=" '$(VersionSuffix)' == '' ">
45-
<VersionSuffix>develop</VersionSuffix>
46-
<VersionSuffix Condition=" '$(APPVEYOR_BUILD_NUMBER)' == '' AND '$(CI_BUILD)' != '' ">ci</VersionSuffix>
47-
</PropertyGroup>
45+
<PrereleaseLabel>-develop</PrereleaseLabel>
46+
<PrereleaseLabel Condition=" '$(APPVEYOR_BUILD_NUMBER)' != '' "></PrereleaseLabel>
47+
<!-- <PrereleaseLabel></PrereleaseLabel> --> <!-- For release versions only -->
4848

49-
<PropertyGroup>
50-
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
51-
<AssemblyFileVersion>$(VersionPrefix)</AssemblyFileVersion>
52-
<InformationalVersion>$(Version)</InformationalVersion>
53-
<PackageVersion>$(Version)</PackageVersion>
54-
</PropertyGroup>
49+
<PrereleaseLabelConstants></PrereleaseLabelConstants>
50+
<PrereleaseLabelConstants Condition=" '$(PrereleaseLabel)' == '-develop' ">PRERELEASE_DEVELOP</PrereleaseLabelConstants>
51+
<PrereleaseLabelConstants Condition=" '$(APPVEYOR_BUILD_NUMBER)' != '' ">PRERELEASE_NIGHTLY</PrereleaseLabelConstants>
52+
<DefineConstants>$(DefineConstants);$(PrereleaseLabelConstants)</DefineConstants>
5553

54+
<AssemblyVersion>$(Major).$(Minor).$(Revision).$(BuildNumber)</AssemblyVersion>
55+
<AssemblyFileVersion>$(Major).$(Minor).$(Revision).$(BuildNumber)</AssemblyFileVersion>
56+
<InformationalVersion>$(Major).$(Minor).$(Revision).$(BuildNumber)$(PrereleaseLabel)</InformationalVersion>
57+
<PackageVersion>$(Major).$(Minor).$(Revision).$(BuildNumber)$(PrereleaseLabel)</PackageVersion>
58+
</PropertyGroup>
5659
<ItemGroup>
5760
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2">
5861
<PrivateAssets>all</PrivateAssets>
5962
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
6063
</PackageReference>
64+
</ItemGroup>
65+
66+
<ItemGroup >
6167
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
6268
<PrivateAssets>all</PrivateAssets>
6369
</PackageReference>

src/BenchmarkDotNet/Disassemblers/WindowsDisassembler.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,15 @@ private static string GetDisassemblerPath(string architectureName)
8686
var dir = new FileInfo(assemblyWithDisassemblersInResources.Location).Directory ?? throw new DirectoryNotFoundException();
8787
string disassemblerPath = Path.Combine(
8888
dir.FullName,
89-
FolderNameHelper.ToFolderName(BenchmarkDotNetInfo.Instance.FullVersion), // possible update
89+
FolderNameHelper.ToFolderName(BenchmarkDotNetInfo.FullVersion), // possible update
9090
exeName); // separate process per architecture!!
9191

9292
Path.GetDirectoryName(disassemblerPath).CreateIfNotExists();
9393

94-
// for development we always want to copy the file to not omit any dev changes
95-
if (!BenchmarkDotNetInfo.Instance.IsDevelop)
96-
{
97-
if (File.Exists(disassemblerPath))
98-
return disassemblerPath;
99-
}
100-
94+
#if !PRERELEASE_DEVELOP // for development we always want to copy the file to not omit any dev changes (Properties.BenchmarkDotNetInfo.FullVersion in file name is not enough)
95+
if (File.Exists(disassemblerPath))
96+
return disassemblerPath;
97+
#endif
10198
// the disassembler has not been yet retrieved from the resources
10299
CopyFromResources(
103100
assemblyWithDisassemblersInResources,

src/BenchmarkDotNet/Environments/HostEnvironmentInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public class HostEnvironmentInfo : BenchmarkEnvironmentInfo
6767

6868
protected HostEnvironmentInfo()
6969
{
70-
BenchmarkDotNetVersion = BenchmarkDotNetInfo.Instance.BrandVersion;
70+
BenchmarkDotNetVersion = BenchmarkDotNetInfo.FullVersion;
7171
OsVersion = new Lazy<string>(RuntimeInformation.GetOsVersion);
7272
CpuInfo = new Lazy<CpuInfo>(RuntimeInformation.GetCpuInfo);
7373
ChronometerFrequency = Chronometer.Frequency;

src/BenchmarkDotNet/Exporters/RPlotExporter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public IEnumerable<string> ExportToFiles(Summary summary, ILogger consoleLogger)
3636
string logFullPath = Path.Combine(summary.ResultsDirectoryPath, logFileName);
3737
string script = ResourceHelper.
3838
LoadTemplate(scriptFileName).
39-
Replace("$BenchmarkDotNetVersion$", BenchmarkDotNetInfo.Instance.BrandTitle).
39+
Replace("$BenchmarkDotNetVersion$", BenchmarkDotNetInfo.FullTitle).
4040
Replace("$CsvSeparator$", CsvMeasurementsExporter.Default.Separator);
4141
lock (BuildScriptLock)
4242
File.WriteAllText(scriptFullPath, script);

src/BenchmarkDotNet/Properties/BenchmarkDotNetInfo.cs

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,39 @@
11
using System;
2+
using System.Diagnostics.CodeAnalysis;
23
using System.Reflection;
3-
using BenchmarkDotNet.Extensions;
44

55
namespace BenchmarkDotNet.Properties
66
{
7-
public class BenchmarkDotNetInfo
7+
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
8+
public static class BenchmarkDotNetInfo
89
{
9-
private static readonly Lazy<BenchmarkDotNetInfo> LazyInstance = new (() =>
10+
#if PRERELEASE_NIGHTLY
11+
public const string PrereleaseLabel = "-nightly";
12+
#elif PRERELEASE_DEVELOP
13+
public const string PrereleaseLabel = "-develop";
14+
#else
15+
public const string PrereleaseLabel = "";
16+
#endif
17+
18+
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
19+
[SuppressMessage("ReSharper", "RedundantLogicalConditionalExpressionOperand")]
20+
private static readonly Lazy<string> FullVersionLazy = new Lazy<string>(() =>
1021
{
11-
var assembly = typeof(BenchmarkDotNetInfo).GetTypeInfo().Assembly;
12-
var assemblyVersion = assembly.GetName().Version;
13-
string informationVersion = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion ?? "";
14-
return new BenchmarkDotNetInfo(assemblyVersion, informationVersion);
22+
string version = typeof(BenchmarkDotNetInfo).GetTypeInfo().Assembly.GetName().Version.ToString();
23+
#pragma warning disable 162
24+
if (version.EndsWith(".0") && PrereleaseLabel == "")
25+
version = version.Substring(0, version.Length - 2);
26+
if (version.EndsWith(".0") && PrereleaseLabel == "-develop")
27+
version = version.Substring(0, version.Length - 1) + DateTime.Now.ToString("yyyyMMdd");
28+
#pragma warning restore 162
29+
return version + PrereleaseLabel;
1530
});
1631

17-
public static BenchmarkDotNetInfo Instance { get; } = LazyInstance.Value;
32+
private static readonly Lazy<string> FullTitleLazy = new Lazy<string>(() => "BenchmarkDotNet v" + FullVersionLazy.Value);
1833

19-
public Version AssemblyVersion { get; }
20-
public string FullVersion { get; }
34+
public static string FullVersion => FullVersionLazy.Value;
2135

22-
public bool IsDevelop { get; }
23-
public bool IsNightly { get; }
24-
public bool IsRelease { get; }
25-
26-
public string BrandTitle { get; }
27-
public string BrandVersion { get; }
28-
29-
public BenchmarkDotNetInfo(Version assemblyVersion, string fullVersion)
30-
{
31-
AssemblyVersion = assemblyVersion;
32-
FullVersion = fullVersion;
33-
34-
string versionPrefix = AssemblyVersion.Revision > 0
35-
? AssemblyVersion.ToString()
36-
: AssemblyVersion.ToString(3);
37-
if (!FullVersion.StartsWith(versionPrefix))
38-
throw new ArgumentException($"Inconsistent versions: '{assemblyVersion}' and '{fullVersion}'");
39-
string versionSuffix = FullVersion.Substring(versionPrefix.Length).TrimStart('-');
40-
41-
IsDevelop = versionSuffix.StartsWith("develop");
42-
IsNightly = AssemblyVersion.Revision > 0;
43-
IsRelease = versionSuffix.IsEmpty() && AssemblyVersion.Revision <= 0;
44-
45-
string brandVersionSuffix = IsDevelop
46-
? "-" + DateTime.Now.ToString("yyyyMMdd")
47-
: "";
48-
BrandVersion = FullVersion + brandVersionSuffix;
49-
BrandTitle = "BenchmarkDotNet v" + BrandVersion;
50-
}
36+
public static string FullTitle => FullTitleLazy.Value;
5137

5238
internal const string PublicKey =
5339
"00240000048000009400000006020000002400005253413100040000010001002970bbdfca4d12" +

src/BenchmarkDotNet/Toolchains/InProcess/Emit/Implementation/Emitters/RunnableEmitter.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
using BenchmarkDotNet.Helpers.Reflection.Emit;
1313
using BenchmarkDotNet.Jobs;
1414
using BenchmarkDotNet.Loggers;
15-
using BenchmarkDotNet.Properties;
1615
using BenchmarkDotNet.Running;
1716
using BenchmarkDotNet.Toolchains.Results;
1817
using JetBrains.Annotations;
@@ -79,13 +78,11 @@ public static Assembly EmitPartitionAssembly(
7978

8079
private static bool ShouldSaveToDisk(IConfig config)
8180
{
82-
if (!BenchmarkDotNetInfo.Instance.IsRelease)
83-
{
84-
// we never want to do that in our official NuGet.org package, it's a hack
85-
return config.Options.IsSet(ConfigOptions.KeepBenchmarkFiles) && Portability.RuntimeInformation.IsFullFramework;
86-
}
87-
81+
#if PRERELEASE_DEVELOP || PRERELEASE_NIGHTLY // we never want to do that in our official NuGet.org package, it's a hack
82+
return config.Options.IsSet(ConfigOptions.KeepBenchmarkFiles) && Portability.RuntimeInformation.IsFullFramework;
83+
#else
8884
return false;
85+
#endif
8986
}
9087

9188
private static string GetRunnableTypeName(BenchmarkBuildInfo benchmark)

tests/BenchmarkDotNet.Tests/BenchmarkDotNetInfoTests.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)