Class DotNetSDK

All Implemented Interfaces:
ExtensionPoint, Describable<ToolInstallation>, EnvironmentSpecific<DotNetSDK>, NodeSpecific<DotNetSDK>, Serializable

public final class DotNetSDK extends ToolInstallation implements NodeSpecific<DotNetSDK>, EnvironmentSpecific<DotNetSDK>
An installation of a .NET SDK as a global tool.
See Also:
  • Field Details

    • HOME_ENVIRONMENT_VARIABLE

      @Deprecated public static final String HOME_ENVIRONMENT_VARIABLE
      Deprecated.
      Use ROOT_ENVIRONMENT_VARIABLE instead; that environment variable is also used by the SDK itself.
      An environment variable that will be set to the full path to the SDK (backward compatibility).
      See Also:
    • ROOT_ENVIRONMENT_VARIABLE

      public static final String ROOT_ENVIRONMENT_VARIABLE
      The environment variable that will be set to the full path to the SDK (used by the SDK in some cases).
      See Also:
  • Constructor Details

    • DotNetSDK

      public DotNetSDK(@NonNull String name, @NonNull String home)
      Creates a new .NET SDK installation.
      Parameters:
      name - The name for the installation.
      home - The path to the SDK.
    • DotNetSDK

      @DataBoundConstructor public DotNetSDK(@NonNull String name, @NonNull String home, @CheckForNull List<? extends ToolProperty<?>> properties)
      Creates a new .NET SDK installation.
      Parameters:
      name - The name for the installation.
      home - The path to the SDK.
      properties - Additional properties for the SDK installation.
  • Method Details

    • isTelemetryOptOut

      public boolean isTelemetryOptOut()
      Determines whether the telemetry opt-out is set.
      Returns:
      true when the telemetry opt-out is set; false otherwise.
    • setTelemetryOptOut

      @DataBoundSetter public void setTelemetryOptOut(boolean telemetryOptOut)
      Determines whether the telemetry opt-out should be set.
      Parameters:
      telemetryOptOut - true to opt out of telemetry; false otherwise.
    • addSdks

      public static void addSdks(@NonNull ListBoxModel model)
      Adds the names of all defined .NET SDK installations to a listbox model.
      Parameters:
      model - The listbox model to add the .NET SDK installations to.
    • buildEnvVars

      public void buildEnvVars(@NonNull EnvVars env)
      Sets up environment variables for this .NET SDK installation.
      Overrides:
      buildEnvVars in class ToolInstallation
      Parameters:
      env - The environment variables to add values to.
    • createGlobalJson

      public boolean createGlobalJson(@NonNull FilePath dir, @NonNull TaskListener listener)
      Create a global.json in the specified location, forcing the use of this .NET SDK's exact version.
      Parameters:
      dir - The location where the global.json should be created.
      listener - The task listener to use for output
      Returns:
      true when a global.json file was created; false otherwise.
    • ensureExecutableExists

      @NonNull public String ensureExecutableExists(@NonNull Launcher launcher) throws IOException, InterruptedException
      Ensures that the dotnet executable exists in this .NET SDK installation.
      Parameters:
      launcher - The launcher to use for the verification.
      Returns:
      The full path to the dotnet executable in this .NET SDK installation.
      Throws:
      AbortException - When the executable could not be found.
      IOException - When an I/O error occurs.
      InterruptedException - When processing is interrupted.
    • forEnvironment

      @NonNull public DotNetSDK forEnvironment(@NonNull EnvVars envVars)
      Creates a copy of this .NET SDK installation that has the specified environment variables applied.
      Specified by:
      forEnvironment in interface EnvironmentSpecific<DotNetSDK>
      Parameters:
      envVars - The environment variables to apply.
      Returns:
      A copy of this .NET SDK installation that has the specified environment variables applied.
    • forNode

      @NonNull public DotNetSDK forNode(@NonNull Node node, @NonNull TaskListener listener) throws IOException, InterruptedException
      Creates a copy of this .NET SDK installation for use on the specified node.
      Specified by:
      forNode in interface NodeSpecific<DotNetSDK>
      Parameters:
      node - The node to use the .NET SDK installation on.
      Returns:
      A copy of this .NET SDK installation for use on node.
      Throws:
      IOException
      InterruptedException
    • getExecutableFileName

      @NonNull public static String getExecutableFileName(@NonNull Launcher launcher)
      Returns the file name for the dotnet executable on the agent platform.
      Parameters:
      launcher - The launcher to use to determine the agent platform.
      Returns:
      dotnet.exe when launcher represents a Windows agent, dotnet otherwise.
    • getHomePath

      @CheckForNull public FilePath getHomePath(@CheckForNull hudson.remoting.VirtualChannel channel)
      Determines the file path for this SDK's home directory.
      Parameters:
      channel - The remote context to use for the file path.
      Returns:
      A file path representing this SDK's home directory, or null if no home directory was set.
    • hasConfiguration

      public static boolean hasConfiguration()
      Determines whether any .NET SDKs have been configured.
      Returns:
      true when at least one .NET SDK has been configured; otherwise, false.
    • removeGlobalJson

      public static void removeGlobalJson(@NonNull FilePath dir, @NonNull TaskListener listener)
      Removes a global.json file (as previously created via createGlobalJson(FilePath, TaskListener).
      Parameters:
      dir - The location containing the global.json file to remove.
      listener - The task listener to use for output.