First test with the Wix Installer, writes a shortcut to the Start Menu and drops the exe into the Program Files (x86) folder.

This commit is contained in:
2017-04-11 15:55:37 -05:00
parent 62a2c0f80e
commit 0b7b14df5f
21 changed files with 24835 additions and 204 deletions
+20 -2
View File
@@ -1,26 +1,44 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.26403.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvertsingProfitControl", "AdvertsingProfitControl\AdvertsingProfitControl.csproj", "{4A45C665-5D02-4724-9CC5-C0C50CA44760}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StringInputParseTester", "StringInputParseTester\StringInputParseTester.csproj", "{2663661B-3D90-4D42-B05E-8038923A2891}"
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "SetupProject", "SetupProject\SetupProject.wixproj", "{EB640D80-1A1E-4835-90B3-83A688419321}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4A45C665-5D02-4724-9CC5-C0C50CA44760}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A45C665-5D02-4724-9CC5-C0C50CA44760}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A45C665-5D02-4724-9CC5-C0C50CA44760}.Debug|x86.ActiveCfg = Debug|Any CPU
{4A45C665-5D02-4724-9CC5-C0C50CA44760}.Debug|x86.Build.0 = Debug|Any CPU
{4A45C665-5D02-4724-9CC5-C0C50CA44760}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A45C665-5D02-4724-9CC5-C0C50CA44760}.Release|Any CPU.Build.0 = Release|Any CPU
{4A45C665-5D02-4724-9CC5-C0C50CA44760}.Release|x86.ActiveCfg = Release|Any CPU
{4A45C665-5D02-4724-9CC5-C0C50CA44760}.Release|x86.Build.0 = Release|Any CPU
{2663661B-3D90-4D42-B05E-8038923A2891}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2663661B-3D90-4D42-B05E-8038923A2891}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2663661B-3D90-4D42-B05E-8038923A2891}.Debug|x86.ActiveCfg = Debug|Any CPU
{2663661B-3D90-4D42-B05E-8038923A2891}.Debug|x86.Build.0 = Debug|Any CPU
{2663661B-3D90-4D42-B05E-8038923A2891}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2663661B-3D90-4D42-B05E-8038923A2891}.Release|Any CPU.Build.0 = Release|Any CPU
{2663661B-3D90-4D42-B05E-8038923A2891}.Release|x86.ActiveCfg = Release|Any CPU
{2663661B-3D90-4D42-B05E-8038923A2891}.Release|x86.Build.0 = Release|Any CPU
{EB640D80-1A1E-4835-90B3-83A688419321}.Debug|Any CPU.ActiveCfg = Debug|x86
{EB640D80-1A1E-4835-90B3-83A688419321}.Debug|x86.ActiveCfg = Debug|x86
{EB640D80-1A1E-4835-90B3-83A688419321}.Debug|x86.Build.0 = Debug|x86
{EB640D80-1A1E-4835-90B3-83A688419321}.Release|Any CPU.ActiveCfg = Release|x86
{EB640D80-1A1E-4835-90B3-83A688419321}.Release|x86.ActiveCfg = Release|x86
{EB640D80-1A1E-4835-90B3-83A688419321}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -161,7 +161,6 @@
<Compile Include="Taxable.cs" />
<Compile Include="TextFormat.cs" />
<Compile Include="BackPageGenerator.cs" />
<Compile Include="DatabaseVersionControl.cs" />
<Compile Include="FrmAddRecord.cs">
<SubType>Form</SubType>
</Compile>
@@ -1,197 +0,0 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.OleDb;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AdvertsingProfitControl
{
internal class DatabaseVersionControl
{
FrmLogConsole _console = FrmLogConsole.GetStaticInstance;
public string GetDatabaseVerionNumber(string connectionString)
{
var versionNumber = "0.0.0.0";
var oleDbCommand = new OleDbCommand
{
CommandText = "SELECT VersionNumber FROM Version"
};
var connection = new OleDbConnection(connectionString);
oleDbCommand.Connection = connection;
try
{
connection.Open();
var reader = oleDbCommand.ExecuteReader();
while(reader != null && reader.Read())
{
versionNumber = reader[0].ToString();
}
}
catch (OleDbException e)
{
//Due to primitive nature of the original database (v0.3.0.0), which did not contain a Version table, an error
//will be kicked out trying to extract the version number from the database. So, just assume this isn't an
//OleDb error of some type.
_console.WriteToLog(FrmLogConsole.Level.Warning, "Testing for the database's version yielded an error.\nVersion number will be assumed to be 0.3.0.0.");
_console.WriteToLog(FrmLogConsole.Level.Debug, e.Message);
versionNumber = "0.3.0.0";
}
finally
{
connection.Close();
}
return versionNumber;
}
public bool UpdateVersionPointFive(string connectionString, out string versionNumber)
{
var updated = false;
//Create a backup of the database
File.Copy(Application.StartupPath + "\\APCDatabase.accdb", Application.StartupPath + "\\APCDatabase.bak", true);
var connection = new OleDbConnection(connectionString);
var oleDbCommand = new OleDbCommand
{
CommandText = "SELECT FK_AdItemID, FK_DateID, FK_GroupID FROM APC",
Connection = connection
};
using (connection)
{
connection.Open();
var apcReturnTable = new List<string>();
using(var reader = oleDbCommand.ExecuteReader())
{
//Each record's structure is as follows (index based):
// 0 - FK_AdItemID, 1 - FK_DateID and 2 - FK_GroupID
var groupID = 0;
var rowAttribute = 0;
var adItemID = "";
var dateID = "";
while(reader != null && reader.Read())
{
apcReturnTable.Add(reader[0] + "," + reader[1] + "," + reader[2]);
}
reader?.Close();
//Update the FK_GroupID's data type.
//oleDbCommand.CommandText = "ALTER TABLE APC ALTER COLUMN FK_GroupID NUMBER";
//oleDbCommand.ExecuteNonQuery();
//Insert the new columns into the APC table.
oleDbCommand.CommandText = "ALTER TABLE APC ADD COLUMN RowPosition NUMBER, RowAttribute NUMBER";
oleDbCommand.ExecuteNonQuery();
//Change the object to update mode
oleDbCommand.CommandText =
"UPDATE APC SET RowAttribute = ?, RowPosition = ?, FK_GroupID = ? WHERE FK_AdItemID = ? AND FK_DateID = ?";
var rowPosition = 1;
foreach (var splitRow in apcReturnTable.Select(row => row.Split(',')))
{
if (splitRow[1] != dateID)
{
rowPosition = 1;
}
groupID = 0;
rowAttribute = 0;
if (splitRow.Length == 3)
{
adItemID = splitRow[0];
dateID = splitRow[1];
var splitGroupIDs = splitRow[2].Split('|');
if (splitGroupIDs.Length == 2)
{
if (splitGroupIDs[1] != "")
{
groupID = int.Parse(splitGroupIDs[1]);
}
if (splitGroupIDs[0] != "")
{
rowAttribute = int.Parse(splitGroupIDs[0]);
}
}
else if (splitGroupIDs.Length == 1)
{
//Try parsing the value to an int and check how big it is.
//Less then three (3) means either a header or member row identifier, whereas a three (3) or greater means an ad special row.
var parsedVal = 0;
if (int.TryParse(splitGroupIDs[0], out parsedVal))
{
if (parsedVal > 2)
{
groupID = parsedVal;
}
else if (parsedVal < 3)
{
rowAttribute = parsedVal;
}
}
}
}
else
{
adItemID = splitRow[0];
dateID = splitRow[1];
}
//Update the new row with the information.
oleDbCommand.Parameters.Clear();
if (rowAttribute == 0)
{
oleDbCommand.Parameters.AddWithValue("RowAttribute", OleDbType.Empty);
}
else
{
oleDbCommand.Parameters.AddWithValue("RowAttribute", rowAttribute);
}
oleDbCommand.Parameters.AddWithValue("RowPosition", rowPosition);
if (groupID == 0)
{
oleDbCommand.Parameters.AddWithValue("RowAttribute", OleDbType.Empty);
}
else
{
oleDbCommand.Parameters.AddWithValue("GroupID", groupID);
}
oleDbCommand.Parameters.AddWithValue("AdItemID", adItemID);
oleDbCommand.Parameters.AddWithValue("DateID", dateID);
if (oleDbCommand.ExecuteNonQuery() != 1)
{
MessageBox.Show("An error has occurred trying to upgrade the database", "Fatal Error");
break;
}
rowPosition++;
}
//Update the FK_GroupID's data type.
oleDbCommand.Parameters.Clear();
oleDbCommand.CommandText = "ALTER TABLE APC ALTER COLUMN FK_GroupID NUMBER";
oleDbCommand.ExecuteNonQuery();
oleDbCommand.CommandText = "ALTER TABLE APC ALTER COLUMN ProjectionSold TEXT";
oleDbCommand.ExecuteNonQuery();
//Apply an update patch for version 0.3.0.0 database by adding a version table and inserting the version number into the database.
oleDbCommand.CommandText = "CREATE TABLE Version (ID AUTOINCREMENT PRIMARY KEY, VersionNumber TEXT)";
oleDbCommand.ExecuteNonQuery();
//Insert the version number into the new table
oleDbCommand.CommandText = "INSERT INTO Version (VersionNumber) VALUES ('0.5.0.0')";
oleDbCommand.ExecuteNonQuery();
versionNumber = "0.5.0.0";
updated = true;
}
}
return updated;
}
}
}
-4
View File
@@ -96,10 +96,6 @@ namespace AdvertsingProfitControl
try
{
message = $"{level}: {message}";
if (level != Level.Info)
{
GlobalClasses.WriteToLog(DateTime.Now + ": " + message + Environment.NewLine);
}
logListView.Items.Add(message);
logListView.Items[index].ForeColor = color;
}
+2
View File
@@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmManageAdItems));
this.adItemsListView = new System.Windows.Forms.ListView();
this.addUpdateItemButton = new System.Windows.Forms.Button();
this.removeAdItemButton = new System.Windows.Forms.Button();
@@ -149,6 +150,7 @@
this.Controls.Add(this.addUpdateItemButton);
this.Controls.Add(this.adItemsListView);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "FrmManageAdItems";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Manage Ad Items";
File diff suppressed because it is too large Load Diff
+2
View File
@@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmManageSuppliers));
this.suppliersListBox = new System.Windows.Forms.ListView();
this.descriptionTextBox = new System.Windows.Forms.TextBox();
this.descriptionLabel = new System.Windows.Forms.Label();
@@ -127,6 +128,7 @@
this.Controls.Add(this.deleteSupplierButton);
this.Controls.Add(this.registerSupplierButton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FrmManageSuppliers";
File diff suppressed because it is too large Load Diff
@@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmRegisterAdSpecial));
this.registerAdSpecialButton = new System.Windows.Forms.Button();
this.deleteAdSpecialButton = new System.Windows.Forms.Button();
this.newAdSpecialLabel = new System.Windows.Forms.Label();
@@ -127,6 +128,7 @@
this.Controls.Add(this.deleteAdSpecialButton);
this.Controls.Add(this.registerAdSpecialButton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FrmRegisterAdSpecial";
File diff suppressed because it is too large Load Diff
+2
View File
@@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NewModifyRecord));
this.mainLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
this.mainMenuStrip = new System.Windows.Forms.MenuStrip();
this.FileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
@@ -952,6 +953,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1821, 980);
this.Controls.Add(this.mainLayoutPanel);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MinimumSize = new System.Drawing.Size(1000, 1000);
this.Name = "NewModifyRecord";
this.Text = "Modify Record";
File diff suppressed because it is too large Load Diff
+55
View File
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="SetupProject" Language="1033" Version="1.0.0.0" Manufacturer="Garritt McCune" UpgradeCode="a416a558-d7c0-4f24-8b1e-2d01761ad15f">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<!--Not set by default, EmbedCab="yes" embeds the cabinet file into the installer-->
<MediaTemplate EmbedCab="yes"/>
<Feature Id="ProductFeature" Title="AdvertisingProfitControl" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<ComponentRef Id="ApplicationShortcut" />
</Feature>
</Product>
<Fragment>
<!--Install Directory-->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Advertising Profit Control" />
</Directory>
<!--Define shortcut-->
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="Advertising Profit Control"/>
</Directory>
<!--App data folder-->
<Directory Id="LocalAppDataFolder">
<Directory Id="AppDataFolder" Name="APC" />
</Directory>
</Directory>
</Fragment>
<!--Define the shortcut-->
<Fragment>
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcut" Guid="*">
<Shortcut Id="ApplicationStartMenuShortcut"
Name="Advertising Profit Control"
Description="Profit Control Recording Software"
Target="[#AdvertsingProfitControl.exe]"
WorkingDirectory="APPLICATIONROOTDIRECTORY"/>
<RemoveFolder Id="CleanUpShortCut" Directory="ApplicationProgramsFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\Microsoft\AdvertsingProfitControl" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<Component Id="AdvertisingProfitControl.exe">
<File Source="$(var.AdvertsingProfitControl.TargetPath)" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
+47
View File
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="EnsureWixToolsetInstalled" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>3.10</ProductVersion>
<ProjectGuid>eb640d80-1a1e-4835-90b3-83a688419321</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>SetupProject</OutputName>
<OutputType>Package</OutputType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="Product.wxs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AdvertsingProfitControl\AdvertsingProfitControl.csproj">
<Name>AdvertsingProfitControl</Name>
<Project>{4a45c665-5d02-4724-9cc5-c0c50ca44760}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
</ItemGroup>
<Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets') " />
<Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' ">
<Error Text="The WiX Toolset v3 build tools must be installed to build this project. To download the WiX Toolset, see http://wixtoolset.org/releases/" />
</Target>
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Wix.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,2 @@
C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\SetupProject\bin\Debug\SetupProject.msi
C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\SetupProject\bin\Debug\SetupProject.wixpdb
@@ -0,0 +1 @@
C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\AdvertsingProfitControl.exe
@@ -0,0 +1,2 @@
C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\SetupProject\bin\Debug\SetupProject.msi
C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\SetupProject\bin\Debug\SetupProject.wixpdb
@@ -0,0 +1,6 @@
C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\SetupProject\bin\Debug\SetupProject.msi
C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\SetupProject\bin\Debug\SetupProject.wixpdb
obj\Debug\Product.wixobj
obj\Debug\SetupProject.wixproj.BindContentsFileListnull.txt
obj\Debug\SetupProject.wixproj.BindOutputsFileListnull.txt
obj\Debug\SetupProject.wixproj.BindBuiltOutputsFileListnull.txt