Skip to content

Commit

Permalink
(build) cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
arturcic committed Mar 7, 2020
1 parent ff09583 commit 026bcbb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .artifactignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
**/*

!artifacts/*/bin/netcoreapp2.1
!artifacts/*/bin/netcoreapp3.1
artifacts/build-artifact
artifacts/test-results
!artifacts/*/nuget

!artifacts/*/*.tar.gz
Expand Down
1 change: 0 additions & 1 deletion build/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Task("Build")
.Does<BuildParameters>((parameters) =>
{
Build(parameters);
PublishGitVersionToArtifacts(parameters);

RunGitVersionOnCI(parameters);
});
Expand Down
4 changes: 3 additions & 1 deletion build/docker-build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ Task("Docker-Build")
var workDir = DirectoryPath.FromString($"./src/Docker");

var tool = parameters.Paths.Directories.NugetRoot.CombineWithFilePath("GitVersion.Tool*");
CopyFiles(tool.FullPath, workDir.Combine("content"));
var dest = workDir.Combine("content");
EnsureDirectoryExists(dest);
CopyFiles(tool.FullPath, dest);

foreach(var dockerImage in parameters.Docker.Images)
{
Expand Down
24 changes: 3 additions & 21 deletions build/utils/paths.cake
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ public class BuildPaths
var artifactsBinDir = artifactsDir.Combine("bin");
var artifactsBinPortableDir = artifactsBinDir.Combine("portable");
var artifactsBinCmdlineDir = artifactsBinDir.Combine("cmdline");
var artifactsBinCoreFx21Dir = artifactsBinDir.Combine(parameters.CoreFxVersion21);
var artifactsBinCoreFx30Dir = artifactsBinDir.Combine(parameters.CoreFxVersion31);
var artifactsBinFullFx472Dir = artifactsBinDir.Combine(parameters.FullFxVersion472);
var nativeDir = artifactsDir.Combine("native");
var nugetRootDir = artifactsDir.Combine("nuget");
var buildArtifactDir = artifactsDir.Combine("build-artifact");
Expand All @@ -53,10 +50,7 @@ public class BuildPaths
nugetRootDir,
artifactsBinDir,
artifactsBinPortableDir,
artifactsBinCmdlineDir,
artifactsBinCoreFx21Dir,
artifactsBinCoreFx30Dir,
artifactsBinFullFx472Dir);
artifactsBinCmdlineDir);

return new BuildPaths
{
Expand All @@ -78,9 +72,6 @@ public class BuildDirectories
public DirectoryPath ArtifactsBin { get; private set; }
public DirectoryPath ArtifactsBinPortable { get; private set; }
public DirectoryPath ArtifactsBinCmdline { get; private set; }
public DirectoryPath ArtifactsBinCoreFx21 { get; private set; }
public DirectoryPath ArtifactsBinCoreFx30 { get; private set; }
public DirectoryPath ArtifactsBinFullFx472 { get; private set; }
public ICollection<DirectoryPath> ToClean { get; private set; }

public BuildDirectories(
Expand All @@ -94,10 +85,7 @@ public class BuildDirectories
DirectoryPath nugetRootDir,
DirectoryPath artifactsBinDir,
DirectoryPath artifactsBinPortableDir,
DirectoryPath artifactsBinCmdlineDir,
DirectoryPath artifactsBinCoreFx21Dir,
DirectoryPath artifactsBinCoreFx30Dir,
DirectoryPath artifactsBinFullFx472Dir
DirectoryPath artifactsBinCmdlineDir
)
{
Root = rootDir;
Expand All @@ -111,9 +99,6 @@ public class BuildDirectories
ArtifactsBin = artifactsBinDir;
ArtifactsBinPortable = artifactsBinPortableDir;
ArtifactsBinCmdline = artifactsBinCmdlineDir;
ArtifactsBinCoreFx21 = artifactsBinCoreFx21Dir;
ArtifactsBinCoreFx30 = artifactsBinCoreFx30Dir;
ArtifactsBinFullFx472 = artifactsBinFullFx472Dir;
ToClean = new[] {
Artifacts,
Native,
Expand All @@ -122,10 +107,7 @@ public class BuildDirectories
NugetRoot,
ArtifactsBin,
ArtifactsBinPortable,
ArtifactsBinCmdline,
ArtifactsBinCoreFx21,
ArtifactsBinCoreFx30,
ArtifactsBinFullFx472
ArtifactsBinCmdline
};
}
}
17 changes: 11 additions & 6 deletions build/utils/utils.cake
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ GitVersion GetVersion(BuildParameters parameters)
Build(parameters);

var settings = new GitVersionSettings { OutputType = GitVersionOutput.Json };
SetGitVersionTool(settings, parameters, "src/GitVersionExe/**");
SetGitVersionTool(settings, parameters);

gitVersion = GitVersion(settings);
SerializeJsonToPrettyFile(gitversionFilePath, gitVersion);
Expand All @@ -128,9 +128,9 @@ GitVersion GetVersion(BuildParameters parameters)

void ValidateVersion(BuildParameters parameters)
{
var gitVersionTool = GetFiles($"artifacts/**/bin/{parameters.CoreFxVersion31}/gitversion.dll").FirstOrDefault();
var gitversionTool = GetGitVersionToolLocation(parameters);

ValidateOutput("dotnet", $"\"{gitVersionTool}\" -version", parameters.Version.GitVersion.InformationalVersion);
ValidateOutput("dotnet", $"\"{gitversionTool}\" -version", parameters.Version.GitVersion.InformationalVersion);
}

void ValidateOutput(string cmd, string args, string expected)
Expand All @@ -152,22 +152,27 @@ void RunGitVersionOnCI(BuildParameters parameters)
LogFilePath = "console",
OutputType = GitVersionOutput.BuildServer
};
SetGitVersionTool(settings, parameters, "artifacts/**/bin");
SetGitVersionTool(settings, parameters);

GitVersion(settings);
}
}

GitVersionSettings SetGitVersionTool(GitVersionSettings settings, BuildParameters parameters, string toolPath)
GitVersionSettings SetGitVersionTool(GitVersionSettings settings, BuildParameters parameters)
{
var gitversionTool = GetFiles($"{toolPath}/{parameters.CoreFxVersion31}/gitversion.dll").FirstOrDefault();
var gitversionTool = GetGitVersionToolLocation(parameters);

settings.ToolPath = Context.FindToolInPath(IsRunningOnUnix() ? "dotnet" : "dotnet.exe");
settings.ArgumentCustomization = args => gitversionTool + " " + args.Render();

return settings;
}

FilePath GetGitVersionToolLocation(BuildParameters parameters)
{
return GetFiles($"src/GitVersionExe/**/{parameters.CoreFxVersion31}/gitversion.dll").SingleOrDefault();
}

void PublishGitVersionToArtifacts(BuildParameters parameters)
{
var frameworks = new[] { parameters.CoreFxVersion21, parameters.CoreFxVersion31, parameters.FullFxVersion472 };
Expand Down

0 comments on commit 026bcbb

Please sign in to comment.