diff --git a/src/Microsoft.Sbom.Targets/GenerateSbom.cs b/src/Microsoft.Sbom.Targets/GenerateSbom.cs
new file mode 100644
index 000000000..18e6fa623
--- /dev/null
+++ b/src/Microsoft.Sbom.Targets/GenerateSbom.cs
@@ -0,0 +1,106 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace Microsoft.Sbom.Targets;
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.Tracing;
+using Microsoft.Build.Framework;
+
+///
+/// This partial class defines and sanitizes the arguments that will be passed
+/// into the SBOM API and CLI tool for generation.
+///
+public partial class GenerateSbom
+{
+ ///
+ /// Gets or sets the path to the drop directory for which the SBOM will be generated.
+ ///
+ [Required]
+ public string BuildDropPath { get; set; }
+
+ ///
+ /// Gets or sets the supplier of the package the SBOM represents.
+ ///
+ [Required]
+ public string PackageSupplier { get; set; }
+
+ ///
+ /// Gets or sets the name of the package the SBOM represents.
+ ///
+ [Required]
+ public string PackageName { get; set; }
+
+ ///
+ /// Gets or sets the version of the package the SBOM represents.
+ ///
+ [Required]
+ public string PackageVersion { get; set; }
+
+ ///
+ /// Gets or sets the base path of the SBOM namespace uri.
+ ///
+ [Required]
+ public string NamespaceBaseUri { get; set; }
+
+ ///
+ /// Gets or sets the path to the directory containing build components and package information.
+ /// For example, path to a .csproj or packages.config file.
+ ///
+ public string BuildComponentPath { get; set; }
+
+ ///
+ /// Gets or sets a unique URI part that will be appended to NamespaceBaseUri.
+ ///
+ public string NamespaceUriUniquePart { get; set; }
+
+ ///
+ /// Gets or sets the path to a file containing a list of external SBOMs that will be appended to the
+ /// SBOM that is being generated.
+ ///
+ public string ExternalDocumentListFile { get; set; }
+
+ ///
+ /// Indicates whether licensing information will be fetched for detected packages.
+ ///
+ public bool FetchLicenseInformation { get; set; }
+
+ ///
+ /// Indicates whether to parse licensing and supplier information from a packages metadata file.
+ ///
+ public bool EnablePackageMetadataParsing { get; set; }
+
+ ///
+ /// Gets or sets the verbosity level for logging output.
+ ///
+ public string Verbosity { get; set; }
+
+ ///
+ /// Gets or sets a list of names and versions of the manifest format being used.
+ ///
+ public string ManifestInfo { get; set; }
+
+ ///
+ /// Indicates whether the previously generated SBOM manifest directory should be deleted
+ /// before generating a new SBOM in the directory specified by ManifestDirPath.
+ /// Defaults to true.
+ ///
+ public bool DeleteManifestDirIfPresent { get; set; } = true;
+
+ ///
+ /// Gets or sets the path where the SBOM will be generated.
+ ///
+ public string ManifestDirPath { get; set; }
+
+ ///
+ /// Gets or sets the path to the SBOM CLI tool
+ ///
+ public string SbomToolPath { get; set; }
+
+ ///
+ /// Gets or sets the path to the generated SBOM directory.
+ ///
+ [Output]
+ public string SbomPath { get; set; }
+}
diff --git a/src/Microsoft.Sbom.Targets/GenerateSbomTask.cs b/src/Microsoft.Sbom.Targets/GenerateSbomTask.cs
index 6225a0370..09bf332d0 100644
--- a/src/Microsoft.Sbom.Targets/GenerateSbomTask.cs
+++ b/src/Microsoft.Sbom.Targets/GenerateSbomTask.cs
@@ -27,98 +27,14 @@ namespace Microsoft.Sbom.Targets;
///
/// MSBuild task for generating SBOMs from build output.
///
-public class GenerateSbomTask : Task
+public partial class GenerateSbom : Task
{
- ///
- /// The path to the drop directory for which the SBOM will be generated.
- ///
- [Required]
- public string BuildDropPath { get; set; }
-
- ///
- /// Supplier of the package the SBOM represents.
- ///
- [Required]
- public string PackageSupplier { get; set; }
-
- ///
- /// Name of the package the SBOM represents.
- ///
- [Required]
- public string PackageName { get; set; }
-
- ///
- /// Version of the package the SBOM represents.
- ///
- [Required]
- public string PackageVersion { get; set; }
-
- ///
- /// The base path of the SBOM namespace uri.
- ///
- [Required]
- public string NamespaceBaseUri { get; set; }
-
- ///
- /// The path to the directory containing build components and package information.
- /// For example, path to a .csproj or packages.config file.
- ///
- public string BuildComponentPath { get; set; }
-
- ///
- /// A unique URI part that will be appended to NamespaceBaseUri.
- ///
- public string NamespaceUriUniquePart { get; set; }
-
- ///
- /// The path to a file containing a list of external SBOMs that will be appended to the
- /// SBOM that is being generated.
- ///
- public string ExternalDocumentListFile { get; set; }
-
- ///
- /// If true, it will fetch licensing information for detected packages.
- ///
- public bool FetchLicenseInformation { get; set; }
-
- ///
- /// If true, it will parse licensing and supplier information from a packages metadata file.
- ///
- public bool EnablePackageMetadataParsing { get; set; }
-
- ///
- /// Determines how detailed the outputed logging will be.
- ///
- public string Verbosity { get; set; }
-
- ///
- /// A list of the name and version of the manifest format being used.
- ///
- public string ManifestInfo { get; set; }
-
- ///
- /// If true, it will delete the previously generated SBOM manifest directory before
- /// generating a new SBOM in ManifestDirPath.
- ///
- public bool DeleteManifestDirIfPresent { get; set; } = true;
-
- ///
- /// The path where the SBOM will be generated.
- ///
- public string ManifestDirPath { get; set; }
-
- ///
- /// The path to the generated SBOM directory.
- ///
- [Output]
- public string SbomPath { get; set; }
-
private ISBOMGenerator Generator { get; set; }
///
/// Constructor for the GenerateSbomTask.
///
- public GenerateSbomTask()
+ public GenerateSbom()
{
var host = Host.CreateDefaultBuilder()
.ConfigureServices((host, services) =>
diff --git a/src/Microsoft.Sbom.Targets/Microsoft.Sbom.Targets.csproj b/src/Microsoft.Sbom.Targets/Microsoft.Sbom.Targets.csproj
index e2f4729bb..a2c94d9ec 100644
--- a/src/Microsoft.Sbom.Targets/Microsoft.Sbom.Targets.csproj
+++ b/src/Microsoft.Sbom.Targets/Microsoft.Sbom.Targets.csproj
@@ -2,6 +2,7 @@
Microsoft.Sbom.Targets
+ net8.0;net472win-x64;osx-x64;linux-x64truetrue
@@ -10,6 +11,7 @@
GenerateSbomTaskTasks and targets for running the SBOM tool.true
+ net8.0
@@ -17,6 +19,7 @@
tasks
+ trueNU5100
@@ -39,6 +42,19 @@
+
+
+
+
+
+ Always
+ true
+ \tasks\net472\sbom-tool\
+ true
+
+
+
+
+
-
- net6.0
- net8.0
+ net472
+ net8.0
+
+
+ $(MSBuildThisFileDirectory)\..\tasks\$(GenerateSbom_TFM)\sbom-tool
-
+
+
+
+
-
-
+
+
-
-
+ ManifestDirPath="$(SbomGenerationManifestDirPath)"
+ SbomToolPath="$(SbomToolPath)">
+
+
diff --git a/src/Microsoft.Sbom.Targets/SbomCLIToolTask.cs b/src/Microsoft.Sbom.Targets/SbomCLIToolTask.cs
new file mode 100644
index 000000000..94e8f4759
--- /dev/null
+++ b/src/Microsoft.Sbom.Targets/SbomCLIToolTask.cs
@@ -0,0 +1,43 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace Microsoft.Sbom.Targets;
+
+using System.IO;
+using Microsoft.Build.Framework;
+using Microsoft.Build.Utilities;
+
+///
+/// MSBuild ToolTask for generating an SBOM using the SBOM CLI tool
+///
+public partial class GenerateSbom : ToolTask
+{
+ protected override string ToolName => "Microsoft.Sbom.Tool";
+
+ ///
+ /// Get full path to SBOM CLI tool.
+ ///
+ ///
+ protected override string GenerateFullPathToTool()
+ {
+ return Path.Combine(this.SbomToolPath, $"{this.ToolName}.exe");
+ }
+
+ ///
+ /// Return a formatted list of arguments for the SBOM CLI tool.
+ ///
+ /// string list of args
+ protected override string GenerateCommandLineCommands()
+ {
+ return "Command";
+ }
+
+ ///
+ /// Validates the SBOM CLI tool parameters
+ ///
+ ///
+ protected override bool ValidateParameters()
+ {
+ return true;
+ }
+}
diff --git a/test/Microsoft.Sbom.Targets.Tests/AbstractGenerateSBomTaskInputTests.cs b/test/Microsoft.Sbom.Targets.Tests/AbstractGenerateSBomTaskInputTests.cs
index a91dbaa99..84ae06889 100644
--- a/test/Microsoft.Sbom.Targets.Tests/AbstractGenerateSBomTaskInputTests.cs
+++ b/test/Microsoft.Sbom.Targets.Tests/AbstractGenerateSBomTaskInputTests.cs
@@ -55,7 +55,7 @@ public void Cleanup() {
}
///
- /// Test for ensuring the GenerateSbomTask fails for null or empty inputs for
+ /// Test for ensuring the GenerateSbom fails for null or empty inputs for
/// required params, which includes BuildDropPath, PackageSupplier, PackageName,
/// PackageVersion, and NamespaceBaseUri.
///
@@ -71,7 +71,7 @@ public void Sbom_Fails_With_Null_Empty_And_WhiteSpace_Required_Params(
string namespaceBaseUri)
{
// Arrange.
- var task = new GenerateSbomTask
+ var task = new GenerateSbom
{
BuildDropPath = buildDropPath,
PackageSupplier = packageSupplier,
@@ -117,7 +117,7 @@ private static IEnumerable
+
+