diff --git a/ATXTray/Properties/Resources.resx b/ATXTray/Properties/Resources.resx index 719fb31fbd77075d95b9d67df6ceffaa2e4e9704..d6a0af53dafe6e325445385d04e904e89a2c64b7 100644 --- a/ATXTray/Properties/Resources.resx +++ b/ATXTray/Properties/Resources.resx @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <root> <!-- Microsoft ResX Schema @@ -119,10 +119,10 @@ </resheader> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <data name="BuildCommit" type="System.Resources.ResXFileRef, System.Windows.Forms"> - <value>..\Resources\BuildCommit.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value> + <value>..\..\Resources\BuildCommit.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value> </data> <data name="BuildDate" type="System.Resources.ResXFileRef, System.Windows.Forms"> - <value>..\Resources\BuildDate.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value> + <value>..\..\Resources\BuildDate.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value> </data> <data name="IconDefault" type="System.Resources.ResXFileRef, System.Windows.Forms"> <value>..\Resources\IconDefault.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> diff --git a/ATxCommon/ATxCommon.csproj b/ATxCommon/ATxCommon.csproj index aee0a693b530abd32dde3b1ef5155ea6af18a847..213dcb1cb988c8b808a37232790534f3e1f9439b 100644 --- a/ATxCommon/ATxCommon.csproj +++ b/ATxCommon/ATxCommon.csproj @@ -47,6 +47,7 @@ </ItemGroup> <ItemGroup> <Compile Include="ActiveDirectory.cs" /> + <Compile Include="BuildDetails.cs" /> <Compile Include="Conv.cs" /> <Compile Include="FsUtils.cs" /> <Compile Include="NLog\RateLimitWrapper.cs" /> @@ -61,6 +62,9 @@ <None Include="packages.config" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <PropertyGroup> + <PreBuildEvent>PowerShell -NoProfile -ExecutionPolicy RemoteSigned $(SolutionDir)Scripts\Prepare-Build.ps1 -SolutionDir $(SolutionDir) -ConfigurationName $(ConfigurationName)</PreBuildEvent> + </PropertyGroup> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> diff --git a/ATxCommon/BuildDetails.cs b/ATxCommon/BuildDetails.cs new file mode 100644 index 0000000000000000000000000000000000000000..dab096d1925c34bc7225ba37ea685cf06fce4606 --- /dev/null +++ b/ATxCommon/BuildDetails.cs @@ -0,0 +1,10 @@ +public static class BuildDetails +{ + public const string GitCommitName = "?commit?"; + public const string GitBranch = "?branch?"; + public const string GitMajor = "1"; + public const string GitMinor = "0"; + public const string GitPatch = "0"; + public const string BuildDate = "?build time?"; + public const string GitCommit = "?sha1?"; +} diff --git a/ATxCommon/Properties/AssemblyInfo.cs b/ATxCommon/Properties/AssemblyInfo.cs index 940f65421955479fbd1baa0854802454eebd4688..3ffd032f4093a5fc905ed45049144a75facde834 100644 --- a/ATxCommon/Properties/AssemblyInfo.cs +++ b/ATxCommon/Properties/AssemblyInfo.cs @@ -1,16 +1,15 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("ATxCommon")] +[assembly: AssemblyTitle("AutoTx Common")] [assembly: AssemblyDescription("AutoTx Common Runtime Libraries")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Universitaet Basel")] +[assembly: AssemblyCompany("IMCF, Biozentrum, University of Basel")] [assembly: AssemblyProduct("AutoTx")] -[assembly: AssemblyCopyright("Copyright © Universitaet Basel 2018")] +[assembly: AssemblyCopyright("© University of Basel 2018")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +31,13 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion(BuildDetails.GitMajor + "." + + BuildDetails.GitMinor + "." + + BuildDetails.GitPatch + ".0")] +[assembly: AssemblyFileVersion(BuildDetails.GitMajor + "." + + BuildDetails.GitMinor + "." + + BuildDetails.GitPatch + ".0")] + +[assembly: AssemblyInformationalVersion(BuildDetails.BuildDate + + " " + BuildDetails.GitCommit + + " (" + BuildDetails.GitBranch + ")")] diff --git a/ATxConfigTest/Properties/AssemblyInfo.cs b/ATxConfigTest/Properties/AssemblyInfo.cs index 690a990c47bace968895c7e68018ecf9cc637ba4..1c4175b6c97236393f0f3b87b6de755328c33418 100644 --- a/ATxConfigTest/Properties/AssemblyInfo.cs +++ b/ATxConfigTest/Properties/AssemblyInfo.cs @@ -1,16 +1,15 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("ATxConfigTest")] -[assembly: AssemblyDescription("")] +[assembly: AssemblyTitle("AutoTx ConfigTest")] +[assembly: AssemblyDescription("AutoTx Configuration Validator")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Universitaet Basel")] -[assembly: AssemblyProduct("ATxConfigTest")] -[assembly: AssemblyCopyright("Copyright © Universitaet Basel 2018")] +[assembly: AssemblyCompany("IMCF, Biozentrum, University of Basel")] +[assembly: AssemblyProduct("AutoTx")] +[assembly: AssemblyCopyright("© University of Basel 2018")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +31,13 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion(BuildDetails.GitMajor + "." + + BuildDetails.GitMinor + "." + + BuildDetails.GitPatch + ".0")] +[assembly: AssemblyFileVersion(BuildDetails.GitMajor + "." + + BuildDetails.GitMinor + "." + + BuildDetails.GitPatch + ".0")] + +[assembly: AssemblyInformationalVersion(BuildDetails.BuildDate + + " " + BuildDetails.GitCommit + + " (" + BuildDetails.GitBranch + ")")] diff --git a/ATxService/ATxService.csproj b/ATxService/ATxService.csproj index b9c7e8642f5775554bce85d5a3459fdf94717e58..d8a2c527578ae7dead1ea1f912969caa418a46b8 100644 --- a/ATxService/ATxService.csproj +++ b/ATxService/ATxService.csproj @@ -141,10 +141,6 @@ </ItemGroup> <ItemGroup> <None Include="packages.config" /> - <None Include="Resources\BuildDate.txt" /> - </ItemGroup> - <ItemGroup> - <None Include="Resources\BuildCommit.txt" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\ATxCommon\ATxCommon.csproj"> @@ -153,6 +149,12 @@ </ProjectReference> </ItemGroup> <ItemGroup> + <None Include="..\Resources\BuildCommit.txt"> + <Link>Resources\BuildCommit.txt</Link> + </None> + <None Include="..\Resources\BuildDate.txt"> + <Link>Resources\BuildDate.txt</Link> + </None> <Content Include="..\Resources\Mail-Templates\DiskSpace-Low.txt"> <Link>Mail-Templates\DiskSpace-Low.txt</Link> <CopyToOutputDirectory>Always</CopyToOutputDirectory> @@ -168,11 +170,11 @@ </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <PropertyGroup> - <PreBuildEvent>PowerShell -NoProfile -ExecutionPolicy RemoteSigned $(SolutionDir)\Scripts\Prepare-Build.ps1 $(ProjectDir)</PreBuildEvent> + <PreBuildEvent>PowerShell -NoProfile -ExecutionPolicy RemoteSigned $(SolutionDir)Scripts\Prepare-Build.ps1 -SolutionDir $(SolutionDir) -ConfigurationName $(ConfigurationName)</PreBuildEvent> </PropertyGroup> <PropertyGroup> - <PostBuildEvent>PowerShell -Command "Write-Host $(ConfigurationName)" > $(ProjectDir)\Resources\BuildConfiguration.txt -</PostBuildEvent> + <PostBuildEvent> + </PostBuildEvent> </PropertyGroup> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. diff --git a/ATxService/AutoTx.cs b/ATxService/AutoTx.cs index 2df178a3f40c0e628334d54a362f8f945a19e872..c515f7fe71cd143fece548a45576fc07868915e5 100644 --- a/ATxService/AutoTx.cs +++ b/ATxService/AutoTx.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using System.Linq; using System.ServiceProcess; using System.IO; +using System.Reflection; using System.Timers; using ATxCommon; using ATxCommon.NLog; @@ -274,12 +275,22 @@ namespace ATxService /// Write a summary of loaded config + status to the log. /// </summary> private void StartupSummary() { - var msg = "Startup Summary:\n\n------ RoboSharp ------\n"; - var roboDll = System.Reflection.Assembly.GetAssembly(typeof(RoboCommand)).Location; - var versionInfo = FileVersionInfo.GetVersionInfo(roboDll); - msg += " > DLL file: " + roboDll + "\n" + - " > DLL description: " + versionInfo.Comments + "\n" + - " > DLL version: " + versionInfo.FileVersion + "\n"; + var msg = "Startup Summary:\n\n"; + + var assembly = Assembly.GetExecutingAssembly(); + var versionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); + msg += "------ Assembly Information ------\n" + + $" > version: {assembly.GetName().Version}\n" + + $" > file version: {versionInfo.FileVersion}\n" + + $" > description: {versionInfo.Comments}\n" + + $" > version information: {versionInfo.ProductVersion}\n"; + + var roboDll = Assembly.GetAssembly(typeof(RoboCommand)).Location; + var roboVersionInfo = FileVersionInfo.GetVersionInfo(roboDll); + msg += "\n------ RoboSharp ------\n" + + $" > DLL location: {roboDll}\n" + + $" > DLL description: {roboVersionInfo.Comments}\n" + + $" > DLL file version: {roboVersionInfo.FileVersion}\n"; msg += "\n------ Loaded status flags ------\n" + _status.Summary() + @@ -333,10 +344,14 @@ namespace ATxService // read the build timestamp from the resources: var buildTimestamp = Properties.Resources.BuildDate.Trim(); var buildCommitName = Properties.Resources.BuildCommit.Trim(); + var assembly = Assembly.GetExecutingAssembly(); + var versionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); + Log.Info("-----------------------"); Log.Info("{0} service started.", ServiceName); Log.Info("build: [{0}]", buildTimestamp); Log.Info("commit: [{0}]", buildCommitName); + Log.Info("product version: [{0}]", versionInfo.ProductVersion); Log.Info("-----------------------"); } diff --git a/ATxService/Properties/AssemblyInfo.cs b/ATxService/Properties/AssemblyInfo.cs index 0ae1c6aad63d704f218057d273fb2f0bfaa804ef..73261ca529769bb8d98bd6e44c5c8d63b4b69878 100644 --- a/ATxService/Properties/AssemblyInfo.cs +++ b/ATxService/Properties/AssemblyInfo.cs @@ -4,12 +4,12 @@ using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("AutoTx")] +[assembly: AssemblyTitle("AutoTx Service")] [assembly: AssemblyDescription("Automatic Background Transfer Service")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("IMCF, Biozentrum, University of Basel")] [assembly: AssemblyProduct("AutoTx")] -[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyCopyright("© University of Basel 2018")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -31,5 +31,13 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion(BuildDetails.GitMajor + "." + + BuildDetails.GitMinor + "." + + BuildDetails.GitPatch + ".0")] +[assembly: AssemblyFileVersion(BuildDetails.GitMajor + "." + + BuildDetails.GitMinor + "." + + BuildDetails.GitPatch + ".0")] + +[assembly: AssemblyInformationalVersion(BuildDetails.BuildDate + + " " + BuildDetails.GitCommit + + " (" + BuildDetails.GitBranch + ")")] diff --git a/ATxService/Properties/Resources.Designer.cs b/ATxService/Properties/Resources.Designer.cs index 26be70d215a1b4caeef7b4d575ef0e84b8d29e07..f51568b5ae15eba2a07ca9344163c3feca7fe034 100644 --- a/ATxService/Properties/Resources.Designer.cs +++ b/ATxService/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace ATxService.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -61,7 +61,7 @@ namespace ATxService.Properties { } /// <summary> - /// Looks up a localized string similar to autotransfer-v1-236-gc48c399 + /// Looks up a localized string similar to 2.0-9-g98d8fc9-unclean ///. /// </summary> internal static string BuildCommit { @@ -71,7 +71,7 @@ namespace ATxService.Properties { } /// <summary> - /// Looks up a localized string similar to 2018-02-01 01:23:43 + /// Looks up a localized string similar to 2018-02-27 15:06:43 ///. /// </summary> internal static string BuildDate { diff --git a/ATxService/Properties/Resources.resx b/ATxService/Properties/Resources.resx index 0cf010f92b4834cfd281dd28fcb065bda0126202..af8a8e0d8aede6daca783f9de816c4e837b9105f 100644 --- a/ATxService/Properties/Resources.resx +++ b/ATxService/Properties/Resources.resx @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <root> <!-- Microsoft ResX Schema @@ -119,9 +119,9 @@ </resheader> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <data name="BuildCommit" type="System.Resources.ResXFileRef, System.Windows.Forms"> - <value>..\Resources\BuildCommit.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value> + <value>..\..\Resources\BuildCommit.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value> </data> <data name="BuildDate" type="System.Resources.ResXFileRef, System.Windows.Forms"> - <value>..\Resources\BuildDate.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value> + <value>..\..\Resources\BuildDate.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value> </data> </root> \ No newline at end of file diff --git a/ATxTray/ATXTray.csproj b/ATxTray/ATXTray.csproj index 3080ad93074147a400cc7d657d27f7ac43fa55ef..d426eed2e12735bcaff6f20efe62efaa138b28e5 100644 --- a/ATxTray/ATXTray.csproj +++ b/ATxTray/ATXTray.csproj @@ -108,16 +108,21 @@ </ProjectReference> </ItemGroup> <ItemGroup> + <Content Include="..\Resources\BuildCommit.txt"> + <Link>Resources\BuildCommit.txt</Link> + </Content> + <Content Include="..\Resources\BuildDate.txt"> + <Link>Resources\BuildDate.txt</Link> + </Content> <Content Include="IconDefault.ico" /> - <None Include="Resources\BuildDate.txt" /> - <None Include="Resources\BuildCommit.txt" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <PropertyGroup> - <PreBuildEvent>PowerShell -NoProfile -ExecutionPolicy RemoteSigned $(SolutionDir)\Scripts\Prepare-Build.ps1 $(ProjectDir)</PreBuildEvent> + <PreBuildEvent>PowerShell -NoProfile -ExecutionPolicy RemoteSigned $(SolutionDir)Scripts\Prepare-Build.ps1 -SolutionDir $(SolutionDir) -ConfigurationName $(ConfigurationName)</PreBuildEvent> </PropertyGroup> <PropertyGroup> - <PostBuildEvent>PowerShell -Command "Write-Host $(ConfigurationName)" > $(ProjectDir)\Resources\BuildConfiguration.txt</PostBuildEvent> + <PostBuildEvent> + </PostBuildEvent> </PropertyGroup> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. diff --git a/ATxTray/Properties/AssemblyInfo.cs b/ATxTray/Properties/AssemblyInfo.cs index 6234f84dc8b3aad0afa6e164962d0644d37363a5..9642ea06a3624dc8eb390593d6a3186399a1eb5a 100644 --- a/ATxTray/Properties/AssemblyInfo.cs +++ b/ATxTray/Properties/AssemblyInfo.cs @@ -1,16 +1,15 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("ATxTray")] +[assembly: AssemblyTitle("AutoTx Tray")] [assembly: AssemblyDescription("AutoTx Tray Monitor")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Universitaet Basel")] -[assembly: AssemblyProduct("ATxTray")] -[assembly: AssemblyCopyright("Copyright © Universitaet Basel 2018")] +[assembly: AssemblyCompany("IMCF, Biozentrum, University of Basel")] +[assembly: AssemblyProduct("AutoTx")] +[assembly: AssemblyCopyright("© University of Basel 2018")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +31,13 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion(BuildDetails.GitMajor + "." + + BuildDetails.GitMinor + "." + + BuildDetails.GitPatch + ".0")] +[assembly: AssemblyFileVersion(BuildDetails.GitMajor + "." + + BuildDetails.GitMinor + "." + + BuildDetails.GitPatch + ".0")] + +[assembly: AssemblyInformationalVersion(BuildDetails.BuildDate + + " " + BuildDetails.GitCommit + + " (" + BuildDetails.GitBranch + ")")] diff --git a/ATxTray/Properties/Resources.Designer.cs b/ATxTray/Properties/Resources.Designer.cs index cc28f91d0d48e056ea8f86d1b1efb17ba7900d6a..ea2b14874bb4731492425b712ff7e42d3771b9bd 100644 --- a/ATxTray/Properties/Resources.Designer.cs +++ b/ATxTray/Properties/Resources.Designer.cs @@ -61,7 +61,7 @@ namespace ATxTray.Properties { } /// <summary> - /// Looks up a localized string similar to autotransfer-v1-265-g1b03979-unclean + /// Looks up a localized string similar to 2.0-9-g98d8fc9-unclean ///. /// </summary> internal static string BuildCommit { @@ -71,7 +71,7 @@ namespace ATxTray.Properties { } /// <summary> - /// Looks up a localized string similar to 2018-02-06 11:38:53 + /// Looks up a localized string similar to 2018-02-27 15:22:30 ///. /// </summary> internal static string BuildDate { diff --git a/ATxTray/Resources/.gitignore b/ATxTray/Resources/.gitignore deleted file mode 100644 index 06696d3d12240c7657519d4c0b6895d033dbf687..0000000000000000000000000000000000000000 --- a/ATxTray/Resources/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -BuildDate.txt -BuildConfiguration.txt -BuildCommit.txt \ No newline at end of file diff --git a/AutoTx.sln b/AutoTx.sln index 27d54e86e2fcc0dd5eae5dcbfeab24a56c02096c..920d1a1d393e6bb2507498f19a8469711a7b4e01 100644 --- a/AutoTx.sln +++ b/AutoTx.sln @@ -1,7 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.27130.2027 +VisualStudioVersion = 15.0.27130.2036 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ATxService", "ATxService\ATxService.csproj", "{5CB67E3A-E63A-4791-B90B-8CEF0027AEAD}" EndProject @@ -16,6 +16,9 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3E945C19-14E3-4FE8-9008-480D4EA57F45}" ProjectSection(SolutionItems) = preProject Resources\auto-tx-logo.png = Resources\auto-tx-logo.png + Resources\BuildCommit.txt = Resources\BuildCommit.txt + Resources\BuildConfiguration.txt = Resources\BuildConfiguration.txt + Resources\BuildDate.txt = Resources\BuildDate.txt Resources\Mail-Templates\DiskSpace-Low.txt = Resources\Mail-Templates\DiskSpace-Low.txt Resources\Mail-Templates\Transfer-Interrupted.txt = Resources\Mail-Templates\Transfer-Interrupted.txt Resources\Mail-Templates\Transfer-Success.txt = Resources\Mail-Templates\Transfer-Success.txt diff --git a/ATxService/Resources/.gitignore b/Resources/.gitignore similarity index 100% rename from ATxService/Resources/.gitignore rename to Resources/.gitignore diff --git a/Scripts/Make-Package.ps1 b/Scripts/Make-Package.ps1 index e0d96c24d85aec47c404b12c77af4e297e7c8dda..a561ab0b312233484a2e4e58cbde11e6b371b33a 100644 --- a/Scripts/Make-Package.ps1 +++ b/Scripts/Make-Package.ps1 @@ -1,5 +1,4 @@ -$ResourceDir = "..\ATxService\Resources" -$RsrcDirCommon = "..\Resources" +$ResourceDir = "..\Resources" function Highlight([string]$Message, [string]$Color = "Cyan", $Indent = $False) { @@ -63,14 +62,14 @@ Copy-Item -Exclude *.pdb -Recurse "$($BinariesDirTrayApp)\*" $tgt -EA Ignore Copy-Item -Exclude *.pdb -Recurse "$($BinariesDirCfgTest)\*" $tgt -EA Ignore # provide an up-to-date version of the example config file: $example = New-Item -ItemType Container -Path $PkgDir -Name "conf-example" -Copy-Item "$($RsrcDirCommon)\conf\config.common.xml" $example -Copy-Item "$($RsrcDirCommon)\conf\host-specific.template.xml" $example +Copy-Item "$($ResourceDir)\conf\config.common.xml" $example +Copy-Item "$($ResourceDir)\conf\host-specific.template.xml" $example Copy-Item "$($ResourceDir)\BuildDate.txt" "$($PkgDir)\AutoTx.log" Copy-Item "$($ResourceDir)\BuildConfiguration.txt" $($PkgDir) try { - $CommitRefFile = "$($PkgDir)\BuildCommitRef.txt" - git describe > $CommitRefFile + $CommitRefFile = "$($ResourceDir)\BuildCommit.txt" + Copy-Item $CommitRefFile $($PkgDir) $BuildCommit = Get-Content $CommitRefFile } catch { diff --git a/Scripts/Prepare-Build.ps1 b/Scripts/Prepare-Build.ps1 index ca337d20ebf50ad528f84e93afdba35c097b5024..7fbe681a094510ec5b68f0c9e39128e410a8deee 100644 --- a/Scripts/Prepare-Build.ps1 +++ b/Scripts/Prepare-Build.ps1 @@ -1,36 +1,118 @@ [CmdletBinding()] Param( - [Parameter(Mandatory=$True)][string] $ProjectDir + [Parameter(Mandatory=$True)][string] $SolutionDir, + [Parameter(Mandatory=$True)][string] $ConfigurationName ) -$oldpwd = pwd -cd $ProjectDir -ErrorAction Stop +$CsTemplate = @" +public static class BuildDetails +{{ + public const string GitCommitName = "{0}"; + public const string GitBranch = "{1}"; + public const string GitMajor = "{2}"; + public const string GitMinor = "{3}"; + public const string GitPatch = "{4}"; + public const string BuildDate = "{5}"; + public const string GitCommit = "{6}"; +}} +"@ + +function Write-BuildDetails { + Param ( + [Parameter(Mandatory=$True)] + [String]$Target, + + [Parameter(Mandatory=$True)] + [Array]$Desc, + + [Parameter(Mandatory=$True)] + [String]$Branch, + + [Parameter(Mandatory=$True)] + [String]$Date + ) + + $CommitName = "$($Desc[0]).$($Desc[1])-$($Desc[2])-$($Desc[3])" + $Commit = $Desc[3].Substring(1) + Write-Output "$($Target.Substring($Target.LastIndexOf('\')+1)) -> $($Target)" + $Code = $CsTemplate -f ` + $CommitName, ` + $Branch, ` + $Desc[0], ` + $Desc[1], ` + $Desc[2], ` + $Date, ` + $Commit + Write-Verbose "/// generated code ///`n$($Code)`n/// generated code ///`n" + Out-File -FilePath $Target -Encoding ASCII -InputObject $Code +} + +function Parse-GitDescribe([string]$CommitName) { + Write-Verbose "Parsing 'git describe' result [$($CommitName)]..." + try { + $Items = $CommitName.Split('-').Split('.') + if ($Items.Length -ne 4) { throw } + } + catch { + throw "Can't parse commit name [$($CommitName)]!" + } + Write-Verbose "Just some $($Items[2]) commits after the last tag." + Return $Items +} + + +$ErrorActionPreference = "Stop" + +$OldLocation = Get-Location +Set-Location $SolutionDir -ErrorAction Stop try { - $CommitName = git describe --tags - $GitStatus = git status --porcelain + $CommitName = & git describe --tags --long --match "[0-9].[0-9]" + if (-Not $?) { throw } + $GitStatus = & git status --porcelain + if (-Not $?) { throw } + $GitBranch = & git symbolic-ref --short HEAD + if (-Not $?) { throw } + + $DescItems = Parse-GitDescribe $CommitName + + if ($GitStatus.Length -gt 0) { + $StatusWarning = " <-- WARNING, repository has uncommitted changes!" + $CommitName += "-unclean" + } } catch { $CommitName = "commit unknown" - $GitStatus = "status unknown" + $GitBranch = "branch unknown" + Write-Output "$(">"*8) Running git failed, using default values! $("<"*8)" } -if ($GitStatus.Length -gt 0) { - Write-Output "NOTE: repository has uncommitted changes!" - $CommitName = "$($CommitName)-unclean" -} - $Date = Get-Date -Format 'yyyy-MM-dd HH:mm:ss' +# the dotted short format can be used in the AssemblyInformationalVersion +# property, as this will magically be parsed and reported as "Version" when +# examining the executable using "Get-Command AutoTx.exe | Format-List *" +$DateShort = Get-Date -Format 'yyyy.MM.dd.HHmm' -$BCommit = "$($ProjectDir)\Resources\BuildCommit.txt" -$BuildDate = "$($ProjectDir)\Resources\BuildDate.txt" -Write-Output $CommitName > $BCommit -Write-Output $Date > $BuildDate +$BCommit = "$($SolutionDir)\Resources\BuildCommit.txt" +$BuildDate = "$($SolutionDir)\Resources\BuildDate.txt" +$BuildConfig = "$($SolutionDir)\Resources\BuildConfiguration.txt" +$BuildDetailsCS = "$($SolutionDir)\ATxCommon\BuildDetails.cs" + + +$Date | Out-File $BuildDate +$CommitName | Out-File $BCommit +$ConfigurationName | Out-File $BuildConfig + +Write-Output $( + "build-config: [$($ConfigurationName)]" + "build-date: [$($Date)]" + "git-branch: [$($GitBranch)]" + "git-describe: [$($CommitName)]$($StatusWarning)" +) -Write-Output $Date -Write-Output $CommitName +Write-BuildDetails $BuildDetailsCS $DescItems $GitBranch $DateShort -cd $oldpwd \ No newline at end of file +Set-Location $OldLocation \ No newline at end of file