[wix-users] Custom Action Files
MANO MANO
mano.n.s75 at gmail.com
Thu Dec 17 03:17:59 PST 2015
can you check if the file is present at location
'C:\ProgramData\MyCompany\MyProduct\InstallScripts\"
just before calling this CA?
On Fri, Dec 11, 2015 at 11:05 PM, Brian Enderle <brianke at gmail.com> wrote:
> I have an installer with a CusotmAction that has been built and deployed
> corectly in the past using WiX 3.9. I recently updated to WiX3.10 and I am
> now getting errors during installation when the custom action tries to run:
>
> System.Reflection.TargetInvocationException: Exception has been thrown by
> the target of an invocation. ---> System.IO.DirectoryNotFoundException:
> Could not find a part of the path
> 'C:\ProgramData\MyCompany\MyProduct\InstallScripts\01_Create Database.sql'.
> at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
> at System.IO.FileStream.Init(String path, FileMode mode, FileAccess
> access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize,
> FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean
> bFromProxy, Boolean useLongPath, Boolean checkHost)
> at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
> access, FileShare share)
> at System.IO.File.Open(String path, FileMode mode, FileAccess access,
> FileShare share)
> at CustomActions.CustomActions.FileContentsToString(FileInfo file)
> at CustomActions.CustomActions.SQL_Step1(Session session, Database
> dbInfo)
> at CustomActions.CustomActions.ExecuteSQLCustomAction(Session session)
> . . . .
>
>
>
>
> The method executed for this CustomAction is:
>
> private static ActionResult SQL_Step1(Session session,
> Models.Database dbInfo)
> {
> //MessageBox.Show("Executing Custom Action Step 1", "Step 1");
>
> // 01_Create Database.sql
> FileInfo _file = new
> FileInfo(session.CustomActionData["Directory"] + "01_Create Database.sql");
> String _script = FileContentsToString(_file);
> session.Log(String.Format("*** dbInfo: {0}, {1}",
> dbInfo.ServerName, dbInfo.Username));
> session.Log("*** Filename: " + _file.Name + "\n Contents:\n"
> + _script);
> session.Log("*** Executing " + _file.FullName);
>
> try
> {
> // Execute the SQL command script
> using (SQLClass _sql = new SQLClass(dbInfo))
> {
> session.Log("SQL Connection established to " +
> _sql.Connection.Database);
> _sql.ExecuteSqlScript(_script, null, false);
> }
> //Thread.Sleep(5000);
> }
> catch (Exception ex)
> {
> MessageBox.Show("Custom Action Step 1: \n" +
> ex.GetBaseException().Message, "Installation Error", MessageBoxButtons.OK,
> MessageBoxIcon.Exclamation);
> session.Log("****ERROR in custom action SQL_Step1,
> executing '{0}': {1}", _file.Name, ex.GetBaseException().Message);
> return ActionResult.Failure;
> }
>
> return ActionResult.Success;
> }
>
>
> The files are stored in the CustomActions project, in a folder called
> 'InstallScripts', with a Build Action of Content/Do no copy. I also tried
> setting this to Resource but am getting the same error.
>
> Has something changed in 3.10 to now break this?
>
>
> Brian
>
> If you can't explain it simply, you don't understand it well enough. -
> Albert Einstein
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant
> http://www.firegiant.com/
>
--
*regards,*
*Mano*
More information about the wix-users
mailing list