Here the issue I believe is setting values to a copy of Package Variables, and never updated to package.
Variables vars = package.Variables;
vars["PackageVar"].Value = "TEST";
now vars is never copied to package.
The ideal way to add variable is :
Variable myVar = package.Variables.Add("PackageVar", false, "User", "Test");
The add method can be defined as :
Add(
string name,
bool readOnly,
string nameSpace,
Object val
)
Parameters
name
Type: System.String
The name of the package, task, or container variable to add to the collection.
readOnly
Type: System.Boolean
A Boolean that indicates whether the variable is read-only or whether the variable can be modified.
nameSpace
Type: System.String
The namespace for the variable. Default value is the User variable namespace. You can also create a namespace to identify variables you create that are used in a certain part of a package. You cannot add variables to the System variable namespace.
val
Type: System.Object
The design-time value of the variable.