I have a script task inside a foreach loop that should write to a variable.
Dts.Variables["Variable"].Value = "Hello";
Looks fine to me, however the variable doesn't ever seem to be written to. The variable name is spelt correctly and is set as ReadWrite in the script task configuration.
The variable has package scope, is there something related to it being in a loop that could affect it? I've also tried using Dts.VariableDispencer.
Update: I have an int that I also write to alongside that does get written to fine. Aside from the different data type, the method is identical. Any ideas why I would fail to write a string?
It turns out the variable was actually set as an expression (totally forgot I had done that!). This was what was stopping it from being overwritten. Changing it to be a normal variable solved the issue.