Added:
trunk/Installer/CustomAction.config
trunk/Installer/InstallUtilLib.dll
trunk/mysqlclient/Installer.cs
Removed:
trunk/Installer/MachineConfig.js
Modified:
trunk/CHANGES
trunk/Installer/Custom.wxs
trunk/Installer/main.wxs
trunk/Installer/sources.wxs
trunk/mysqlclient/MySql.Data.2005.csproj
Log:
Bug #23245 Connector Net 5.01 Beta Installer produces Antivirus Error Message
Fixed this bug by replacing JScript based custom action with an Installer derived class
inside MySQLClient. We had to add a helper library (InstallUtilLib.dll) and
CustomAction.config as well as make significant changes to main.wxs.
Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES 2006-10-25 21:09:00 UTC (rev 436)
+++ trunk/CHANGES 2006-10-27 20:31:18 UTC (rev 437)
@@ -4,6 +4,7 @@
----------
Bug #23268 System.FormatException when invoking procedure with ENUM input parameter
Bug #23538 Exception thrown when GetSchemaTable is called and "fields" is null.
+ Bug #23245 Connector Net 5.01 Beta Installer produces Antivirus Error Message
Other changes
-------------
Modified: trunk/Installer/Custom.wxs
===================================================================
--- trunk/Installer/Custom.wxs 2006-10-25 21:09:00 UTC (rev 436)
+++ trunk/Installer/Custom.wxs 2006-10-27 20:31:18 UTC (rev 437)
@@ -47,14 +47,14 @@
<InstallUISequence>
<Custom Action="RGSM1" Sequence="1"/>
- <Custom Action="RGSM2" Sequence="1"/>
- <Custom Action="RGSM3" Sequence="1"/>
- <Custom Action="RGSM4" Sequence="1"/>
- <Custom Action="RGSM5" Sequence="1"/>
- <Custom Action="RGSM6" Sequence="1"/>
- <Custom Action="RGSM7" Sequence="1"/>
- <Custom Action="RGSM8" Sequence="1"/>
- <Custom Action="RGSM9" Sequence="1"/>
+ <Custom Action="RGSM2" After="RGSM1"/>
+ <Custom Action="RGSM3" After="RGSM2"/>
+ <Custom Action="RGSM4" After="RGSM3"/>
+ <Custom Action="RGSM5" After="RGSM4"/>
+ <Custom Action="RGSM6" After="RGSM5"/>
+ <Custom Action="RGSM7" After="RGSM6"/>
+ <Custom Action="RGSM8" After="RGSM7"/>
+ <Custom Action="RGSM9" After="RGSM8"/>
</InstallUISequence>
</Fragment>
Added: trunk/Installer/CustomAction.config
===================================================================
--- trunk/Installer/CustomAction.config 2006-10-25 21:09:00 UTC (rev 436)
+++ trunk/Installer/CustomAction.config 2006-10-27 20:31:18 UTC (rev 437)
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<configuration>
+<startup>
+<supportedRuntime version="v2.0.50727"/>
+</startup>
+</configuration>
Added: trunk/Installer/InstallUtilLib.dll
===================================================================
(Binary files differ)
Property changes on: trunk/Installer/InstallUtilLib.dll
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/Installer/MachineConfig.js
===================================================================
--- trunk/Installer/MachineConfig.js 2006-10-25 21:09:00 UTC (rev 436)
+++ trunk/Installer/MachineConfig.js 2006-10-27 20:31:18 UTC (rev 437)
@@ -1,262 +0,0 @@
-// Launched during installation
-function InstallMachineConfig()
-{
- DoAllJob("Install");
-}
-
-// Launched during deinstalation
-function UninstallMachineConfig()
-{
- DoAllJob("Uninstall");
-}
-
-// Does all job
-function DoAllJob(action)
-{
- // Init log
- var log = InitLog();
- WriteLineToLog(log, "Initializing installation.");
- WriteLineToLog(log, "Action is " + action);
-
-
- // Get framework root
- var frameworkRoot = GetFrameworkRoot(log);
- if( frameworkRoot == null )
- {
- WriteLineToLog("Failed to get framework root!");
- return;
- }
- WriteLineToLog(log, "Framework root: " + frameworkRoot);
-
- // Get 2.0 path
- var machineConfig = GetMachineConfigPath(log, frameworkRoot);
- if( machineConfig == null )
- {
- WriteLineToLog("Failed to get machine.config path!");
- return;
- }
- WriteLineToLog(log, "machine.config path: " + machineConfig);
-
- // Perform main task
- MainOperation(log, machineConfig, action);
-
- // Close log
- CloseLog(log);
-}
-
-// Returns machine.config path
-function GetMachineConfigPath(log, root)
-{
- try
- {
- // Create fso
- var fso, f, fc, s;
- fso = new ActiveXObject("Scripting.FileSystemObject");
- if(fso == null)
- {
- WriteLineToLog(log, "Failed to get FSO!");
- return null;
- }
-
- // Get root information
- f = fso.GetFolder(root);
- if(fso == null)
- {
- WriteLineToLog(log, "Failed to get information about framework root!");
- return null;
- }
-
- // Enumerate subfolders
- fc = new Enumerator(f.SubFolders);
- if(fc == null)
- {
- WriteLineToLog(log, "Failed to enumerate framework root subfolders!");
- return null;
- }
-
- // Search for v2.0.... subfolder
- for (; !fc.atEnd(); fc.moveNext())
- {
- if( fc.item().Name.indexOf("v2.0.") == 0)
- {
- // Extract config name and check for existence
- var result = root + fc.item().Name + "\\CONFIG\\machine.config";
- if( fso.FileExists(result) )
- return result;
- else
- WriteLineToLog(log, "File " + result + " doesn't exists.");
- }
- }
-
- WriteLineToLog(log, "v2.0 subfolder not founded!");
- return null;
- }
- catch(e)
- {
- WriteLineToLog(log, "Failed to get framework root because of exception!");
- return null;
- }
-}
-
-// Returns .NET frameworks root directory
-function GetFrameworkRoot(log)
-{
- try
- {
- var WshShell = new ActiveXObject("WScript.Shell");
- if( WshShell == null )
- {
- WriteLineToLog(log, "Failed to create WScript.Shell!");
- return null;
- }
- WriteLineToLog("reading framework root from registry");
- return WshShell.RegRead
("HKLM\\Software\\Microsoft\\.NETFramework\\InstallRoot");
- }
- catch(e)
- {
- WriteLineToLog(log, "Failed to get framework root because of exception!");
- return null;
- }
-}
-
-// Initializes log file on disk C
-function InitLog()
-{
- try
- {
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- return fso.CreateTextFile("c:\\MySql.Data.log", true);
- }
- catch(e)
- {
- return null;
- }
-}
-
-// Writes text to log
-function WriteToLog(log, line)
-{
- try
- {
- if( log != null )
- log.Write(line);
- }
- catch(e)
- {
- }
-}
-
-// Writes line to log
-function WriteLineToLog(log, line)
-{
- try
- {
- if( log != null )
- log.WriteLine(line);
- }
- catch(e)
- {
- }
-}
-
-// Closes log file on disk C
-function CloseLog(log)
-{
- try
- {
- if( log != null )
- log.Close();
- }
- catch(e)
- {
- return null;
- }
-}
-
-// Performs main operation - alters machine.config
-function MainOperation(log, machineConfigPath, action)
-{
- var invariantName = "MySql.Data.MySqlClient";
-
- try
- {
- // Create DOM object
- var config = new ActiveXObject("Msxml2.DOMDocument");
- if( config == null )
- {
- WriteLineToLog(log, "Failed to create XML document!");
- return;
- }
- WriteLineToLog(log, "XML document created.");
-
- // Load machine config
- config.load(machineConfigPath);
- WriteLineToLog(log, "XML document loaded.");
-
- // Locate list of factpries
- var factoriesList = config.getElementsByTagName("DbProviderFactories");
- if( factoriesList == null || factoriesList.length <= 0 &&
factoriesList[0] == null )
- {
- WriteLineToLog(log, "Factories list is empty!");
- return;
- }
- WriteLineToLog(log, "Factories read.");
-
- // Modify list if it is founded
- var existEntry = GetExistsEntry(factoriesList[0], invariantName);
- WriteLineToLog(log, "Search for existed entry completed.");
-
- // Uninstall if installed
- if( action == "Uninstall" && existEntry != null )
- {
- WriteLineToLog(log, "Removing exists entry...");
- factoriesList[0].removeChild(existEntry);
- WriteLineToLog(log, "Existing entry removed.");
- }
-
- // Install if not installed
- if( action == "Install" && existEntry == null )
- {
- WriteLineToLog(log, "Creating new entry...");
- var newEntry = config.createElement("add");
- if(newEntry == null)
- {
- WriteLineToLog(log, "Factories to create new entry!");
- return;
- }
- WriteLineToLog(log, "New entry created.");
-
- WriteLineToLog(log, "Filling attributes...");
- newEntry.setAttribute("name", "MySQL Data Provider");
- newEntry.setAttribute("invariant", invariantName);
- newEntry.setAttribute("description", ".Net Framework Data Provider for
MySQL");
- newEntry.setAttribute("type", "MySql.Data.MySqlClient.MySqlClientFactory,
MySql.Data");
- WriteLineToLog(log, "Attributes are filled.");
-
- WriteLineToLog(log, "Appending entry...");
- factoriesList[0].appendChild(newEntry);
- WriteLineToLog(log, "New entry appended.");
- }
-
- // Save changes
- WriteLineToLog(log, "Saving changes...");
- config.save(machineConfigPath);
- WriteLineToLog(log, "machine.config succesfully saved.");
-
- }
- catch(e)
- {
- WriteLineToLog(log, "Failed to perform main task because of exception!");
- }
-}
-
-// Searches for existing provider entry
-function GetExistsEntry(factoriesList, invariantName)
-{
- for(i = 0; i < factoriesList.childNodes.length; i++ )
- {
- if( factoriesList.childNodes[i].getAttribute("invariant") == invariantName )
- return factoriesList.childNodes[i];
- }
- return null;
-}
\ No newline at end of file
Modified: trunk/Installer/main.wxs
===================================================================
--- trunk/Installer/main.wxs 2006-10-25 21:09:00 UTC (rev 436)
+++ trunk/Installer/main.wxs 2006-10-27 20:31:18 UTC (rev 437)
@@ -51,6 +51,7 @@
<DirectoryRef Id='BinNet20'>
<Component Id="Net20" Guid="529dc176-92d0-4f14-ab09-25f611ce2959">
<File Id="CoreBin20" Name="MD20" LongName="MySql.Data.dll"
src="..\mysqlclient\bin\net-2.0\$(var.build)\mysql.data.dll" DiskId="1" />
+ <File Id="CoreBin20Config" Name="mdconfig" LongName="CustomAction.config"
src="CustomAction.config" DiskId="1"/>
<Registry Id="vs80registry" Root="HKLM"
Key="Software\Microsoft\VisualStudio\8.0\AssemblyFolders\MySQL Connector Net
$(var.ProductVersion)" Type="string" KeyPath="yes" Value="[TARGETDIR]bin\.NET 2.0\" />
</Component>
<Component Id="GAC20" DiskId="1" Guid="302b607b-2633-4b2c-b3da-476a50574b16">
@@ -115,17 +116,20 @@
<Icon Id="ChangeLogIcon" src="Bitmaps\document.ico"/>
+ <!-- custom actions for performing machine.config mods -->
+ <Binary Id="InstallUtil" src="InstallUtilLib.dll" />
+ <CustomAction Id="CustomInstall" BinaryKey="InstallUtil" DllEntry="ManagedInstall"
Execute="deferred" />
+ <CustomAction Id="InstallSetProp" Property="CustomInstall"
Value="/installtype=notransaction /action=install /LogFile=
"[#CoreBin20]" "[#CoreBin20Config]"" />
+ <CustomAction Id="CustomUninstall" BinaryKey="InstallUtil" DllEntry="ManagedInstall"
Execute="deferred" />
+ <CustomAction Id="UninstallSetProp" Property="CustomUninstall"
Value="/installtype=notransaction /action=uninstall /LogFile=
"[#CoreBin20]" "[#CoreBin20Config]"" />
- <Binary Id="MachineConfig" src='MachineConfig.js' />
- <CustomAction Id="InstallMachineConfig" BinaryKey="MachineConfig"
JScriptCall='InstallMachineConfig'/>
- <CustomAction Id="ReinstallMachineConfig" BinaryKey="MachineConfig"
JScriptCall='InstallMachineConfig'/>
- <CustomAction Id="UninstallMachineConfig" BinaryKey="MachineConfig"
JScriptCall='UninstallMachineConfig'/>
+ <InstallExecuteSequence>
+ <Custom Action="InstallSetProp" After="InstallFiles">NOT
Installed</Custom>
+ <Custom Action="CustomInstall" After="InstallSetProp">NOT
Installed</Custom>
- <InstallExecuteSequence>
- <Custom Action='InstallMachineConfig' After='InstallFinalize'>NOT
Installed</Custom>
- <Custom Action='UninstallMachineConfig'
Before='ProcessComponents'>Installed</Custom>
- <Custom Action='ReinstallMachineConfig'
Before='ProcessComponents'>(&Complete<>2) AND
(!Complete=3)</Custom>
- </InstallExecuteSequence>
+ <Custom Action="UninstallSetProp"
After="ProcessComponents">Installed</Custom>
+ <Custom Action="CustomUninstall"
After="UninstallSetProp">Installed</Custom>
+ </InstallExecuteSequence>
</Product>
</Wix>
Modified: trunk/Installer/sources.wxs
===================================================================
--- trunk/Installer/sources.wxs 2006-10-25 21:09:00 UTC (rev 436)
+++ trunk/Installer/sources.wxs 2006-10-27 20:31:18 UTC (rev 437)
@@ -122,7 +122,6 @@
</Directory>
<Directory Id="TestSuite" Name="ts" LongName="TestSuite">
<Component Id="TestSuiteSrc" DiskId="1"
Guid="cfe61742-5d9d-452b-9b12-f8adb012bbb4">
- <File Id="file400" Name="APP_1.CON" LongName="App.config"
src="..\TestSuite\App.config" />
<File Id="file401" Name="ASSEMB_1.CS" LongName="AssemblyInfo.cs"
src="..\TestSuite\AssemblyInfo.cs" />
<File Id="file402" Name="ASYNCT_1.CS" LongName="AsyncTests.cs"
src="..\TestSuite\AsyncTests.cs" />
<File Id="file403" Name="BaseTest.cs" src="..\TestSuite\BaseTest.cs" />
@@ -158,9 +157,9 @@
<File Id="file439" Name="TRANSA_1.CS" LongName="Transactions.cs"
src="..\TestSuite\Transactions.cs" />
<File Id="file440" Name="USAGEA_1.CS" LongName="UsageAdvisor.cs"
src="..\TestSuite\UsageAdvisor.cs" />
<File Id="file441" Name="Utils.cs" src="..\TestSuite\Utils.cs" />
- <File Id="file442" Name="Simple_1.cs" LongName="SimpleTransactions.cs"
src="..\mysqlclient\SimpleTransactions.cs"/>
- <File Id="file443" Name="Timeou_1.cs" LongName="TimeoutAndCancel.cs"
src="..\mysqlclient\TimeoutAndCancel.cs"/>
- <File Id="file444" Name="Syntax2.cs" src="..\mysqlclient\Syntax2.cs"/>
+ <File Id="file442" Name="Simple_1.cs" LongName="SimpleTransactions.cs"
src="..\TestSuite\SimpleTransactions.cs"/>
+ <File Id="file443" Name="Timeou_1.cs" LongName="TimeoutAndCancel.cs"
src="..\TestSuite\TimeoutAndCancel.cs"/>
+ <File Id="file444" Name="Syntax2.cs" src="..\TestSuite\Syntax2.cs"/>
</Component>
</Directory>
</DirectoryRef>
Added: trunk/mysqlclient/Installer.cs
===================================================================
--- trunk/mysqlclient/Installer.cs 2006-10-25 21:09:00 UTC (rev 436)
+++ trunk/mysqlclient/Installer.cs 2006-10-27 20:31:18 UTC (rev 437)
@@ -0,0 +1,108 @@
+using System.Configuration.Install;
+using System.ComponentModel;
+using System.Reflection;
+using System;
+using System.Windows.Forms;
+using Microsoft.Win32;
+using System.Xml;
+using System.IO;
+
+namespace MySql.Data.MySqlClient
+{
+ /// <summary>
+ /// We are adding a custom installer class to our assembly so our installer
+ /// can make proper changes to the machine.config file.
+ /// </summary>
+ [RunInstaller(true)]
+ public class CustomInstaller : Installer
+ {
+ /// <summary>
+ /// We override Install so we can add our assembly to the proper
+ /// machine.config files.
+ /// </summary>
+ /// <param name="stateSaver"></param>
+ public override void Install(System.Collections.IDictionary stateSaver)
+ {
+ base.Install(stateSaver);
+ object installRoot = Registry.GetValue(
+ @"HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\",
+ "InstallRoot", null);
+ if (installRoot == null)
+ throw new Exception("Unable to retrieve install root for .NET framework");
+ string configPath = String.Format(@"{0}v2.0.50727\CONFIG\machine.config",
+ installRoot);
+
+ // now read the config file into memory
+ StreamReader sr = new StreamReader(configPath);
+ string configXML = sr.ReadToEnd();
+ sr.Close();
+
+ // load the XML into the XmlDocument
+ XmlDocument doc = new XmlDocument();
+ doc.LoadXml(configXML);
+
+ // create our new node
+ XmlElement newNode = (XmlElement)doc.CreateNode(XmlNodeType.Element, "add", "");
+
+ // add the proper attributes
+ newNode.SetAttribute("name", "MySQL Data Provider");
+ newNode.SetAttribute("invariant", "MySql.Data.MySqlClient");
+ newNode.SetAttribute("description", ".Net Framework Data Provider for MySQL");
+
+ // add the type attribute by reflecting on the executing assembly
+ Assembly a = Assembly.GetExecutingAssembly();
+ newNode.SetAttribute("type", a.FullName);
+
+ XmlNodeList nodes = doc.GetElementsByTagName("DbProviderFactories");
+ nodes[0].AppendChild(newNode);
+
+ // Save the document to a file and auto-indent the output.
+ XmlTextWriter writer = new XmlTextWriter(configPath, null);
+ writer.Formatting = Formatting.Indented;
+ doc.Save(writer);
+ }
+
+ /// <summary>
+ /// We override Uninstall so we can remove out assembly from the
+ /// machine.config files.
+ /// </summary>
+ /// <param name="savedState"></param>
+ public override void Uninstall(System.Collections.IDictionary savedState)
+ {
+ base.Uninstall(savedState);
+
+ object installRoot = Registry.GetValue(
+ @"HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\",
+ "InstallRoot", null);
+ if (installRoot == null)
+ throw new Exception("Unable to retrieve install root for .NET framework");
+ string configPath = String.Format(@"{0}v2.0.50727\CONFIG\machine.config",
+ installRoot);
+
+ // now read the config file into memory
+ StreamReader sr = new StreamReader(configPath);
+ string configXML = sr.ReadToEnd();
+ sr.Close();
+
+ // load the XML into the XmlDocument
+ XmlDocument doc = new XmlDocument();
+ doc.LoadXml(configXML);
+
+ XmlNodeList nodes = doc.GetElementsByTagName("DbProviderFactories");
+ foreach (XmlNode node in nodes[0].ChildNodes)
+ {
+ string name = node.Attributes["name"].Value;
+ if (name == "MySQL Data Provider")
+ {
+ nodes[0].RemoveChild(node);
+ break;
+ }
+ }
+
+ // Save the document to a file and auto-indent the output.
+ XmlTextWriter writer = new XmlTextWriter(configPath, null);
+ writer.Formatting = Formatting.Indented;
+ doc.Save(writer);
+ }
+ }
+}
Modified: trunk/mysqlclient/MySql.Data.2005.csproj
===================================================================
--- trunk/mysqlclient/MySql.Data.2005.csproj 2006-10-25 21:09:00 UTC (rev 436)
+++ trunk/mysqlclient/MySql.Data.2005.csproj 2006-10-27 20:31:18 UTC (rev 437)
@@ -11,8 +11,7 @@
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>MySql.Data</AssemblyName>
- <AssemblyOriginatorKeyFile>
- </AssemblyOriginatorKeyFile>
+ <AssemblyOriginatorKeyFile>cnet.snk</AssemblyOriginatorKeyFile>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
@@ -91,13 +90,10 @@
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
</PropertyGroup>
<ItemGroup>
- <Reference Include="ICSharpCode.SharpZipLib, Version=0.81.0.1407, Culture=neutral,
PublicKeyToken=1b03e6acf1164f73">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\ICSharpCode.SharpZipLib.dll</HintPath>
- </Reference>
<Reference Include="System">
<Name>System</Name>
</Reference>
+ <Reference Include="System.Configuration.Install" />
<Reference Include="System.Data">
<Name>System.Data</Name>
</Reference>
@@ -116,6 +112,7 @@
<ItemGroup>
<None Include="..\CHANGES" />
<None Include="..\README" />
+ <None Include="cnet.snk" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
@@ -143,6 +140,9 @@
<Compile Include="Driver.cs" />
<Compile Include="Exception.cs" />
<Compile Include="Field.cs" />
+ <Compile Include="Installer.cs">
+ <SubType>Component</SubType>
+ </Compile>
<Compile Include="ISSchemaProvider.cs" />
<Compile Include="Logger.cs" />
<Compile Include="MySqlClientFactory.cs" />
| Thread |
|---|
| • Connector/NET commit: r437 - in trunk: . Installer mysqlclient | rburnett | 27 Oct |