diff --git a/src/Microsoft.Sbom.Targets/Microsoft.Sbom.Targets.targets b/src/Microsoft.Sbom.Targets/Microsoft.Sbom.Targets.targets index 914941eb5..c6700e7ff 100644 --- a/src/Microsoft.Sbom.Targets/Microsoft.Sbom.Targets.targets +++ b/src/Microsoft.Sbom.Targets/Microsoft.Sbom.Targets.targets @@ -12,13 +12,24 @@ net472 net8.0 + $([System.IO.Path]::Combine($(MSBuildThisFileDirectory),..,tasks,$(GenerateSbom_TFM),sbom-tool)) + $([System.IO.Path]::Combine($(MSBuildThisFileDirectory),..,tasks,$(GenerateSbom_TFM),Microsoft.Sbom.Targets.dll)) + - $(MSBuildThisFileDirectory)\..\tasks\$(GenerateSbom_TFM)\sbom-tool + $(SbomToolBinaryOutputPath) _manifest + spdx_2.2 + + + + + + $(TargetsForTfmSpecificContentInPackage);CopySbomOutput + - + false @@ -39,6 +50,7 @@ + + - - - - true - _manifest - - - - true - _manifest - - - - true - _manifest - + + + + + $(TargetFramework)$(TargetPlatformVersion) + $(TargetFramework) + + + + + $([System.IO.Path]::Combine($(BuildOutputTargetFolder),$(TargetFrameworkWithPlatformVersion),$(ManifestFolderName),$(SbomSpecification))) + diff --git a/src/Microsoft.Sbom.Targets/SbomCLIToolTask.cs b/src/Microsoft.Sbom.Targets/SbomCLIToolTask.cs index 99f3692e1..c86dcd380 100644 --- a/src/Microsoft.Sbom.Targets/SbomCLIToolTask.cs +++ b/src/Microsoft.Sbom.Targets/SbomCLIToolTask.cs @@ -3,7 +3,7 @@ namespace Microsoft.Sbom.Targets; -using System.Diagnostics.Tracing; +using System; using System.IO; using Microsoft.Build.Utilities; @@ -14,6 +14,31 @@ public partial class GenerateSbom : ToolTask { protected override string ToolName => "Microsoft.Sbom.Tool"; + /// + /// Executes the SBOM CLI Tool invocation. Need to add extra logic + /// to set SbomPath to the directory containing the SBOM. + /// + /// + public override bool Execute() + { + var taskResult = base.Execute(); + // Set the SbomPath output variable + if (taskResult) { + var manifestFolderName = "_manifest"; + if (!string.IsNullOrWhiteSpace(this.ManifestDirPath)) + { + var fullManifestDirPath = Path.GetFullPath(this.ManifestDirPath); + this.SbomPath = Path.Combine(fullManifestDirPath, manifestFolderName); + } else + { + var fullBuidDropPath = Path.GetFullPath(this.BuildDropPath); + this.SbomPath = Path.Combine(fullBuidDropPath, manifestFolderName); + } + } + + return taskResult; + } + /// /// Get full path to SBOM CLI tool. /// @@ -97,5 +122,7 @@ private void SetOutputImportance() { this.StandardOutputImportance = "Low"; } + + this.LogStandardErrorAsError = true; } }