MSSQLDatabase and Components

May 6, 2012 at 9:56 PM

I have a component with the following structure:

<Component Id="MSSQLDatabaseComponent" Guid="MY-GUID-HERE">

      <DataSource:MSSQLDatabase Id="MSSQLDatabase" Name="[RUNTIME_DATABASE_NAME]" ConnectionId="SQLServerConnection"
      CreateOnInstall="yes" DropOnUnInstall="yes" CheckIfExists="yes">
        <DataSource:ODBCExecute Id="MSSQLDatabase_CreateSchema" ExecuteOnInstall="yes"
         BasePath="[INSTALLLOCATION]" Type="SqlServer" Sql="Schema.sql" >FirstInstall OR Upgrading</DataSource:ODBCExecute>
      </DataSource:MSSQLDatabase>
    </Component>

I;m getting an error: The Component/@Direcotr attribute was not found; it is required. And I cant seem to get rid of it, no matter what I do. Ive tried creating a directory inside, as well as adding keyvalue to the Component, but nothing works.

Any help would be appreciated.

Coordinator
May 6, 2012 at 10:36 PM

Is the component within a Directory? Which version of Wix?

Jan 21, 2013 at 2:05 PM
Edited Jan 21, 2013 at 2:06 PM

I get the same error. what is the fix?

