Skip to content

Commit

Permalink
Adding tool to configure installation program during release build.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinknafve committed Apr 13, 2014
1 parent f894042 commit 3f3e58c
Show file tree
Hide file tree
Showing 10 changed files with 479 additions and 3 deletions.
12 changes: 9 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@
*.lai
*.la
*.a
hmailserver/source/Server/hMailServer/Debug/
hmailserver/source/Server/hMailServer/hMailServer.h
hmailserver/source/Server/hMailServer/Debug (x64)/*

*.user
*.log
*.suo

bin/
obj/
_ReSharper.*/

hmailserver/source/Server/hMailServer/Debug/
hmailserver/source/Server/hMailServer/hMailServer.h
hmailserver/source/Server/hMailServer/Debug (x64)/*
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D1C089F5-C3DB-4B4E-A5F8-705AB5BEB8DF}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ConfigureInstallation</RootNamespace>
<AssemblyName>ConfigureInstallation</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<StartupObject>
</StartupObject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Ini.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
21 changes: 21 additions & 0 deletions hmailserver/tools/ConfigureInstallation/Ini.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace ConfigureInstallation
{
class Ini
{
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section,
string key, string val, string filePath);

public static void Write(string file, string section, string key, string value)
{
WritePrivateProfileString(section, key, value, file);
}

}
}
67 changes: 67 additions & 0 deletions hmailserver/tools/ConfigureInstallation/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows.Forms;

namespace ConfigureInstallation
{
static class Program
{

static int Main(string []args)
{
if (args.Count() != 3)
{
Console.WriteLine("Expected two parameters: RootDir, Version, Build");
return -1;
}

var rootDir = args[0];
var version = args[1];
var build = args[2];

if (!Directory.Exists(rootDir))
{
Console.WriteLine("Root directory {0} was not found.", rootDir);
return -1;
}

// Write C++ version header file.
string cppVersionFile = Path.Combine(rootDir, @"hmailserver\source\Server\Common\Application\Version.h");
if (!File.Exists(cppVersionFile))
{
Console.WriteLine("Version file {0} was not found.", cppVersionFile);
return -1;
}
Console.WriteLine("Writing c++ version info to {0}", cppVersionFile);
var versionContent = string.Format("#pragma once\r\n\r\n#define HMAILSERVER_VERSION \"{0}\"\r\n#define HMAILSERVER_BUILD {1}\r\n\r\n", version, build);
File.WriteAllText(cppVersionFile, versionContent);

// Write C++ version header file.
string phpVersionFile = Path.Combine(rootDir, @"hmailserver\source\WebAdmin\include_versioncheck.php");

Console.WriteLine("Writing php version info to {0}", phpVersionFile);
var phpVersionContent = string.Format("<?php\r\ndefine('REQUIRED_VERSION', '{0}-B{1}');\r\n?>", version, build);
File.WriteAllText(phpVersionFile, phpVersionContent);

// Write installation program verison
string installationFile = Path.Combine(rootDir, @"hmailserver\Installation\hMailServer.iss");
if (!File.Exists(installationFile))
{
Console.WriteLine("Installation file {0} was not found.", installationFile);
return -1;
}
Console.WriteLine("Writing install version and output name to {0}", installationFile);

Ini.Write(installationFile, "Setup", "AppVerName", string.Format("hMailServer {0}-B{1}", version, build));

// Write installation output verison
Ini.Write(installationFile, "Setup", "OutputBaseFilename", string.Format("hMailServer-{0}-B{1}", version, build));

Console.WriteLine("All done. Exiting");

return 0;
}
}
}
36 changes: 36 additions & 0 deletions hmailserver/tools/ConfigureInstallation/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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("ConfigureInstallation")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConfigureInstallation")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a19e9619-d730-44a3-baa3-e9dfbef38bc5")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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")]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3f3e58c

Please sign in to comment.