Skip to content

Commit b581ffa

Browse files
committed
Fixed prepublished.
1 parent 7c4ffbe commit b581ffa

File tree

3 files changed

+30
-21
lines changed

3 files changed

+30
-21
lines changed

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

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,9 @@ public static bool TryWrite( BuildContext context, bool dry, out bool hasChanges
2121
var autoUpdatedDependencies = context.Product.DependencyDefinition.GetAllDependencies( BuildConfiguration.Public )
2222
.Where( d => d.Definition.AutoUpdateVersion )
2323
.ToArray();
24-
25-
if ( autoUpdatedDependencies.Length == 0 )
26-
{
27-
context.Console.WriteMessage( "There are no auto-updated dependencies to check." );
28-
29-
return true;
30-
}
31-
24+
3225
// Load XML.
33-
var thisAutoUpdatedVersionsFilePath = context.Product.AutoUpdatedVersionsFilePath;
26+
var thisAutoUpdatedVersionsFilePath = Path.Combine( context.RepoDirectory, context.Product.AutoUpdatedVersionsFilePath );
3427
var thisAutoUpdatedVersionsDocument = XDocument.Load( thisAutoUpdatedVersionsFilePath, LoadOptions.PreserveWhitespace );
3528
var thisAutoUpdatedVersionsPropertyGroupElement = thisAutoUpdatedVersionsDocument.Root!.Element( "PropertyGroup" )!;
3629

@@ -44,8 +37,8 @@ public static bool TryWrite( BuildContext context, bool dry, out bool hasChanges
4437

4538
string[] filePathCandidates =
4639
[
47-
Path.Combine( context.RepoDirectory, context.Product.SourceDependenciesDirectory, dependency.Name, "eng", FileName ),
48-
Path.Combine( context.RepoDirectory, "..", dependency.Name, "eng", FileName )
40+
Path.GetFullPath( Path.Combine( context.RepoDirectory, context.Product.SourceDependenciesDirectory, dependency.Name, dependency.EngineeringDirectory, FileName ) ),
41+
Path.GetFullPath( Path.Combine( context.RepoDirectory, "..", dependency.Name, dependency.EngineeringDirectory, FileName ) )
4942
];
5043

5144
var theirAutoUpdatedVersionsFilePath = filePathCandidates.FirstOrDefault( File.Exists );
@@ -63,7 +56,7 @@ public static bool TryWrite( BuildContext context, bool dry, out bool hasChanges
6356

6457
var releasedVersionPropertyName = $"{dependency.NameWithoutDot}ReleaseVersion";
6558

66-
var dependencyReleasedVersion = theirAutoUpdatedVersionsDocument.Root?.Element( "Project" )
59+
var dependencyReleasedVersion = theirAutoUpdatedVersionsDocument.Root
6760
?.Element( "PropertyGroup" )
6861
?.Element( releasedVersionPropertyName )
6962
?.Value;
@@ -105,9 +98,9 @@ public static bool TryWrite( BuildContext context, bool dry, out bool hasChanges
10598
{
10699
var releasedMainVersionPropertyName = $"{dependency.NameWithoutDot}ReleaseMainVersion";
107100

108-
var releasedMainVersionPropertyValue = theirAutoUpdatedVersionsDocument.Root?.Element( "Project" )
101+
var releasedMainVersionPropertyValue = theirAutoUpdatedVersionsDocument.Root
109102
?.Element( "PropertyGroup" )
110-
?.Element( releasedVersionPropertyName )
103+
?.Element( releasedMainVersionPropertyName )
111104
?.Value;
112105

113106
if ( string.IsNullOrEmpty( releasedMainVersionPropertyValue ) )
@@ -165,8 +158,8 @@ public static bool TryWrite( BuildContext context, bool dry, out bool hasChanges
165158

166159
if ( thisMainVersionElement == null )
167160
{
168-
thisMainVersionElement = new XElement( $"{context.Product.ProductNameWithoutDot}ReleaseVersion" );
169-
thisAutoUpdatedVersionsPropertyGroupElement.Add( thisVersionElement );
161+
thisMainVersionElement = new XElement( $"{context.Product.ProductNameWithoutDot}ReleaseMainVersion" );
162+
thisAutoUpdatedVersionsPropertyGroupElement.Add( thisMainVersionElement );
170163
}
171164

172165
if ( thisMainVersionElement.Value != versionComponents.MainVersion )

src/PostSharp.Engineering.BuildTools/Build/Publishing/PrePublishCommand.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,28 @@ private static bool Execute( BuildContext context, PublishSettings settings )
5454
return false;
5555
}
5656

57-
if ( !AutoUpdatedVersionsFile.TryWriteAndCommit( context, settings.Dry ) )
57+
if ( settings.NoCommit )
5858
{
59-
return false;
59+
if ( !AutoUpdatedVersionsFile.TryWrite( context, settings.Dry, out _ ) )
60+
{
61+
return false;
62+
}
6063
}
61-
62-
if ( !GitHelper.TryPullAndMergeAndPush( context, settings, targetBranch ) )
64+
else
6365
{
64-
return false;
66+
if ( !AutoUpdatedVersionsFile.TryWriteAndCommit( context, settings.Dry ) )
67+
{
68+
return false;
69+
}
70+
71+
if ( !GitHelper.TryPullAndMergeAndPush( context, settings, targetBranch ) )
72+
{
73+
return false;
74+
}
75+
6576
}
6677

78+
6779
return true;
6880
}
6981
}

src/PostSharp.Engineering.BuildTools/Build/Publishing/PublishSettings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ public class PublishSettings : BuildSettings
1313
[CommandOption( "--dry" )]
1414
public bool Dry { get; protected set; }
1515

16+
[Description( "Write the files (unless --dry is used) but do not commit them." )]
17+
[CommandOption( "--no-commit" )]
18+
public bool NoCommit { get; init; }
19+
1620
[Description( "Avoids check of the current branch" )]
1721
[CommandOption( "--standalone" )]
1822
public bool IsStandalone { get; protected set; }

0 commit comments

Comments
 (0)