Skip to content

Commit 6098afe

Browse files
committed
(build) improve build constants
1 parent 0d2d67c commit 6098afe

14 files changed

+21
-26
lines changed

.github/workflows/_unit_tests.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ env:
77

88
jobs:
99
unit_test:
10-
name: ${{ matrix.os }} - ${{ matrix.targetFramework }}
10+
name: ${{ matrix.os }} - net${{ matrix.targetFramework }}
1111
env:
1212
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1313
strategy:
1414
fail-fast: false
1515
matrix:
1616
os: [windows-latest, ubuntu-latest, macos-13, macos-14]
17-
targetFramework: [ 'net8.0', 'net7.0', 'net6.0' ]
17+
targetFramework: [ '6.0', '7.0', '8.0' ]
1818

1919
runs-on: ${{ matrix.os }}
2020
steps:
@@ -34,6 +34,6 @@ jobs:
3434
-
3535
name: Test Summary
3636
uses: test-summary/[email protected]
37-
if: matrix.targetFramework == 'net8.0'
37+
if: matrix.targetFramework == '8.0'
3838
with:
3939
paths: artifacts/test-results/*.results.xml

build/.run/Artifacts DotnetTool Test.run.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Artifacts DotnetTool Test" type="DotNetProject" factoryName=".NET Project" folderName="Artifacts">
33
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/artifacts.exe" />
4-
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsDotnetToolTest --arch=amd64 --docker_dotnetversion=6.0 --docker_distro=debian.11" />
4+
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsDotnetToolTest --arch=amd64 --docker_dotnetversion=8.0 --docker_distro=alpine.3.17" />
55
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
66
<option name="PASS_PARENT_ENVS" value="1" />
77
<envs>

build/.run/Artifacts MsBuildCore Test.run.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Artifacts MsBuildCore Test" type="DotNetProject" factoryName=".NET Project" folderName="Artifacts">
33
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/artifacts.exe" />
4-
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsMsBuildCoreTest --arch=amd64 --docker_dotnetversion=6.0 --docker_distro=alpine.3.17" />
4+
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsMsBuildCoreTest --arch=amd64 --docker_dotnetversion=8.0 --docker_distro=alpine.3.17" />
55
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
66
<option name="PASS_PARENT_ENVS" value="1" />
77
<envs>

build/.run/Artifacts Native Test.run.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Artifacts Native Test" type="DotNetProject" factoryName=".NET Project" folderName="Artifacts">
33
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/artifacts.exe" />
4-
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsNativeTest --arch=amd64 --docker_dotnetversion=6.0 --docker_distro=alpine.3.17" />
4+
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsNativeTest --arch=amd64 --docker_dotnetversion=8.0 --docker_distro=alpine.3.17" />
55
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
66
<option name="PASS_PARENT_ENVS" value="1" />
77
<envs>

build/.run/Artifacts Prepare.run.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Artifacts Prepare" type="DotNetProject" factoryName=".NET Project" folderName="Artifacts">
33
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/artifacts.exe" />
4-
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsPrepare --docker_dotnetversion=6.0 --docker_distro=alpine.3.17" />
4+
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsPrepare --docker_dotnetversion=8.0 --docker_distro=alpine.3.17" />
55
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
66
<option name="PASS_PARENT_ENVS" value="1" />
77
<envs>

build/.run/Artifacts Test.run.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Artifacts Test" type="DotNetProject" factoryName=".NET Project" folderName="Artifacts">
33
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/artifacts.exe" />
4-
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsTest --docker_dotnetversion=6.0 --docker_distro=alpine.3.17" />
4+
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsTest --docker_dotnetversion=8.0 --docker_distro=alpine.3.17" />
55
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
66
<option name="PASS_PARENT_ENVS" value="1" />
77
<envs>

build/artifacts/BuildLifetime.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public override void Setup(BuildContext context, ISetupContext info)
1515
var dotnetVersion = context.Argument(Arguments.DockerDotnetVersion, string.Empty).ToLower();
1616
var dockerDistro = context.Argument(Arguments.DockerDistro, string.Empty).ToLower();
1717

18-
var versions = string.IsNullOrWhiteSpace(dotnetVersion) ? Constants.VersionsToBuild : [dotnetVersion];
18+
var versions = string.IsNullOrWhiteSpace(dotnetVersion) ? Constants.Frameworks : [dotnetVersion];
1919
var distros = string.IsNullOrWhiteSpace(dockerDistro) ? Constants.DockerDistrosToBuild : [dockerDistro];
2020

2121
var architectures = context.HasArgument(Arguments.Architecture) ? context.Arguments<Architecture>(Arguments.Architecture) : Constants.ArchToBuild;

build/artifacts/Tasks/ArtifactsMsBuildFullTest.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ public override void Run(BuildContext context)
2323
var nugetSource = context.MakeAbsolute(Paths.Nuget).FullPath;
2424

2525
context.Information("\nTesting msbuild task with dotnet build\n");
26-
foreach (var framework in Constants.Frameworks)
26+
foreach (var netVersion in Constants.Frameworks)
2727
{
28+
var framework = $"net{netVersion}";
2829
var dotnetMsBuildSettings = new DotNetMSBuildSettings();
2930
dotnetMsBuildSettings.SetTargetFramework(framework);
3031
dotnetMsBuildSettings.WithProperty("GitVersionMsBuildVersion", version);

build/build/Tasks/BuildPrepare.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public override void Run(BuildContext context)
2525
Verbosity = DotNetVerbosity.Minimal,
2626
Configuration = Constants.DefaultConfiguration,
2727
OutputDirectory = Paths.Tools.Combine("gitversion"),
28-
Framework = Constants.NetVersionLatest,
28+
Framework = $"net{Constants.VersionLatest}",
2929
NoRestore = true,
3030
});
3131

@@ -35,7 +35,7 @@ public override void Run(BuildContext context)
3535
Verbosity = DotNetVerbosity.Minimal,
3636
Configuration = Constants.DefaultConfiguration,
3737
OutputDirectory = Paths.Tools.Combine("schema"),
38-
Framework = Constants.NetVersionLatest,
38+
Framework = $"net{Constants.VersionLatest}",
3939
NoRestore = true,
4040
});
4141
}

build/build/Tasks/Package/PackagePrepare.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private static DirectoryPath PackPrepareNative(BuildContext context, string runt
5151

5252
var settings = new DotNetPublishSettings
5353
{
54-
Framework = Constants.NetVersionLatest,
54+
Framework = $"net{Constants.VersionLatest}",
5555
Runtime = runtime,
5656
NoRestore = false,
5757
Configuration = context.MsBuildConfiguration,

build/build/Tasks/Test/UnitTest.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Build.Tasks;
88

99
[TaskName(nameof(UnitTest))]
1010
[TaskDescription("Run the unit tests")]
11-
[TaskArgument(Arguments.DotnetTarget, Constants.NetVersion60, Constants.NetVersion70, Constants.NetVersion80)]
11+
[TaskArgument(Arguments.DotnetTarget, Constants.Version60, Constants.Version70, Constants.Version80)]
1212
[IsDependentOn(typeof(Build))]
1313
public class UnitTest : FrostingTask<BuildContext>
1414
{
@@ -62,14 +62,14 @@ public override void Finally(BuildContext context)
6262
private static void TestProjectForTarget(BuildContext context, FilePath project, string framework)
6363
{
6464
var testResultsPath = Paths.TestOutput;
65-
var projectName = $"{project.GetFilenameWithoutExtension()}.{framework}";
65+
var projectName = $"{project.GetFilenameWithoutExtension()}.net{framework}";
6666
var settings = new DotNetTestSettings
6767
{
68-
Framework = framework,
68+
Framework = $"net{framework}",
6969
NoBuild = true,
7070
NoRestore = true,
7171
Configuration = context.MsBuildConfiguration,
72-
TestAdapterPath = new DirectoryPath(".")
72+
TestAdapterPath = new(".")
7373
};
7474

7575
var resultsPath = context.MakeAbsolute(testResultsPath.CombineWithFilePath($"{projectName}.results.xml"));

build/common/Utilities/Constants.cs

+1-7
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,11 @@ public class Constants
1010
public const string Version80 = "8.0";
1111
public const string VersionLatest = Version80;
1212

13-
public const string NetVersion60 = $"net{Version60}";
14-
public const string NetVersion70 = $"net{Version70}";
15-
public const string NetVersion80 = $"net{Version80}";
16-
public const string NetVersionLatest = $"net{VersionLatest}";
17-
1813
public const string DefaultBranch = "main";
1914
public const string DefaultConfiguration = "Release";
2015

2116
public static readonly Architecture[] ArchToBuild = [Architecture.Amd64, Architecture.Arm64];
22-
public static readonly string[] VersionsToBuild = [Version60, Version70, Version80];
23-
public static readonly string[] Frameworks = [NetVersion60, NetVersion70, NetVersion80];
17+
public static readonly string[] Frameworks = [Version60, Version70, Version80];
2418

2519
public const string DockerBaseImageName = "gittools/build-images";
2620
public const string DockerImageName = "gittools/gitversion";

build/common/Utilities/ContextExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public static string GetRepositoryName(this ICakeContext context)
180180
private static void EndGroup(this IAzurePipelinesCommands _, ICakeContext context) => context.Information("##[endgroup]");
181181

182182
public static FilePath? GetGitVersionToolLocation(this ICakeContext context) =>
183-
context.GetFiles($"src/GitVersion.App/bin/{Constants.DefaultConfiguration}/{Constants.NetVersionLatest}/gitversion.dll").SingleOrDefault();
183+
context.GetFiles($"src/GitVersion.App/bin/{Constants.DefaultConfiguration}/net{Constants.VersionLatest}/gitversion.dll").SingleOrDefault();
184184
public static FilePath? GetGitVersionDotnetToolLocation(this ICakeContext context) =>
185185
context.MakeAbsolute(Paths.Tools.Combine("gitversion").CombineWithFilePath("gitversion.dll"));
186186

build/docker/BuildLifetime.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public override void Setup(BuildContext context, ISetupContext info)
1818
var dotnetVersion = context.Argument(Arguments.DockerDotnetVersion, string.Empty).ToLower();
1919
var dockerDistro = context.Argument(Arguments.DockerDistro, string.Empty).ToLower();
2020

21-
var versions = string.IsNullOrWhiteSpace(dotnetVersion) ? Constants.VersionsToBuild : [dotnetVersion];
21+
var versions = string.IsNullOrWhiteSpace(dotnetVersion) ? Constants.Frameworks : [dotnetVersion];
2222
var distros = string.IsNullOrWhiteSpace(dockerDistro) ? Constants.DockerDistrosToBuild : [dockerDistro];
2323

2424
var architectures = context.HasArgument(Arguments.Architecture) ? context.Arguments<Architecture>(Arguments.Architecture) : Constants.ArchToBuild;

0 commit comments

Comments
 (0)