Skip to content

How to set project properties that depend on PackageVersion? #2984

@natemcmaster

Description

@natemcmaster

I'm trying to adopt Microsoft.DotNet.Arcade.Sdk. Before adopting this, we were computing VersionPrefix, VersionSuffix, and PackageVersion properties during the Directory.Build.props file.

In Microsoft.DotNet.Arcade.Sdk, the evaluation order is different. VersionSuffix is set in Version.BeforeCommonTargets.targets which is evaluated after the project file, so I can't set PackageVersion from Directory.Build.props. As a result, I haven't found a way to make something like this work:

<TargetName>aspnetcore-runtime-$(PackageVersion)-win-$(Platform)</TargetName>

Example: https://github.com/aspnet/AspNetCore/blob/67b665208c94908ef8503e39d54e078a2ea778dc/src/Installers/Windows/TargetingPack/TargetingPack.wixproj#L9

Candidates and why they don't work:

  • Project file
    • Implicit top/bottom imports - evaluation is always too early. PackageVersion is empty
    • With explicit top/bottom imports, setting the property after the Sdk.targets import. - too late
  • Directory.Build.targets - too late, Microsoft.Common.targets uses TargetName to compute a handful of other properties like TargetPath. I could attempt to find everywhere TargetName is used and re-compute all derived properties, but that's likely to be fragile
  • Custom import set via CustomBeforeMicrosoftCommonTargets - target is still evaluated too early, before Version.BeforeCommon.targets

@tmat - any ideas how to solve this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions