dotnet / docker-tools

This is a repo to house some common tools for our various docker repos.
MIT License
122 stars 46 forks source link

SBOM generation fails when trying to execute dotnet executable #1152

Closed mthalman closed 4 months ago

mthalman commented 1 year ago

The following error occurs when executing the SBOM generation step:

ForEach-Object : The term 
'D:\a\_work\_tasks\ManifestGeneratorTask_0a569e1c-b731-4e6d-995a-8184fcd1f6e7\0.197.56\dotnet-6.0.15 
D:\a\_work\_tasks\ManifestGeneratorTask_0a569e1c-b731-4e6d-995a-8184fcd1f6e7\0.197.57\dotnet-6.0.15/dotnet' is not 
recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if 
a path was included, verify that the path is correct and try again.
At D:\a\_work\_temp\afdef589-18cb-4c83-9808-cf128c567d68.ps1:30 char:22
+ $images -Split ',' | ForEach-Object {
+                      ~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (D:\a\_work\_tas...t-6.0.15/dotnet:String) [ForEach-Object], CommandNotF 
   oundException
    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.ForEachObjectCommand

Example build (internal link)

Not all of the build jobs are failing with this error. Some are able to successfully generate an SBOM even though they have the same version of the ManifestGeneratorTask (0.197.57) as the failing ones. But this may be due to having a cached copy of the previous version of the ManifestGeneratorTask on the agent. The logic to find the task location is meant to handle this:

https://github.com/dotnet/docker-tools/blob/9791b1592829efbcd4da15a4aabed083b66615b7/eng/common/templates/jobs/build-images.yml#L137-L138

But that may have a bug. Need to sort the sort the results first?

dotnet-issue-labeler[bot] commented 1 year ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

mthalman commented 1 year ago

Need to update the logic to include more logging so that we can see the path it's attempting to use as well as the paths it's queried to derive the action it takes.