This is my product.wxs content:

 

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
     xmlns:sql="http://schemas.microsoft.com/wix/SqlExtension"
     xmlns:DataSource="http://schemas.appsecinc.com/wix/DataSourceExtension">
    
	<Product Id="*" Name="MySetup2" Language="1033" Version="1.0.0.0" Manufacturer="Hewlett-Packard Company" UpgradeCode="bf1da750-c2fe-4026-9d2b-9d291a61a8b5">
		<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

		<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
		<MediaTemplate />

		<Feature Id="ProductFeature" Title="MySetup2" Level="1" ConfigurableDirectory="INSTALLDIR">
			<ComponentGroupRef Id="ProductComponents" />
            <!--<ComponentRef Id="Web.config" />-->
            <!--<ComponentRef Id="MvcApplication4.dll" />-->
            <ComponentRef Id="StartMenuFolder" />
            <!--<ComponentRef Id="IISApplication" />-->
            <ComponentGroupRef Id='MvcApp'/>
            <!--<ComponentRef Id='SqlComponent' />-->
            <ComponentRef Id='MSSQLDatabaseMsiComponent' />
		</Feature>
        <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />

        <Binary Id="CreateTableScript"  SourceFile="c:\Temp\MyDb.sql" />
        
        <!-- Specify UI -->
        <UIRef Id="MyWebUI" />
 
    	<!-- .NET Framework 3.0 SP 1 must be installed -->
		<Property Id="FRAMEWORKBASEPATH">
			<RegistrySearch Id="FindFrameworkDir" Root="HKLM" Key="SOFTWARE\Microsoft\.NETFramework" Name="InstallRoot" Type="raw"/>
		</Property>

        <DataSource:ODBCConnection Id="DemoSQLServerConnection" ConnectionString="[ODBC_CONNECTION_STRING]" />
        
	</Product>

    
	<Fragment>
		<Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="INSTALLDIR" Name="MySetup2" >
                    <!--<Component Id="Web.config" Guid="2ED81B77-F153-4003-9006-4770D789D4B6">
                        <File Id="Web.config" Name="Web.config" Source="$(var.SolutionDir)MvcApplication4\Web.config" DiskId="1" KeyPath="yes" />
                        <util:XmlFile Id="AppSettingsAddNode" File="[INSTALLDIR]Web.config" Action="createElement" ElementPath="/configuration/appSettings" Name="add" Sequence="1" />
                        <util:XmlFile Id="AppSettingsKeyAttribute" Action="setValue" File="[INSTALLDIR]Web.config" ElementPath="/configuration/appSettings/add" Name="key" Value="AddedDuringInstall" Sequence="2" />
                        <util:XmlFile Id="AppSettingsValueAttribute" Action="setValue" File="[INSTALLDIR]Web.config" ElementPath="/configuration/appSettings/add" Name="value" Value="This text was added during installation." Sequence="3" />
                    </Component>
                    <Directory Id="binFolder" Name="bin">
                        <Component Id="MvcApplication4.dll" Guid="7FC6DA37-12E5-463d-8E7E-08F73E40CCF2">
                            <File Id="MvcApplication4.dll" Name="MvcApplication4.dll" Source="$(var.SolutionDir)MvcApplication4\Bin\MvcApplication4.dll" DiskId="1" KeyPath="yes" />
                        </Component>
                    </Directory>-->

                </Directory>
                
                <Directory Id="MyWebAppStartMenuFolder" Name="SimpleWebApp">
                    <Component Id="StartMenuFolder" Guid="B3AEC4C4-3F8E-4865-B87A-B750533776B5" >
                        <util:InternetShortcut Id="SimpleWebAppShortcut" Name="SimpleWebApp" Target="http://localhost/SimpleWebApp/Default.aspx" Directory="MyWebAppStartMenuFolder" />
                        <RemoveFolder Id="RemoveStartMenuFolder1" On="uninstall"/>
                        <RegistryKey Root="HKCU" Key="SOFTWARE\torresdal.net\SimpleWebApp\SimpleWebAppShortcut">
                            <RegistryValue Type="string" Value="Default Value"/>
                        </RegistryKey>
                    </Component>
                </Directory>
                
			</Directory>

            <!--<Component Id="SqlComponent" Guid="C50999A0-02FD-42d5-9F65-7375318DD328">
                <sql:SqlDatabase Id="SqlDatabase" 
                                Database="[DB_NAME]" 
                                Server="[DB_SERVERNAME]" 
                                CreateOnInstall="yes" 
                                DropOnUninstall="yes" 
                                User="SQLUser">
                    <sql:SqlScript Id="CreateTableScript" ExecuteOnInstall="yes" BinaryKey="CreateTableScript" />
                </sql:SqlDatabase> 
                <util:User Id="SQLUser" Name="[DB_USER]" Password="[DB_PASSWORD]" />  
            </Component>-->

            
            
            <Component Id="MSSQLDatabaseMsiComponent" Guid="0FEAF4B6-7065-47e2-A403-E94A4B176772">
                <CreateFolder/>
                <DataSource:MSSQLDatabase Id="MSSQLDemoDatabase" Name="DemoDatabase" ConnectionId="DemoSQLServerConnection"
                  CreateOnInstall="yes" DropOnUnInstall="no" CheckIfExists="yes">
                    <DataSource:ODBCExecute Id="MSSQLDemoDatabase_CreateSchema" ExecuteOnInstall="yes"
                     BasePath="[INSTALLLOCATION]" Type="SqlServer" File="MyDb.sql">FirstInstall</DataSource:ODBCExecute>
                </DataSource:MSSQLDatabase>
            </Component>
            
            
        </Directory>
        
	</Fragment>

	<Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLDIR">
            <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
            <!-- <Component Id="ProductComponent"> -->
            <!-- TODO: Insert files, registry keys, and other resources here. -->
            <!-- </Component> -->
        </ComponentGroup>
	</Fragment>
</Wix>

 

Coordinator
Jan 21, 2013 at 2:09 PM

 

*IMPORTANT*

THE PROJECT HAS MOVED TO GITHUB, PLEASE DON'T POST ANYTHING HERE

THE PROJECT HAS MOVED TO GITHUB, PLEASE DON'T POST ANYTHING HERE

THE PROJECT HAS MOVED TO GITHUB, PLEASE DON'T POST ANYTHING HERE

THE PROJECT HAS MOVED TO GITHUB, PLEASE DON'T POST ANYTHING HERE

THE PROJECT HAS MOVED TO GITHUB, PLEASE DON'T POST ANYTHING HERE

THE PROJECT HAS MOVED TO GITHUB, PLEASE DON'T POST ANYTHING HERE

THE PROJECT HAS MOVED TO GITHUB, PLEASE DON'T POST ANYTHING HERE

THE PROJECT HAS MOVED TO GITHUB, PLEASE DON'T POST ANYTHING HERE

Go here. There's also a new discussions group on Google, here. Please don't post any more questions on CodePlex.