Skip to content

Conversation

@MichaelSimons
Copy link
Member

</Target>

<!-- Parse the passed in CSV file into PackageInfo items with metadata. -->
<UsingTask TaskName="ParsePackagesCsv" AssemblyFile="$(PackageSourceGeneratorTaskAssembly)" />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ViktorHofer, I went with an approach to encapsulate the CSV logic within a task. The problem is the PackageSourceGeneratorTask dependency project doesn't get in time the packageDownloads need to be defined. Do you have any suggestions on how to get the PackageSourceGeneratorTask to build sooner? TIA

Comment on lines +58 to +61
<PackageDownload Include="@(GroupedPackageInfo->Metadata('PackageName'))"
Version="%(PackageVersions)"
Condition="'@(GroupedPackageInfo)' != ''" />
</ItemGroup>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PackageDownload and PackageReference items which are read by NuGet need to either be defined statically at evaluation time or inside a target that runs before CollectPackageReferences / CollectPackageDownloads.

So I would add a BeforeTargets="CollectPackageDownloads" to this target.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was that the thing you were asking for help?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that CollectPackageDownloads runs before the referenced PackageSourceGeneratorTask.csproj gets built as it is defined as a ProjectReference. I am not sure what the best way to trigger the building of PackageSourceGeneratorTask.csproj. Changing AfterTargets="ValidateRestoreCsvContentProperties" to BeforeTargets="CollectPackageDownloads" doesn't solve this problem.

Copy link
Member

@ViktorHofer ViktorHofer Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see. While I usually don't recommend doing that, you could use an inline C# msbuild task.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that thought crossed my mind but didn't think it would be acceptable. I don't want to spend much time on this and would just like a working solution so I will proceed with this. We can always refactor later. Thanks for the feedback.

@MichaelSimons MichaelSimons marked this pull request as ready for review January 31, 2025 23:30
@MichaelSimons MichaelSimons requested a review from a team as a code owner January 31, 2025 23:30
@MichaelSimons MichaelSimons merged commit 7290368 into dotnet:main Feb 3, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SBRP] generate.sh --csv does not supporting multiple versions of a package

3 participants