Builder finally implemented (run 'Build.exe IISMainHandler' to get .msi package in IISMainHandler folder

main
Inga 🏳‍🌈 15 years ago
parent 11e2cda727
commit 473c0ebfbf
  1. 3
      Builder/Builder.csproj
  2. 1
      Builder/IISMainHandler/build.txt
  3. 5
      Builder/IISMainHandler/postbuild.bat
  4. 3
      Builder/IISMainHandler/prebuild.bat
  5. 103
      Builder/IISMainHandler/product.wxs
  6. 90
      Builder/Program.cs
  7. 29
      Builder/TempFile.cs

@ -12,6 +12,7 @@
<AssemblyName>Builder</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
@ -24,7 +25,6 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
@ -63,6 +63,7 @@
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TempFile.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">

@ -0,0 +1,5 @@
@echo off
del Templates.7z
del Templates.bat
ping localhost -n 2 >nul
del 7z.exe

@ -0,0 +1,3 @@
@echo off
"C:\Program Files\7-Zip\7z.exe" a Templates.7z ..\..\templates\* -xr!.svn
copy "C:\Program Files\7-Zip\7z.exe" 7z.exe

@ -0,0 +1,103 @@
<?xml version='1.0'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<Product Id='*' Name='FLocal IISMainHandler' Language='1033'
Version='1.{rev}.{build}.0' Manufacturer='inga-lovinde' UpgradeCode='3981e346-b07f-45aa-bb8e-263a01dee3f1' >
<Package Description='FLocal IISMainHandler' Comments='FLocal IISMainHandler' Manufacturer='inga-lovinde' InstallerVersion='300' Compressed='yes' Platform="x64" />
<Upgrade Id="3981e346-b07f-45aa-bb8e-263a01dee3f1">
<UpgradeVersion Minimum="1.0.0" IncludeMinimum="yes" Maximum="1.{rev}.{build}" IncludeMaximum="no" Property="OLDERVERSIONBEINGUPGRADED" />
</Upgrade>
<Upgrade Id="3981e346-b07f-45aa-bb8e-263a01dee3f1">
<UpgradeVersion Minimum="1.{rev}.{build}" IncludeMinimum="no" Property="NEWERVERSIONDETECTED" />
</Upgrade>
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallInitialize"/>
</InstallExecuteSequence>
<Media Id='1' Cabinet='product.cab' EmbedCab='yes' />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="APPLICATIONROOTDIRECTORY" Name="FLocal"/>
</Directory>
<Directory Id="INETPUBROOTDIRECTORY" Name="inetpub">
<Directory Id="INETPUBMAINDIRECTORY" Name="flocal-main">
<Directory Id="BINARIESROOTDIRECTORY" Name="Bin"/>
<Directory Id="DATAROOTDIRECTORY" Name="data"/>
</Directory>
</Directory>
</Directory>
<DirectoryRef Id="BINARIESROOTDIRECTORY">
<Component Id="Core.dll" Guid="B8542489-E367-4AC6-9FCF-EA3454F0D642">
<File Id="Core.dll" Source="..\..\Core\bin\Release\Core.dll" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="Core.pdb" Guid="3109981C-0182-48CA-B1CA-8F68F1C0F4B9">
<File Id="Core.pdb" Source="..\..\Core\bin\Release\Core.pdb" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="Common.dll" Guid="4CD35090-702C-479D-826B-2DE966FB0D45">
<File Id="Common.dll" Source="..\..\Common\bin\Release\Common.dll" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="Common.pdb" Guid="78F773B8-0B28-4657-8E13-739FDB16F3C5">
<File Id="Common.pdb" Source="..\..\Common\bin\Release\Common.pdb" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="MySQLConnector.dll" Guid="924EC439-F1F0-431F-A6EA-152C321F614C">
<File Id="MySQLConnector.dll" Source="..\..\MySQLConnector\bin\Release\MySQLConnector.dll" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="MySQLConnector.pdb" Guid="32AA82C5-1561-4612-A113-C7A099C3ECEF">
<File Id="MySQLConnector.pdb" Source="..\..\IISMainHandler\bin\Release\MySQLConnector.pdb" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="IISMainHandler.dll" Guid="E3BCF3A1-75C0-4CD7-95D4-4A0245B1CA18">
<File Id="IISMainHandler.dll" Source="..\..\IISMainHandler\bin\Release\IISMainHandler.dll" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="IISMainHandler.pdb" Guid="4F5F1280-8EC8-4C56-80F4-8C810F0C839F">
<File Id="IISMainHandler.pdb" Source="..\..\IISMainHandler\bin\Release\IISMainHandler.pdb" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="MySql.Data.dll" Guid="90646729-6B21-4BEE-94C3-F39F5288EFB3">
<File Id="MySql.Data.dll" Source="..\..\ThirdParty\mysql-connector-net-6.2.3\MySql.Data\Provider\bin\Release\MySql.Data.dll" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="MySql.Data.pdb" Guid="7105BA2A-A10A-4E41-AA4F-30FA66499BE6">
<File Id="MySql.Data.pdb" Source="..\..\ThirdParty\mysql-connector-net-6.2.3\MySql.Data\Provider\bin\Release\MySql.Data.pdb" KeyPath="yes" Checksum="yes"/>
</Component>
</DirectoryRef>
<DirectoryRef Id="APPLICATIONROOTDIRECTORY">
<Component Id="Templates.7z" Guid="B41F4142-A39C-43BE-8D20-F31BFFA9B483">
<File Id="Templates.7z" Source="Templates.7z" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="_7z.exe" Guid="57AD7901-2C9B-4349-ABD8-C8FBA82F2724">
<File Id="_7z.exe" Name="7z.exe" Source="7z.exe" KeyPath="yes" Checksum="yes"/>
</Component>
</DirectoryRef>
<Feature Id='IISMainHandler' Title='IISMainHandler' Level='1'>
<ComponentRef Id='IISMainHandler.dll' />
<ComponentRef Id='IISMainHandler.pdb' />
</Feature>
<Feature Id='Core' Title='Core library' Level='1'>
<ComponentRef Id='Core.dll' />
<ComponentRef Id='Core.pdb' />
</Feature>
<Feature Id='Common' Title='Common FLocal libraries' Level='1'>
<ComponentRef Id='Common.dll' />
<ComponentRef Id='Common.pdb' />
</Feature>
<Feature Id='MySQLConnector' Title='Adapter to MySql Connector/NET' Level='1'>
<ComponentRef Id='MySQLConnector.dll' />
<ComponentRef Id='MySQLConnector.pdb' />
</Feature>
<Feature Id='ThirdParty' Title='ThirdParty libraries/tools' Level='1'>
<Feature Id='MySql.Data' Title='MySql Connector/NET' Level='1'>
<ComponentRef Id='MySql.Data.dll' />
<ComponentRef Id='MySql.Data.pdb' />
</Feature>
</Feature>
<Feature Id="Data" Title="Various data sets" Level="1">
<ComponentRef Id="_7z.exe"/>
<Feature Id="Templates" Title="Templates" Level="1">
<ComponentRef Id="Templates.7z"/>
</Feature>
</Feature>
<CustomAction Id="InstallTemplates" FileKey="_7z.exe" ExeCommand="x &quot;C:\Program Files\FLocal\Templates.7z&quot; -oC:\inetpub\flocal-main\data\templates\ -aoa -y" Execute="deferred" Impersonate="no" Return="check"/>
<InstallExecuteSequence>
<Custom Action="InstallTemplates" Before="InstallFinalize">
<![CDATA[NOT REMOVE]]>
</Custom>
</InstallExecuteSequence>
</Product>
</Wix>

@ -4,12 +4,24 @@ using System.Linq;
using System.Text;
using System.IO;
//using Microsoft.Tools.WindowsInstallerXml;
//using System.Xml;
using System.Xml;
using System.Diagnostics;
using System.Configuration;
namespace Builder {
class Program {
private static string runBatFile(string filename) {
ProcessStartInfo info = new ProcessStartInfo(filename);
info.WorkingDirectory = (new FileInfo(filename)).Directory.FullName;
info.UseShellExecute = false;
info.RedirectStandardOutput = true;
using(Process process = Process.Start(info)) {
process.WaitForExit();
return process.StandardOutput.ReadToEnd();
}
}
static void Main(string[] args) {
try {
@ -27,23 +39,77 @@ namespace Builder {
string sourceFile = fullPath + "product.wxs";
if(!File.Exists(sourceFile)) throw new ApplicationException("No wxs file could be found");
string targetFile = fullPath + "product.wixobj";
string wixPdbFile = fullPath + "product.wixpdb";
string outputFile = fullPath + "product.msi";
string prebuildCommands = fullPath + "prebuild.bat";
string postbuildCommands = fullPath + "postbuild.bat";
string buildNumberFile = fullPath + "build.txt";
if(File.Exists(prebuildCommands)) Console.WriteLine(runBatFile(prebuildCommands));
if(!File.Exists(buildNumberFile)) {
using(FileStream stream = File.Create(buildNumberFile)) {
using(StreamWriter writer = new StreamWriter(stream)) {
writer.Write("0");
}
}
}
int buildNumber;
using(StreamReader reader = new StreamReader(buildNumberFile)) {
buildNumber = int.Parse(reader.ReadToEnd());
}
buildNumber++; //NO CONCURRENCY HERE
using(StreamWriter writer = new StreamWriter(buildNumberFile)) {
writer.Write(buildNumber);
}
ProcessStartInfo candleInfo = new ProcessStartInfo(WIXPATH + "candle.exe", "-nologo -out \"" + targetFile + "\" \"" + sourceFile + "\"");
candleInfo.UseShellExecute = false;
candleInfo.RedirectStandardOutput = true;
Process candle = Process.Start(candleInfo);
//candle.Start();
candle.WaitForExit();
Console.Write(candle.StandardOutput.ReadToEnd());
int revNumber;
ProcessStartInfo svnInfo = new ProcessStartInfo(SVNPATH + "svn", "info --xml");
svnInfo.WorkingDirectory = (new DirectoryInfo(".")).Parent.FullName;
svnInfo.UseShellExecute = false;
svnInfo.RedirectStandardOutput = true;
using(Process svn = Process.Start(svnInfo)) {
svn.WaitForExit();
XmlDocument document = new XmlDocument();
document.Load(svn.StandardOutput);
revNumber = int.Parse(document.GetElementsByTagName("entry")[0].Attributes["revision"].Value);
}
using(TempFile tempFile = new TempFile()) {
string wxsData;
using(StreamReader sourceReader = new StreamReader(sourceFile)) {
wxsData = sourceReader.ReadToEnd();
}
wxsData = wxsData.Replace("{rev}", revNumber.ToString()).Replace("{build}", buildNumber.ToString());
using(StreamWriter tempWriter = tempFile.getWriter()) {
tempWriter.Write(wxsData);
}
ProcessStartInfo candleInfo = new ProcessStartInfo(WIXPATH + "candle.exe", "-nologo -arch x64 -out \"" + targetFile + "\" \"" + tempFile.fileName + "\"");
candleInfo.UseShellExecute = false;
candleInfo.RedirectStandardOutput = true;
using(Process candle = Process.Start(candleInfo)) {
//candle.Start();
candle.WaitForExit();
Console.Write(candle.StandardOutput.ReadToEnd());
}
}
ProcessStartInfo lightInfo = new ProcessStartInfo(WIXPATH + "light.exe", "-nologo -out \"" + outputFile + "\" \"" + targetFile + "\"");
lightInfo.UseShellExecute = false;
lightInfo.RedirectStandardOutput = true;
Process light = Process.Start(lightInfo);
//light.Start();
light.WaitForExit();
Console.Write(light.StandardOutput.ReadToEnd());
using(Process light = Process.Start(lightInfo)) {
//light.Start();
light.WaitForExit();
Console.Write(light.StandardOutput.ReadToEnd());
}
File.Delete(targetFile);
if(File.Exists(wixPdbFile)) File.Delete(wixPdbFile);
if(File.Exists(postbuildCommands)) Console.WriteLine(runBatFile(postbuildCommands));
/* Preprocessor preprocessor = new Preprocessor();
preprocessor.CurrentPlatform = Platform.X86;

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Builder {
class TempFile : IDisposable {
public readonly string fileName;
public TempFile() {
this.fileName = Path.GetTempFileName();
}
public StreamReader getReader() {
return new StreamReader(this.fileName);
}
public StreamWriter getWriter() {
return new StreamWriter(this.fileName);
}
public void Dispose() {
File.Delete(this.fileName);
}
}
}
Loading…
Cancel
Save