Skip to content

Commit

Permalink
Refactored build method again.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidRogersDev committed Mar 30, 2024
1 parent 04392cc commit 687d747
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
20 changes: 7 additions & 13 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public static int Main() => IsLocalBuild
protected override void OnBuildInitialized()
{
_releaseGuard = new ReleaseGuard(GitVersion,
new PackagePublishConfig(NUGET_API_KEY, NUGET_URL),
new PackagePublishConfig(PACKAGES_GITHUB_NUGET_PAT, PACKAGES_GITHUB_NUGET_URL));
new PackagePublishConfig(NUGET_API_KEY, NUGET_URL, false),
new PackagePublishConfig(PACKAGES_GITHUB_NUGET_PAT, PACKAGES_GITHUB_NUGET_URL, false));
_directoryResolver = new DirectoryResolver(RootDirectory);
_buildConfigurationManager = new BuildConfigurationManager(Solution);

Expand Down Expand Up @@ -63,21 +63,15 @@ protected override void OnBuildInitialized()
.Unlisted()
.Description(Description.Clean)
.OnlyWhenStatic(() => IsLocalBuild)
.Executes(() =>
{
_directoryResolver.SourceDirectory.GlobDirectories(FileSystem.CleanUpGlobPatterns).DeleteDirectories();
});
.Executes(() => _directoryResolver.SourceDirectory.GlobDirectories(FileSystem.CleanUpGlobPatterns).DeleteDirectories());

Target Restore => _ => _
.Description(Description.Restore)
.DependsOn(Clean)
.Executes(() =>
{
DotNetRestore(_ => _
.Executes(() => DotNetRestore(_ => _
.SetProjectFile(Solution)
.SetIgnoreFailedSources(IgnoreFailedSources)
);
});
));

Target Compile => _ => _
.Description(Description.Compile)
Expand Down Expand Up @@ -153,9 +147,9 @@ protected override void OnBuildInitialized()
Assert.True(nugetFiles.Any(), LogMessage.Assertion.NoNugetFilesExist);
(string Token, string Url) = _releaseGuard.ResolvePublishDestinationDetails();
(string Token, string Url, bool HasNoValue) = _releaseGuard.ResolvePublishDestinationDetails();
if (string.IsNullOrEmpty(Token))
if (HasNoValue)
{
Log.Information(LogMessage.NothingPushed);
}
Expand Down
4 changes: 2 additions & 2 deletions build/ReleaseGuard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public PackagePublishConfig ResolvePublishDestinationDetails()
}
else
{
return new PackagePublishConfig(string.Empty, string.Empty);
return new PackagePublishConfig(string.Empty, string.Empty, true);
}
}
}

public record PackagePublishConfig(string Token, string Url);
public record PackagePublishConfig(string Token, string Url, bool HasNoValue);

0 comments on commit 687d747

Please sign in to comment.