Skip to content

Commit

Permalink
Add file and information version to MSBuild call (RicoSuter#3774)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma committed Dec 3, 2021
1 parent d9ab430 commit acdb04f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
1 change: 1 addition & 0 deletions build/Build.Pack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public partial class Build
.SetConfiguration(Configuration)
.SetOutputDirectory(ArtifactsDirectory)
.SetDeterministic(IsServerBuild)
.SetContinuousIntegrationBuild(IsServerBuild)
);
}
Expand Down
33 changes: 23 additions & 10 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,14 @@ protected override void OnBuildInitialized()
MSBuild(x => x
.SetTargetPath(Solution)
.SetTargets("Rebuild")
.SetAssemblyVersion(VersionPrefix)
.SetFileVersion(VersionPrefix)
.SetInformationalVersion(VersionPrefix)
.SetConfiguration(Configuration)
.SetMaxCpuCount(Environment.ProcessorCount)
.SetNodeReuse(IsLocalBuild)
.SetVerbosity(MSBuildVerbosity.Minimal)
.SetProperty("ContinuousIntegrationBuild", IsServerBuild)
);
});

Expand Down Expand Up @@ -236,7 +239,7 @@ protected override void OnBuildInitialized()
foreach (var (projectName, runtime) in dotnetTargets)
{
var project = Solution.GetProject(projectName);
DotNetBuild(x => x
DotNetBuild(x => BuildDefaults(x)
.SetProcessWorkingDirectory(project.Directory)
.SetProperty("CopyLocalLockFileAssemblies", true)
);
Expand Down Expand Up @@ -277,7 +280,7 @@ void NSwagRun(
Project project,
string configurationFile,
string runtime,
string configuration,
Configuration configuration,
bool build)
{
var nswagConfigurationFile = project.Directory / $"{configurationFile}.nswag";
Expand All @@ -287,9 +290,9 @@ void NSwagRun(
if (build)
{
DotNetBuild(x => x
.SetProjectFile(project)
DotNetBuild(x => BuildDefaults(x)
.SetConfiguration(configuration)
.SetProjectFile(project)
);
}
else
Expand All @@ -310,13 +313,23 @@ void NSwagRun(
var samplesPath = RootDirectory / "samples";
var sampleSolution = ProjectModelTasks.ParseSolution(samplesPath / "Samples.sln");
NSwagRun(sampleSolution.GetProject("Sample.AspNetCore21"), "nswag_assembly", "NetCore21", "Release", true);
NSwagRun(sampleSolution.GetProject("Sample.AspNetCore21"), "nswag_project", "NetCore21", "Release", false);
NSwagRun(sampleSolution.GetProject("Sample.AspNetCore21"), "nswag_reflection", "NetCore21", "Release", true);
NSwagRun(sampleSolution.GetProject("Sample.AspNetCore21"), "nswag_assembly", "NetCore21", Configuration.Release, true);
NSwagRun(sampleSolution.GetProject("Sample.AspNetCore21"), "nswag_project", "NetCore21", Configuration.Release, false);
NSwagRun(sampleSolution.GetProject("Sample.AspNetCore21"), "nswag_reflection", "NetCore21", Configuration.Release, true);
NSwagRun(sampleSolution.GetProject("Sample.AspNetCore21"), "nswag_assembly", "NetCore21", "Debug", true);
NSwagRun(sampleSolution.GetProject("Sample.AspNetCore21"), "nswag_project", "NetCore21", "Debug", false);
NSwagRun(sampleSolution.GetProject("Sample.AspNetCore21"), "nswag_reflection", "NetCore21", "Debug", true);
NSwagRun(sampleSolution.GetProject("Sample.AspNetCore21"), "nswag_assembly", "NetCore21", Configuration.Debug, true);
NSwagRun(sampleSolution.GetProject("Sample.AspNetCore21"), "nswag_project", "NetCore21", Configuration.Debug, false);
NSwagRun(sampleSolution.GetProject("Sample.AspNetCore21"), "nswag_reflection", "NetCore21", Configuration.Debug, true);
});

DotNetBuildSettings BuildDefaults(DotNetBuildSettings s)
{
return s
.SetAssemblyVersion(VersionPrefix)
.SetFileVersion(VersionPrefix)
.SetInformationalVersion(VersionPrefix)
.SetConfiguration(Configuration)
.SetDeterministic(IsServerBuild)
.SetContinuousIntegrationBuild(IsServerBuild);
}
}

0 comments on commit acdb04f

Please sign in to comment.