/// <summary>
        /// Constructs a local (task-specific) script task.
        /// </summary>
        public ScriptTask(Script script,
                          ProjectWrapper projectWrapper, PackageWrapper packageWrapper, ContainerWrapper containerWrapper, ScriptProject referencedGlobalScriptProject)
        {
            bool hasReference = script.ScriptProjectReference != null;

            ScriptTaskWrapper = new ScriptTaskWrapper(containerWrapper, hasReference ? script.ScriptProjectReference.ScriptProjectName : script.ScriptProject.Name, hasReference, ScriptTaskScope.Package)
            {
                Name                 = script.Name,
                DelayValidation      = script.DelayValidation,
                ForceExecutionResult = script.ForceExecutionResult.ToString()
            };

            AddExpressions(ScriptTaskWrapper, script.PropertyExpressions);

            if (hasReference)
            {
                ScriptTaskWrapper.ReadOnlyVariables  = GetVariableNames(referencedGlobalScriptProject.ReadOnlyVariables, ScriptTaskScope.Package, projectWrapper, packageWrapper, containerWrapper);
                ScriptTaskWrapper.ReadWriteVariables = GetVariableNames(referencedGlobalScriptProject.ReadWriteVariables, ScriptTaskScope.Package, projectWrapper, packageWrapper, containerWrapper);
            }
            else
            {
                ScriptTaskWrapper.ReadOnlyVariables  = GetVariableNames(script.ScriptProject.ReadOnlyVariables, ScriptTaskScope.Package, projectWrapper, packageWrapper, containerWrapper);
                ScriptTaskWrapper.ReadWriteVariables = GetVariableNames(script.ScriptProject.ReadWriteVariables, ScriptTaskScope.Package, projectWrapper, packageWrapper, containerWrapper);

                AddAssemblyReferences(script.ScriptProject.AssemblyReferences, projectWrapper.Version);
                AddSourceFiles(script.ScriptProject.Files);
            }

            CheckForBuildErrors(projectWrapper.StopBuildOnScriptErrors);
            ScriptTaskWrapper.PropagateErrors(script.PropagateErrors);
        }
        /// <summary>
        /// Constructs a "global" script task.
        /// </summary>
        public ScriptTask(ScriptProject scriptProject, ProjectWrapper projectWrapper, PackageWrapper packageWrapper, ContainerWrapper containerWrapper)
        {
            ScriptTaskWrapper = new ScriptTaskWrapper(containerWrapper, scriptProject.Name, false, ScriptTaskScope.Project)
            {
                Name = scriptProject.Name
            };

            ScriptTaskWrapper.ReadOnlyVariables  = GetVariableNames(scriptProject.ReadOnlyVariables, ScriptTaskScope.Project, projectWrapper, packageWrapper, containerWrapper);
            ScriptTaskWrapper.ReadWriteVariables = GetVariableNames(scriptProject.ReadWriteVariables, ScriptTaskScope.Project, projectWrapper, packageWrapper, containerWrapper);

            AddAssemblyReferences(scriptProject.AssemblyReferences, projectWrapper.Version);
            AddSourceFiles(scriptProject.Files);
        }