Example #1
0
            public TaskDefinition(BuildTask task, PSWithReturnValueToken varToken)
            {
                this.task = task;
                scriptUseToken = asNodeWithOptions(varToken);
                task.SetParameterValue("Capture", scriptUseToken["Capture"]);

                var kvSerializer = (KeyValueSerializer)scriptUseToken.Where(kv => kv.Key != "Capture")
                .ToDictionary(kv => kv.Key, kv => kv.Value);
                if (!string.IsNullOrEmpty(kvSerializer.ToString()))
                  task.SetParameterValue("CommandParameters", kvSerializer.ToString());

                task.SetParameterValue("ReturnValueType", varToken.ValueType.ToString());
                if (varToken.ValueType.Equals(PSScriptReturnValueType.ItemGroup))
                  task.AddOutputItem("ScriptItemOutput", varToken.VariableName);
                if (varToken.ValueType.Equals(PSScriptReturnValueType.Property))
                  task.AddOutputProperty("ScriptPropOutput", varToken.VariableName);
            }
        /// <summary>
        /// Adds a new VCBuild task element to the specified target
        /// </summary>
        /// <param name="target">The target to add the VCBuild task to</param>
        /// <param name="solutionPath">Path to the solution if any</param>
        /// <param name="projectPath">Path to the solution if any</param>
        /// <param name="vcbuildTargetName">The VCBuild target name</param>
        /// <param name="platformName">The platform parameter to VCBuild</param>
        /// <param name="fullConfigurationName">Configuration property value</param>
        /// <returns></returns>
        static internal BuildTask AddVCBuildTaskElement
        (
            Project msbuildProject,
            Target target,
            string solutionPath,
            string projectPath,
            string vcbuildTargetName,
            string platformName,
            string fullConfigurationName
        )
        {
            // The VCBuild task (which we already shipped) has a bug - it cannot
            // find vcbuild.exe when running in MSBuild 64 bit unless it's on the path.
            // So, pass it here, unless some explicit path was passed.
            // Note, we have to do this even if we're in a 32 bit MSBuild, because we save the .sln.cache
            // file, and the next build of the solution could be a 64 bit MSBuild.

            if (VCBuildLocationHint != null) // Should only be null if vcbuild truly isn't installed; in that case, let the task log its error
            {
                BuildTask createProperty = target.AddNewTask("CreateProperty");

                createProperty.SetParameterValue("Value", VCBuildLocationHint);
                createProperty.Condition = "'$(VCBuildToolPath)' == ''";
                createProperty.AddOutputProperty("Value", "VCBuildToolPath");
            }

            BuildTask newTask = target.AddNewTask("VCBuild");

            newTask.SetParameterValue("Projects", projectPath, true /* treat as literal */);

            // Add the toolpath so that the user can override if necessary
            newTask.SetParameterValue("ToolPath", "$(VCBuildToolPath)");

            newTask.SetParameterValue("Configuration", fullConfigurationName);

            if (!string.IsNullOrEmpty(platformName))
            {
                newTask.SetParameterValue("Platform", platformName);
            }

            newTask.SetParameterValue("SolutionFile", solutionPath);

            if ((vcbuildTargetName != null) && (vcbuildTargetName.Length > 0))
            {
                newTask.SetParameterValue(vcbuildTargetName, "true");
            }

            // Add the override switch so that the user can supply one if necessary
            newTask.SetParameterValue("Override", "$(VCBuildOverride)");

            // Add any additional lib paths
            newTask.SetParameterValue("AdditionalLibPaths", "$(VCBuildAdditionalLibPaths)");

            // Only use new properties if we're not emitting a 2.0 project
            if (!String.Equals(msbuildProject.ToolsVersion, "2.0", StringComparison.OrdinalIgnoreCase))
            {
                // Add any additional link library paths
                newTask.SetParameterValue("AdditionalLinkLibraryPaths", "$(VCBuildAdditionalLinkLibraryPaths)");

                // Add the useenv switch so that the user can supply one if necessary
                // Note: "VCBuildUserEnvironment" is included for backwards-compatibility; the correct
                // property name is "VCBuildUseEnvironment" to match the task parameter. When the old name is
                // used the task will emit a warning.
                newTask.SetParameterValue("UseEnvironment", "$(VCBuildUseEnvironment)");
            }

            newTask.SetParameterValue("UserEnvironment", "$(VCBuildUserEnvironment)");

            // Add the additional options switches
            newTask.SetParameterValue("AdditionalOptions", "$(VCBuildAdditionalOptions)");

            return(newTask);
        }
Example #3
0
 public TaskDefinition(BuildTask task, PSScriptToken token)
 {
     this.task = task;
     task.SetParameterValue("Script", token.Script);
     task.SetParameterValue("ReturnValueType", PSScriptReturnValueType.Undefined.ToString());
     ScriptIsSet = true;
 }
Example #4
0
 public TaskDefinition(BuildTask task, TokenWithOptions callToken)
 {
     this.task = task;
     scriptUseToken = callToken;
     task.SetParameterValue("Capture", callToken["Capture"]);
     task.SetParameterValue("ReturnValueType", PSScriptReturnValueType.Undefined.ToString());
 }