あなたはそれを正しくやっています。基本的な SSIS パッケージを作成しました。1 つの変数、FolderPath、タイプ文字列があります。Information イベントを発生させるスクリプト タスクが 1 つあり、その内容によって FolderPath 変数の値が公開されます。

次に、このような基本的な C# コンソール アプリを作成しました
public class InformationListener : DefaultEvents
{
public override void OnInformation(DtsObject source, int informationCode, string subComponent, string description, string helpFile, int helpContext, string idofInterfaceWithError, ref bool fireAgain)
{
//base.OnInformation(source, informationCode, subComponent, description, helpFile, helpContext, idofInterfaceWithError, ref fireAgain);
Console.WriteLine(string.Format("{0} {1}", subComponent, description));
}
}
class Program
{
static void Main(string[] args)
{
string sourcePackage = string.Empty;
string path = string.Empty;
string variableName = string.Empty;
string designValue = string.Empty;
string newValue = string.Empty;
InformationListener listener = null;
sourcePackage = @"J:\Src\SO\SSIS\Package.dtsx";
path = @"J:\runtime";
variableName = "User::FolderPath";
listener = new InformationListener();
Application app = new Application();
Package pkg = null;
Variable ssisVariable = null;
pkg = app.LoadPackage(sourcePackage, null);
ssisVariable = pkg.Variables[variableName];
designValue = ssisVariable.Value.ToString();
Console.WriteLine(string.Format("Designtime value = {0}", designValue));
ssisVariable.Value = path;
newValue = ssisVariable.Value.ToString();
Console.WriteLine(string.Format("new value = {0}", newValue));
DTSExecResult results = DTSExecResult.Canceled;
results = pkg.Execute(null, null, listener, null, null);
Console.WriteLine("Press any key to continue");
Console.ReadKey();
}
}
変数検査からわかるように

そして私のプリントステートメントから

上記の文字列をエスケープするのを忘れたため、 の設計時の値はC:\designTime
に移動しますが、表示されるふりをすることができます。J:
J:\runtime
つまり、メソッドを呼び出してパッケージをシリアル化しない限りSaveToXml
、オブジェクトがスコープ外になると、User::FolderPath の値は設計時の値にリセットされます。永久に更新すると次のようになります
app.SaveToXml(sourcePackage, pkg, null);
OP EDITこの議論と例は、私を答えに導きました
: c-script-task-not-setting-variable