1

I've a setup project in VS2013 using WiX. The setup executes SQL scripts on SQL Server. I'd like to find a way to add raiserror messages (with severity <11) into installation log and show them to a user.

Leo Y
  • 659
  • 7
  • 22

2 Answers2

0
  1. Your SQL script should be executed using a Custom action.
  2. Use System.Data.SqlClient.SQLCommand to execute your script.
  3. Then surround it with a try catch and catch the exception and show an error message as below.

    try {

    // Your code to execute the script.
    

    }

    catch (Exception e)

    {
    session.Message(InstallMessage.Warning, new Record(new string[] { e.Message }));

    }

LeoN
  • 1,590
  • 1
  • 11
  • 19
  • Thank you. I know about this approach. However, I'm looking for a way to do it using WIX script for executing everything. This way I don't need to deal with all implementation of executing SQL commands in the setup domain. An alternative can be using custom action to retrieve all information messages from SQL, but not implement the whole DB setup this way. – Leo Y Apr 30 '15 at 17:17
  • I would say this way is much better than trying to use wix to execute the script. Because we got more control on what we do. Also we have the flexibility to show the required error message. – LeoN May 01 '15 at 06:12
  • I separate implementation and flexibility/control. This is way I'm looking for different answer. – Leo Y May 01 '15 at 07:56
0

After in-depth investigation of what WIX tools provide, it seems that there is no way to achieve this goal using WIX tools. I've opened a feature request. If it passes moderation, I'll update the answer with a link. An alternative is suggested in comments above. It's implement the whole SQL setup using custom action.

Leo Y
  • 659
  • 7
  • 22