Debugging SSIS Script task - Breakpoint is enabled but it does not hit

After more research and trial-error, found that the SSIS package ignores the breakpoints in a Script Task when debugging on a 64-bit machine. To fix it -

  1. Go to the Solution Explorer
  2. Right click your SSIS project node > Properties
  3. In Configuration Properties > Debugging > Debug Options > Set Run64BitRunTime to False.

SSIS Project configuration settings

After making this change, the breakpoints hit like magic.


I tried all the answers provided here with no success (using VS2015). After some more searching I found this question that is actually an answer which stated that newer C# features / syntax were causing the debugger to not fire correctly.

In their example (and also mine) using string interpolation was causing the breakpoints to not be hit.

Replacing

$"{someVariable} - {someOtherVariable}"

with

string.Format("{0} - {1}", someVariable, someOtherVariable);

did the trick for me.

EDIT

It appears this issue has now been fixed with SQL Server Integration Services Projects, but you need to be running VS2019 to download it.


In my case, none of these solutions worked. I finally got to know that the Resharper was culprit. After uninstalling it, it started working like charm.


Update: Guys, I againg lost any ability to set breakpoints (a request to MS)
My previous fixes are below.
Now I'm using logging and tracing instead of debugging.


C# new features (after C# 4.0) are blamed for killing debugging of the SSIS Script Task.

To return the breakpoint capability I do the following.

  1. Remove C# new features
  2. Run my Script Task once, successfully. I.e. without a crash.
  3. Reopen the Vsta Project from my Script Task and put breakpoints there.

At the end, you have to see a red circle on your Script Task.
(Tested in VS 2017.)

enter image description here

Note. I have to mention that debugging works even if your use "Execute Task" only, not "Execute Package"!

Remove C# new features

To remove the C# new features, I can advise you two ways.

First, restrict Vsta Project properties to C# 4.0 (migrated packages may not support this).

  1. Dobule click your "Script Task" to open "Script Task Editor".
  2. Click "Edit Script..." button to open Visual Studio.
  3. In "Solution Explorer" select the project and click the F4 key on your keyboard.
  4. In opened "Properties" window in "C# Language Level" choise "C# 4.0"
  5. Build your project and fix compilation errors.

Secondly, Vsta Projects in old/migrated packages may not show the above "C# Language Level" property.
So you can put your code in a fake project in Visual Studio 2010 and compile it there.

Run it once successfully

After you fix your C#, you have to run your Script Task once successfully.
You may want to put the return statement at the beginning of the Main() method to prevent any real execution.
Sorry, this doesn't always work and I don't realise why but you definitely need to fix your C# in the first place.
At least you will get a working Script Task and can debug it in an old fashioned way (logs by Dts.Events..., exceptions, etc.)

TL;DR

It looks like I even got severe cases when C# new features forced Script Tasks to fail silently with a success completion status.

As an example, add the following to your Script task.

string Bug { get; } // Only getter properties.
//...
var str = $"Now is {DateTime.Now}"; // String Interpolation in C#
//...
var dummy = val?.ToUpper(); // ?. and ?[] null-conditional Operators

And workarounds for this non-complete list:

string Bug { get; set; }
//...
var str = string.Format("Now is {0}", DateTime.Now);
// etc.

What I also do, I build my C# code in Visual Studio 2010. It simply doesn't compile the new .NET features and do not allows .NET Framework versions above 4.0. So far, so good.

Of course, other answers from this SO-question didn't help me.