Class MSBuildCommand

All Implemented Interfaces:
ExtensionPoint, Describable<Builder>, BuildStep, SimpleBuildStep
Direct Known Subclasses:
Build, Clean, Pack, Publish, Test

public class MSBuildCommand extends Command
A build step executing an MSBuild-based .NET CLI command.
  • Field Details

    • configuration

      @CheckForNull protected String configuration
      The project configuration to use.
    • options

      @CheckForNull protected String options
      Additional options to pass to the command. Options specified via more specific settings will take precedence over options specified here.
    • outputDirectory

      @CheckForNull protected String outputDirectory
      The output directory for the command.
    • project

      @CheckForNull protected String project
      The project to process; for some commands this can also be a directory or a solution.
    • properties

      @CheckForNull protected String properties
      MSBuild properties to set.
    • verbosity

      @CheckForNull protected String verbosity
      The verbosity to use for the command.
  • Constructor Details

    • MSBuildCommand

      public MSBuildCommand()
      Creates a new dotnet build step based on MSBuild processing.
    • MSBuildCommand

      public MSBuildCommand(@NonNull String command)
      Creates a new dotnet build step based on MSBuild processing.
      Parameters:
      command - The dotnet command to execute.
  • Method Details

    • addCommandLineArguments

      protected void addCommandLineArguments(@NonNull DotNetArguments args)
      Adds command line arguments for this invocation of the dotnet CLI.

      This adds:

      1. The command name, if applicable.
      2. The project specified via setProject(String).
      3. Any raw options specified via setOption(String), setOptions(String...) or setOptionsString(String).
      4. -c:xxx, if a configuration has been specified via setConfiguration(String).
      5. --nologo, if requested via setNologo(boolean).
      6. --output xxx, if an output directory has been specified via setOutputDirectory(String).
      7. -p:name=value, for all properties specified via setProperties(Map) or setPropertiesString(String).
      8. -v:xxx, if a verbosity has been specified via setVerbosity(String).
      Overrides:
      addCommandLineArguments in class Command
      Parameters:
      args - The current set of arguments.
    • getConfiguration

      @CheckForNull public String getConfiguration()
      Gets the project configuration to use.
      Returns:
      The project configuration to use.
    • setConfiguration

      @DataBoundSetter public void setConfiguration(@CheckForNull String configuration)
      Sets the project configuration to use.
      Parameters:
      configuration - The project configuration to use.
    • isNologo

      public boolean isNologo()
      Determines whether the MSBuild version/copyright lines should be suppressed.
      Returns:
      true if the MSBuild startup banner should be suppressed; false otherwise.
    • setNologo

      @DataBoundSetter public void setNologo(boolean noLogo)
      Determines whether the MSBuild version/copyright lines should be suppressed.
      Parameters:
      noLogo - true if the MSBuild startup banner should be suppressed; false otherwise.
    • getOption

      @CheckForNull public String getOption()
      Gets the single additional option to pass to the command.
      Returns:
      An additional option to pass to the command, or null when there is not exactly one such option set.
    • setOption

      @DataBoundSetter public void setOption(@CheckForNull String option)
      Sets a single additional option to pass to the command.

      To set more than one, use setOptions(String...) instead.

      Parameters:
      option - An additional option to pass to the command.
    • getOptions

      @CheckForNull public String[] getOptions()
      Gets additional options to pass to the command.
      Returns:
      Additional options to pass to the command.
    • setOptions

      @DataBoundSetter public void setOptions(@CheckForNull String... options)
      Sets additional options to pass to the command. Options specified via more specific settings will take precedence over options specified here.
      Parameters:
      options - Additional options to pass to the command.
    • getOptionsString

      @CheckForNull public String getOptionsString()
      Gets additional options to pass to the command. Options specified via more specific settings will take precedence over options specified here.
      Returns:
      Additional options to pass to the command.
    • setOptionsString

      @DataBoundSetter public void setOptionsString(@CheckForNull String options)
      Sets additional options to pass to the command. Options specified via more specific settings will take precedence over options specified here.
      Parameters:
      options - Additional options to pass to the command.
    • getOutputDirectory

      @CheckForNull public String getOutputDirectory()
      Gets the output directory for the command.
      Returns:
      The output directory for the command.
    • setOutputDirectory

      @DataBoundSetter public void setOutputDirectory(@CheckForNull String outputDirectory)
      Sets the output directory for the command.
      Parameters:
      outputDirectory - The output directory for the command.
    • getProject

      @CheckForNull public String getProject()
      Gets the name of the project file to process. For some commands, this can also be a directory or a solution file. When null, a project or solution from the current directory will usually be processed.
      Returns:
      The project to process.
    • setProject

      @DataBoundSetter public void setProject(@CheckForNull String project)
      Sets the name of the project file to process. For some commands, this can also be a directory or a solution file. When null, a project or solution from the current directory will usually be processed.
      Parameters:
      project - The project to process.
    • getProperties

      @CheckForNull public Map<String,String> getProperties() throws IOException
      Gets MSBuild properties to be applied to the command.
      Returns:
      MSBuild properties to be applied to the command (one key=value setting per line).
      Throws:
      IOException - When there is a problem loading the properties into a Java Properties object.
    • setProperties

      @DataBoundSetter public void setProperties(@CheckForNull Map<String,String> properties) throws IOException
      Sets MSBuild properties to be applied to the command.
      Parameters:
      properties - MSBuild properties to be applied to the command (one key=value setting per line).
      Throws:
      IOException - When there is a problem using a Properties object to generate a string form for the map.
    • getPropertiesString

      @CheckForNull public String getPropertiesString()
      Gets MSBuild properties to be applied to the command.
      Returns:
      MSBuild properties to be applied to the command (one key=value setting per line).
    • setPropertiesString

      @DataBoundSetter public void setPropertiesString(@CheckForNull String properties)
      Sets MSBuild properties to be applied to the command.
      Parameters:
      properties - MSBuild properties to be applied to the command (one key=value setting per line).
    • isShutDownBuildServers

      public boolean isShutDownBuildServers()
      Determines whether any build servers started by the main command should be shut down.
      Returns:
      true if "dotnet build-server shutdown" should be run after the main command; false otherwise.
    • setShutDownBuildServers

      @DataBoundSetter public void setShutDownBuildServers(boolean shutDownBuildServers)
      Determines whether any build servers started by the main command should be shut down.
      Parameters:
      shutDownBuildServers - true if "dotnet build-server shutdown" should be run after the main command; false otherwise.
    • isUnstableIfErrors

      public boolean isUnstableIfErrors()
      Determines whether the presence of errors makes the build unstable (instead of failed).
      Returns:
      true if errors cause the build to be marked as unstable (instead of failed); false otherwise.
    • setUnstableIfErrors

      @DataBoundSetter public void setUnstableIfErrors(boolean unstableIfErrors)
      Determines whether the presence of errors makes the build unstable (instead of failed).
      Parameters:
      unstableIfErrors - true if errors cause the build to be marked as unstable (instead of failed); false otherwise.
    • isUnstableIfWarnings

      public boolean isUnstableIfWarnings()
      Determines whether the presence of warnings makes the build unstable (instead of successful).
      Returns:
      true if warnings cause the build to be marked as unstable (instead of successful); false otherwise.
    • setUnstableIfWarnings

      @DataBoundSetter public void setUnstableIfWarnings(boolean unstableIfWarnings)
      Determines whether the presence of warnings makes the build unstable (instead of successful).
      Parameters:
      unstableIfWarnings - true if warnings cause the build to be marked as unstable (instead of successful); false otherwise.
    • getVerbosity

      @CheckForNull public String getVerbosity()
      Gets the verbosity to use for the command.
      Returns:
      The verbosity to use for the command.
    • setVerbosity

      @DataBoundSetter public void setVerbosity(@CheckForNull String verbosity)
      Sets the verbosity to use for the command.
      Parameters:
      verbosity - The verbosity to use for the command.