Exemple #1
0
        /// <summary>
        /// Adds a task element to the current target.
        /// </summary>
        /// <param name="name">The name of the task.</param>
        /// <param name="condition">An optional condition to add to the task.</param>
        /// <param name="parameters">An optional <see cref="IDictionary{String,String}" /> that contains the parameters to pass to the task.</param>
        /// <param name="continueOnError">An optional value indicating if the build should continue in the case of an error.  The valid values are:
        /// <list type="Bullet">
        ///   <item>
        ///     <description><code>WarnAndContinue</code> or <code>true</code> - When a task fails, subsequent tasks in the Target element and the build continue to execute, and all errors from the task are treated as warnings.</description>
        ///   </item>
        ///   <item>
        ///     <description><code>ErrorAndContinue</code> - When a task fails, subsequent tasks in the Target element and the build continue to execute, and all errors from the task are treated as errors.</description>
        ///   </item>
        ///   <item>
        ///     <description><code>ErrorAndStop</code> or <code>false</code> - (Default) When a task fails, the remaining tasks in the Target element and the build aren't executed, and the entire Target element and the build is considered to have failed.</description>
        ///   </item>
        /// </list>
        /// </param>
        /// <param name="architecture">an optional architecture for the task.</param>
        /// <param name="runtime">An optional runtime for the task.</param>
        /// <param name="label">An optional label to add to the task.</param>
        /// <returns>The current <see cref="ProjectCreator" />.</returns>
        public ProjectCreator Task(string name, string?condition = null, IDictionary <string, string?>?parameters = null, string?continueOnError = null, string?architecture = null, string?runtime = null, string?label = null)
        {
            _lastTask = LastTarget.AddTask(name);

            _lastTask.ContinueOnError     = continueOnError;
            _lastTask.Condition           = condition;
            _lastTask.Label               = label;
            _lastTask.MSBuildArchitecture = architecture;
            _lastTask.MSBuildRuntime      = runtime;

            if (parameters != null)
            {
                foreach (KeyValuePair <string, string?> parameter in parameters.Where(i => i.Value != null))
                {
                    _lastTask.SetParameter(parameter.Key, parameter.Value);
                }
            }

            return(this);
        }