question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to set project properties that depend on PackageVersion?

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
natemcmastercommented, Jun 7, 2019

Yeah, it’s hacky. Let me spend more time digging through wix targets to see if I can find a better workaround.

0reactions
natemcmastercommented, Jun 8, 2019

Found workarounds.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PackageReference in project files - NuGet
In this article. Package references, using <PackageReference> MSBuild items, specify NuGet package dependencies directly within project files, ...
Read more >
How to manage Nuget package dependency version with ...
In project B, I have the package version set to 2.0.0 manually. when I test building project A in Visual Studio, the Nuget...
Read more >
Simplify NuGet Package Versions in your application with ...
The package version can be overridden in the project file by setting the VersionOverride attribute to the desired version. <PackageReference ...
Read more >
How to centrally manage NuGet package versions within your ...
That option relies on using the Directory.Build.Targets file to define the nuget package versions in a centralized way. MSBuild projects that ...
Read more >
Managing Package Versions Centrally - Stuart Lang
NET solution grows to 20 projects, and the versions of packages you ... by setting the ManagePackageVersionsCentrally MSBuild property to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found