I find my answer:
first we create an exe file that installs sql server local db 2012. because its indeed small size rather than sql server 2008.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using System.IO;
using System.Configuration.Install;
using System.Diagnostics;
namespace EXE
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
bool instalResult = false;
timer1.Enabled = true;
string strResult = "n";
strResult=fncCheckRegistry();
bool is64 = CheckCpuArcitecture();
string appPath = Path.GetDirectoryName(Application.ExecutablePath);
string strMsix86FileName = appPath + @"\x86\SqlLocaLDB.msi";
string strMsix64FileName = appPath + @"\x64\SqlLocalDB_64.msi";
if (strResult != "y")
{
if (is64 == false)
{
instalResult=fncInstal32(strMsix86FileName);
}
}
if (strResult != "y")
{
if (is64 == true)
{
instalResult = fncInstal32(strMsix64FileName);
}
}
if (instalResult) timer1.Enabled = false;
this.Close();
}
public bool fncInstal32(string sMSIPath)
{
try
{
Console.WriteLine("Starting to install application");
Process process = new Process();
process.StartInfo.FileName = "msiexec.exe";
process.StartInfo.Arguments = string.Format(" /qf /i \"{0}\" ALLUSERS=1 IACCEPTSQLNCLILICENSETERMS=YES", sMSIPath);
process.Start();
process.WaitForExit();
Console.WriteLine("Application installed successfully!");
return true;
}
catch
{
Console.WriteLine("There was a problem installing the application!");
return false;
}
}
public bool CheckCpuArcitecture()
{
bool is64 = System.Environment.Is64BitOperatingSystem;
return is64;
}
public string fncCheckRegistry()
{
string strResult = "n";
using (RegistryKey Key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server 2012 Redist\MSSQL11E.LOCALDB\1033\CurrentVersion"))
if (Key != null)
{
strResult= "y";
}
else
{
strResult= "n";
}
return strResult;
}
bool x = false;
private void timer1_Tick(object sender, EventArgs e)
{
if (progressBar1.Value==100) x=true;
if(!x) progressBar1.Value++;
if (progressBar1.Value==0) x=false;
if(x) progressBar1.Value--;
}
}
}
This checks cpu Arcitecture and if my msi is installed before.
the problem begins here.
I used this project as an exe in custom actions in a another setup project.
in the second setup project i install .net framework 4 and windows installer.
but i added custom action in the commit part of the setup.
So after the first installation finished(not completely the finish button is not clicked) the second setup that install sql server will begin, but how unlucky i am after two days of thinking on my problem it warns me about having two setup working together!!!
What should i do friends? do you have any suggestion?
How can i close the base uninstaller at the end of installation and open another process?
wow i find the answer her too:
I have find my answer:
Well we create an installer class and we write this in it:
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
namespace OpenWeb
{
[RunInstaller(true)]
public partial class Installer1 : System.Configuration.Install.Installer
{
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
}
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
public override void Commit(IDictionary savedState)
{
base.Commit(savedState);
System.Diagnostics.Process.Start(Context.Parameters["TARGETDIR"].ToString() + "Exe.exe");
base.Dispose();
}
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
public override void Rollback(IDictionary savedState)
{
base.Rollback(savedState);
}
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
public override void Uninstall(IDictionary savedState)
{
base.Uninstall(savedState);
}
public Installer1()
{
InitializeComponent();
}
}
}
then we create our setup and we add our exe file and we add the installer class by adding primary output.
now we add custom action in commit and install by adding primary output there too.
now we build our setup.
Enjoy