-
Notifications
You must be signed in to change notification settings - Fork 161
[Microsoft.Sbom.Targets] Generates the wrong .nupkg file name and cannot find it. #920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
In NuGet.Build.Tasks.Pack.targets, the |
I think you can use the Example: <Target Name="FindNupgkFile" AfterTargets="Pack">
<ItemGroup>
<_NupgkFiles Include="@(NuGetPackOutput)" Condition="'%(Extension)' == '.nupkg'" />
</ItemGroup>
<Message Text="NupgkFile: @(_NupgkFiles)" Importance="high" />
</Target> See: Provide MSBuild properties or items for resolved pack outputs or Make MSBuild Pack target return the nupkg file as output |
Somewhat related dotnet/msbuild#9881 -- I think a MSBuild v17.12.18 with BuildCheck enabled will warn that both the PackTask task (in the "GenerateNuspec" target) and the Microsoft.Build.Tasks.ZipDirectory task (in the "GenerateSbomTarget" target) output the same nupkg file. Fixing that might require telling NuGet.Build.Tasks.Pack.targets to write the nupkg file to some other directory initially and then writing only the SBOM-enriched nupkg to the final output directory. But if PackTask writes a snupkg file too, then that complicates the implementation. |
This analyzer currently only checks a few specific tasks: So, this shouldn't trigger the "Double Writes" warning (At least for now) |
@baronfel do you have any thoughts on this issue? Is this something that needs to be addressed in this repo or one of the .NET repos? |
I think the fix needs to be made here: sbom-tool/src/Microsoft.Sbom.Targets/Microsoft.Sbom.Targets.targets Lines 43 to 45 in 20f4360
|
Hi @philipp-naused feel free to make a PR if you would like us to consider this change, I would also love @baronfel to chime in on this before we action on it. |
@KalleOlaviNiemitalo is definitely on the right path here - we must be data-driven and retrieve it from the Target Outputs being discussed here. |
@baronfel, I'm not clear about which "Target Outputs" you are referring to. Do you mean the SBOM target should call the |
@sfoslund Unfortunately, I cannot contribute to a public repo on this account. I might do that on a separate account later. |
Uh oh!
There was an error while loading. Please reload this page.
The
GenerateSbomTarget
target generates the wrong path to the .nupkg file and fails.Example:
dotnet pack
Result:
error MSB3932: Failed to unzip file "X:\ws\Test\bin\Release\Test.1.2.3.0.nupkg" because the file does not exist or is inaccessible.
The correct path would have been
X:\ws\Test\bin\Release\Test.1.2.3.nupkg
since the trailing0
is trimmed.See:
sbom-tool/src/Microsoft.Sbom.Targets/Microsoft.Sbom.Targets.targets
Lines 43 to 45 in 20f4360
Since the unzip task is set to
ErrorAndContinue
, the target will then generate a new zip file calledTest.1.2.3.0.nupkg
that only contains the SBOM. If you rundotnet pack
again without deleting the bin directory, you get a different warning:and
The text was updated successfully, but these errors were encountered: