Build target _CalculateInputsOutputsForPack calculates NuGetPackOutput incorrectly when OutputFileNamesWithoutVersion set to true
#12.644 aperta il 8 giu 2023
Metriche repository
- Star
- (1459 stelle)
- Metriche merge PR
- (Merge medio 464g 23h) (1 PR mergiata in 30 g)
Descrizione
NuGet Product Used
MSBuild.exe
Product Version
17.2.9
Worked before?
No
Impact
Other
Repro Steps & Context
Description: When I set OutputFileNamesWithoutVersion to ‘true’ in my self-package project (.csproj), theNuGetPackOut items still includes the PackageVersion. Here is the output from my diagnostic log.
Target "_CalculateInputsOutputsForPack: (TargetId:197)" in file "e:\cc.A\DotNetSDK.WNISXRY87pl2QEmm1UZjOg\sdk\6.0.408\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets" from project "d:\msazure\Intune\CoreSvc\EnggInfra\QLocal\cmd\b\src\BuildTools\Intune.Build.EmbeddedSymbolChecker\EmbeddedSymbolChecker\EmbeddedSymbolChecker.csproj" (target "GenerateNuspec" depends on it): --snip-- Added Item(s): NuGetPackOutput= d:\msazure\Intune\CoreSvc\EnggInfra\QLocal\cmd\b\out\packages\Microsoft.Intune.Build.EmbeddedSymbolChecker.1.0.5-carhein2315178459.nupkg d:\msazure\Intune\CoreSvc\EnggInfra\src\BuildTools\Intune.Build.EmbeddedSymbolChecker\EmbeddedSymbolChecker\obj\Release\Microsoft.Intune.Build.EmbeddedSymbolChecker.1.0.5-carhein2315178459.nuspec --snip-- Task Parameter:OutputFileNamesWithoutVersion=True (TaskId:128) --snip— Successfully created package 'd:\msazure\Intune\CoreSvc\EnggInfra\QLocal\cmd\b\out\packages\Microsoft.Intune.Build.EmbeddedSymbolChecker.nupkg'. (TaskId:128) Done executing task "PackTask". (TaskId:128)
Looks like the GetPackOutputItemsTask in NuGet.Build.Tasks.Pack.targets does not consider the OutputFileNamesWithoutVersion property.
============================================================
_GetOutputItemsFromPack
Gets the output '.nupkg' and '.nuspec' absolute file paths.
============================================================
-->
<!-- 'PackageOutputAbsolutePath' and 'NuspecOutputAbsolutePath' will be provided by '_GetAbsoluteOutputPathsForPack' target -->
<GetPackOutputItemsTask
PackageOutputPath="$(PackageOutputAbsolutePath)"
NuspecOutputPath="$(NuspecOutputAbsolutePath)"
PackageId="$(PackageId)"
PackageVersion="$(PackageVersion)"
IncludeSymbols="$(IncludeSymbols)"
IncludeSource="$(IncludeSource)"
SymbolPackageFormat="$(SymbolPackageFormat)">
<Output
TaskParameter="OutputPackItems"
ItemName="_OutputPackItems" />
</GetPackOutputItemsTask>
Repro steps:
- Create an SDK Style MSBuild project.
- Set the OutputFileNamesWithoutVersion property to true.
- Build
Actual Result: _CalculateInputsOutputsForPack calculates a NuGet output path that includes the package version. The PackTask creates a NuGet package without the package version.
Expected Result: _CalculateInputsOutputsForPack calculates a NuGet output path that excludes the package version.
Impact: Any build target that needs the NuGet output path cannot rely on the NuGetPackOutput item.
Incremental build does not work correctly.
Verbose Logs
Verbose logs attached to comments.