Skip to content

Commit 2cd0060

Browse files
committed
Refactoring of VersionComponents. Make Prepublish not require dependencies.
1 parent 9ce68b0 commit 2cd0060

File tree

5 files changed

+275
-275
lines changed

5 files changed

+275
-275
lines changed

src/PostSharp.Engineering.BuildTools/Build/Files/ArtifactManifestFile.cs

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -36,63 +36,29 @@ public static bool TryWrite(
3636
<PropertyGroup>
3737
<{product.ProductNameWithoutDot}MainVersion>{version.MainVersion}</{product.ProductNameWithoutDot}MainVersion>";
3838

39-
var packageVersionWithoutSuffix = version.PatchNumber == 0 ? version.VersionPrefix : version.VersionPrefix + "." + version.PatchNumber;
40-
var assemblyVersion = version.VersionPrefix + "." + version.PatchNumber;
41-
var previewVersionSuffix = configuration == BuildConfiguration.Public ? "preview" : version.VersionSuffix;
42-
4339
if ( product.GenerateArcadeProperties )
4440
{
4541
// Metalama.Compiler, because of Arcade, requires the version number to be decomposed in a prefix, patch number, and suffix.
4642
// In Arcade, the package naming scheme is different because the patch number is not a part of the package name.
4743

48-
var arcadeSuffix = string.IsNullOrEmpty( version.VersionSuffix ) ? "" : version.VersionSuffix;
49-
var previewArcadeSuffix = previewVersionSuffix;
50-
51-
void AppendToArcadeSuffix( string s )
52-
{
53-
arcadeSuffix += s;
54-
previewArcadeSuffix += s;
55-
}
56-
57-
if ( version.PatchNumber > 0 )
58-
{
59-
if ( arcadeSuffix.Length > 0 )
60-
{
61-
AppendToArcadeSuffix( "-" );
62-
}
63-
else
64-
{
65-
// It should not happen that we have a patch number without a suffix.
66-
AppendToArcadeSuffix( "-patch-" + configuration );
67-
}
68-
69-
AppendToArcadeSuffix( version.PatchNumber.ToString( CultureInfo.InvariantCulture ) );
70-
}
71-
72-
var packageSuffixWithDash = string.IsNullOrEmpty( arcadeSuffix ) ? "" : "-" + arcadeSuffix;
73-
var packageVersion = version.VersionPrefix + packageSuffixWithDash;
74-
var packagePreviewVersion = version.VersionPrefix + "-" + previewArcadeSuffix;
75-
7644
manifestFileContent += $@"
7745
7846
<{product.ProductNameWithoutDot}VersionPrefix>{version.VersionPrefix}</{product.ProductNameWithoutDot}VersionPrefix>
79-
<{product.ProductNameWithoutDot}VersionSuffix>{arcadeSuffix}</{product.ProductNameWithoutDot}VersionSuffix>
47+
<{product.ProductNameWithoutDot}VersionSuffix>{version.ArcadeSuffix}</{product.ProductNameWithoutDot}VersionSuffix>
8048
<{product.ProductNameWithoutDot}VersionPatchNumber>{version.PatchNumber}</{product.ProductNameWithoutDot}VersionPatchNumber>
81-
<{product.ProductNameWithoutDot}VersionWithoutSuffix>{packageVersionWithoutSuffix}</{product.ProductNameWithoutDot}VersionWithoutSuffix>
82-
<{product.ProductNameWithoutDot}Version>{packageVersion}</{product.ProductNameWithoutDot}Version>
83-
<{product.ProductNameWithoutDot}PreviewVersion>{packagePreviewVersion}</{product.ProductNameWithoutDot}PreviewVersion>
84-
<{product.ProductNameWithoutDot}AssemblyVersion>{assemblyVersion}</{product.ProductNameWithoutDot}AssemblyVersion>";
49+
<{product.ProductNameWithoutDot}VersionWithoutSuffix>{version.PackageVersionWithoutSuffix}</{product.ProductNameWithoutDot}VersionWithoutSuffix>
50+
<{product.ProductNameWithoutDot}Version>{version.PackageVersion}</{product.ProductNameWithoutDot}Version>
51+
<{product.ProductNameWithoutDot}PreviewVersion>{version.PackagePreviewVersion}</{product.ProductNameWithoutDot}PreviewVersion>
52+
<{product.ProductNameWithoutDot}AssemblyVersion>{version.AssemblyVersion}</{product.ProductNameWithoutDot}AssemblyVersion>";
8553
}
8654
else
8755
{
8856
var packageSuffix = string.IsNullOrEmpty( version.VersionSuffix ) ? "" : "-" + version.VersionSuffix;
89-
var packageVersion = packageVersionWithoutSuffix + packageSuffix;
90-
var packagePreviewVersion = packageVersionWithoutSuffix + "-" + previewVersionSuffix;
9157

9258
manifestFileContent += $@"
93-
<{product.ProductNameWithoutDot}Version>{packageVersion}</{product.ProductNameWithoutDot}Version>
94-
<{product.ProductNameWithoutDot}PreviewVersion>{packagePreviewVersion}</{product.ProductNameWithoutDot}PreviewVersion>
95-
<{product.ProductNameWithoutDot}AssemblyVersion>{assemblyVersion}</{product.ProductNameWithoutDot}AssemblyVersion>";
59+
<{product.ProductNameWithoutDot}Version>{version.PackageVersion}</{product.ProductNameWithoutDot}Version>
60+
<{product.ProductNameWithoutDot}PreviewVersion>{version.PackagePreviewVersion}</{product.ProductNameWithoutDot}PreviewVersion>
61+
<{product.ProductNameWithoutDot}AssemblyVersion>{version.AssemblyVersion}</{product.ProductNameWithoutDot}AssemblyVersion>";
9662
}
9763

9864
manifestFileContent += $@"

src/PostSharp.Engineering.BuildTools/Build/Files/MasterGenerator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) SharpCrafters s.r.o. See the LICENSE.md file in the root directory of this repository root for details.
22

3+
using PostSharp.Engineering.BuildTools.Build.Model;
34
using PostSharp.Engineering.BuildTools.Dependencies.Model;
45
using PostSharp.Engineering.BuildTools.Utilities;
56
using System.Diagnostics.CodeAnalysis;
@@ -55,7 +56,7 @@ public static bool TryWriteFiles(
5556
return false;
5657
}
5758

58-
if ( !VersionFileHelper.TryComputeVersion( context, settings, configuration, mainVersionFileInfo, dependenciesOverrideFile, out var version ) )
59+
if ( !VersionComponents.TryCompute( context, settings, configuration, mainVersionFileInfo, dependenciesOverrideFile, out var version ) )
5960
{
6061
return false;
6162
}

src/PostSharp.Engineering.BuildTools/Build/Files/VersionFileHelper.cs

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

0 commit comments

Comments
 (0)