From d3261c545fb39abd56381c3f170e53c89c722ba5 Mon Sep 17 00:00:00 2001 From: Anthony Perez Date: Mon, 21 Mar 2016 13:25:25 +0000 Subject: [PATCH 1/3] Add AssemblyInfoFile.getAssemblyInformationalVersion method --- src/app/FakeLib/AssemblyInfoFile.fs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/FakeLib/AssemblyInfoFile.fs b/src/app/FakeLib/AssemblyInfoFile.fs index ba8e5060416..2478e033636 100644 --- a/src/app/FakeLib/AssemblyInfoFile.fs +++ b/src/app/FakeLib/AssemblyInfoFile.fs @@ -150,6 +150,11 @@ let private getAssemblyVersionInfo attributes = | Some attr -> attr.Value | None _ -> "\"" + buildVersion + "\"" +let private getAssemblyInformationalVersion attributes = + match attributes |> Seq.tryFind (fun (attr : Attribute) -> attr.Name = "AssemblyInformationalVersion") with + | Some attr -> attr.Value + | None _ -> getAssemblyVersionInfo attributes + /// Creates a C# AssemblyInfo file with the given attributes and configuration. /// The generated AssemblyInfo file contains an AssemblyVersionInformation class which can be used to retrieve the current version no. from inside of an assembly. let CreateCSharpAssemblyInfoWithConfig outputFileName attributes (config : AssemblyInfoFileConfig) = From 1eecddaf0685aa1c4c9702cd9daca64c1211e78a Mon Sep 17 00:00:00 2001 From: Anthony Perez Date: Mon, 21 Mar 2016 13:25:45 +0000 Subject: [PATCH 2/3] Add InformationalVersion to all AssemblyVersionInformation definitions (C#, F#, and VB) --- src/app/FakeLib/AssemblyInfoFile.fs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/FakeLib/AssemblyInfoFile.fs b/src/app/FakeLib/AssemblyInfoFile.fs index 2478e033636..c04e61cea76 100644 --- a/src/app/FakeLib/AssemblyInfoFile.fs +++ b/src/app/FakeLib/AssemblyInfoFile.fs @@ -173,6 +173,7 @@ let CreateCSharpAssemblyInfoWithConfig outputFileName attributes (config : Assem [ sprintf "namespace %s {" useNamespace " internal static class AssemblyVersionInformation {" sprintf " internal const string Version = %s;" (getAssemblyVersionInfo attributes) + sprintf " internal const string InformationalVersion = %s;" (getAssemblyInformationalVersion attributes) " }" "}" ] else [] @@ -199,7 +200,9 @@ let CreateFSharpAssemblyInfoWithConfig outputFileName attributes (config : Assem let optional = [ "module internal AssemblyVersionInformation =" - sprintf " let [] Version = %s" (getAssemblyVersionInfo attributes) ] + sprintf " let [] Version = %s" (getAssemblyVersionInfo attributes) + sprintf " let [] InformationalVersion = %s" (getAssemblyInformationalVersion attributes) + ] if generateClass then required @ optional else required @@ -223,6 +226,7 @@ let CreateVisualBasicAssemblyInfoWithConfig outputFileName attributes (config : if generateClass then [ "Friend NotInheritable Class AssemblyVersionInformation" sprintf " Friend Const Version As String = %s" (getAssemblyVersionInfo attributes) + sprintf " Friend Const InformationalVersion As String = %s" (getAssemblyInformationalVersion attributes) "End Class" ] else [] From 41409e297d0d3a4f40a71f0ff4360e4cc5a294cf Mon Sep 17 00:00:00 2001 From: Anthony Perez Date: Mon, 21 Mar 2016 14:18:21 +0000 Subject: [PATCH 3/3] Adjust hard-coded test data in AssemblyInfoSpecs --- src/test/Test.FAKECore/AssemblyInfoSpecs.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/Test.FAKECore/AssemblyInfoSpecs.cs b/src/test/Test.FAKECore/AssemblyInfoSpecs.cs index 048954b22db..4dab20008d4 100644 --- a/src/test/Test.FAKECore/AssemblyInfoSpecs.cs +++ b/src/test/Test.FAKECore/AssemblyInfoSpecs.cs @@ -24,7 +24,7 @@ public class when_using_fsharp_task_with_default_config AssemblyInfoFile.Attribute.Version("1.0.0.0") }; AssemblyInfoFile.CreateFSharpAssemblyInfo(infoFile, attributes); - const string expected = "namespace System\r\nopen System.Reflection\r\n\r\n[]\r\n[]\r\ndo ()\r\n\r\nmodule internal AssemblyVersionInformation =\r\n let [] Version = \"1.0.0.0\"\r\n"; + const string expected = "namespace System\r\nopen System.Reflection\r\n\r\n[]\r\n[]\r\ndo ()\r\n\r\nmodule internal AssemblyVersionInformation =\r\n let [] Version = \"1.0.0.0\"\r\n let [] InformationalVersion = \"1.0.0.0\"\r\n"; File.ReadAllText(infoFile) .ShouldEqual(expected.Replace("\r\n", Environment.NewLine)); @@ -104,7 +104,7 @@ public class when_using_csharp_task_with_default_config AssemblyInfoFile.Attribute.Version("1.0.0.0") }; AssemblyInfoFile.CreateCSharpAssemblyInfo(infoFile, attributes); - const string expected = "// \r\nusing System.Reflection;\r\n\r\n[assembly: AssemblyProductAttribute(\"TestLib\")]\r\n[assembly: AssemblyVersionAttribute(\"1.0.0.0\")]\r\nnamespace System {\r\n internal static class AssemblyVersionInformation {\r\n internal const string Version = \"1.0.0.0\";\r\n }\r\n}\r\n"; + const string expected = "// \r\nusing System.Reflection;\r\n\r\n[assembly: AssemblyProductAttribute(\"TestLib\")]\r\n[assembly: AssemblyVersionAttribute(\"1.0.0.0\")]\r\nnamespace System {\r\n internal static class AssemblyVersionInformation {\r\n internal const string Version = \"1.0.0.0\";\r\n internal const string InformationalVersion = \"1.0.0.0\";\r\n }\r\n}\r\n"; File.ReadAllText(infoFile) .ShouldEqual(expected.Replace("\r\n", Environment.NewLine)); @@ -230,7 +230,7 @@ public class when_using_vb_task_with_default_config AssemblyInfoFile.Attribute.Version("1.0.0.0") }; AssemblyInfoFile.CreateVisualBasicAssemblyInfo(infoFile, attributes); - const string expected = "' \r\nImports System.Reflection\r\n\r\n\r\n\r\nFriend NotInheritable Class AssemblyVersionInformation\r\n Friend Const Version As String = \"1.0.0.0\"\r\nEnd Class\r\n"; + const string expected = "' \r\nImports System.Reflection\r\n\r\n\r\n\r\nFriend NotInheritable Class AssemblyVersionInformation\r\n Friend Const Version As String = \"1.0.0.0\"\r\n Friend Const InformationalVersion As String = \"1.0.0.0\"\r\nEnd Class\r\n"; File.ReadAllText(infoFile) .ShouldEqual(expected.Replace("\r\n", Environment.NewLine));