From c542ed19362dadc5e4888850312eb95895293299 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Mon, 16 Aug 2021 11:01:49 +0100 Subject: [PATCH 1/2] [build] Use GitInfo to generate $(Version) (#131) Context: http://github.com/xamarin/xamarin-android/commit/2d81740cc1c708cd0474c9eac8936cd7abfc72e3 Context: https://github.com/xamarin/xamarin-android/issues/5749 In order to better support building solutions which reference both .NET 6 and legacy projects within Visual Studio, we have begun strong-naming all the MSBuild-related assemblies; see also 87acd6b9. This allows loading two different version of the "same" assembly, e.g. `Microsoft.Android.Build.BaseTasks.dll`, from two different locations within the same AppDomain/AssemblyLoadContext. However, strong-naming is only part of the solution. The other part is that, for sanity and reliability, the "two different versions of the 'same' assembly" should *also* have different assembly *versions*. If they have the same assembly version, are they truly different? Update the build system by adding a `Directory.Build.targets` and `GitInfo.txt` file so that the the [`GitInfo`][0] [NuGet Package][1] will be used to "fully" set the `$(Version)` MSBuild property, consisting of the major and minor version numbers contained within `GitInfo.txt`, along with a "computed" `$(GitSemVerPatch)` value based on the "patch version" in `GitInfo.txt`, if present, added to the number of commits which have occurred since `GitInfo.txt` changed. Additionally, set the `$(InformationalVersion)` MSBuild property so that it mirrors the behavior in [`Mono.Android.dll`][2]: [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.1; git-rev-head:4c2e36c; git-branch: main") [0]: https://github.com/devlooped/GitInfo [1]: https://www.nuget.org/packages/GitInfo/2.1.2 [2]: https://github.com/xamarin/xamarin-android/commit/b620689ddf0214b1e38d5feab9e2ea7a653614ff --- Directory.Build.targets | 16 ++++++++++++++++ GitInfo.txt | 1 + 2 files changed, 17 insertions(+) create mode 100644 Directory.Build.targets create mode 100644 GitInfo.txt diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 0000000..1253b09 --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,16 @@ + + + + + + false + main + + + + + $(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch) + $(Version); git-rev-head: $(GitCommit) git-branch: $(GitBranch) + + + \ No newline at end of file diff --git a/GitInfo.txt b/GitInfo.txt new file mode 100644 index 0000000..9f8e9b6 --- /dev/null +++ b/GitInfo.txt @@ -0,0 +1 @@ +1.0 \ No newline at end of file From 19adf866c61e96dff3004d1646859fec7970d2e7 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Thu, 19 Aug 2021 06:33:14 -0400 Subject: [PATCH 2/2] Format like Mono.Android.dll for consistency. --- Directory.Build.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index 1253b09..ec55b38 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -10,7 +10,7 @@ $(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch) - $(Version); git-rev-head: $(GitCommit) git-branch: $(GitBranch) + $(Version); git-rev-head:$(GitCommit); git-branch:$(GitBranch) - \ No newline at end of file +