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.

Add NuGet package version to ThisAssembly

See original GitHub issue

I’m working on a .NET tool which will add a reference to a NuGet package to a project file, very similar to what nbgv does.

For this, I’d like to use a property on ThisAssembly which would return the NuGet package version.

@AArnott what do you think?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:14

github_iconTop GitHub Comments

3reactions
AArnottcommented, Apr 20, 2021

If there was a NuGetPackageVersion available in ThisAssembly, it would be easy to compare.

Really? What compare method would you use? You’d need to know whether the version string is using semver1 or 2 rules then use a compare function appropriate for that semver syntax. It wouldn’t be a simple Version class comparer. Would you redist a NuGet assembly and use its comparer function?

I’ve been trying to use the AdditionalThisAssemblyFields

That would have very specific build ordering requirements. But it should be possible. Like this:

<Target Name="AddNuGetPackageVersionToThisAssembly"
        DependsOnTargets="GetBuildVersion"
        BeforeTargets="GenerateAssemblyVersionInfo">
  <ItemGroup>
    <AdditionalThisAssemblyFields Include="NuGetPackageVersion" String="$(NuGetPackageVersion)" />
  </ItemGroup>
</Target>
2reactions
perpetualKidcommented, Apr 20, 2021

If there was a NuGetPackageVersion available in ThisAssembly, it would be easy to compare.

Really? What compare method would you use? You’d need to know whether the version string is using semver1 or 2 rules then use a compare function appropriate for that semver syntax. It wouldn’t be a simple Version class comparer. Would you redist a NuGet assembly and use its comparer function?

correct, using Nuget.Versioning to provide SemVer-compatible version comparison, to enable auto-update for the application itself, and (future plan) application content, aside using Nuget Core/Protocolto handle feed, download and unpacking. All worked well from the ground for public releases, just got stuck when offering an additional update channel for “developer versions” which are basically non-public releases in nbgv semantic (and served of a separate feed). Certainly not a standard use case.

I’ve been trying to use the AdditionalThisAssemblyFields

That would have very specific build ordering requirements. But it should be possible. Like this:

<Target Name="AddNuGetPackageVersionToThisAssembly"
        DependsOnTargets="GetBuildVersion"
        BeforeTargets="GenerateAssemblyVersionInfo">
  <ItemGroup>
    <AdditionalThisAssemblyFields Include="NuGetPackageVersion" String="$(NuGetPackageVersion)" />
  </ItemGroup>
</Target>

aweseome just did a quick test and seems to do that I needed, saves me from string-mangeling metadata into release labels for non-public releases. Thanks for quick response, and great tool!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ThisAssembly 1.4.0
dotnet add package ThisAssembly --version 1.4.0. NuGet\Install-Package ThisAssembly -Version 1.4.0. This command is intended to be used within the Package ...
Read more >
ThisAssembly 1.2.10
Meta-package that includes all ThisAssembly.* packages. ... See the version list below for details. ... dotnet add package ThisAssembly --version 1.2.10.
Read more >
ThisAssembly 1.2.11
Meta-package that includes all ThisAssembly.* packages. ... See the version list below for details. ... dotnet add package ThisAssembly --version 1.2.11.
Read more >
ThisAssembly 1.1.1-beta
This is a prerelease version of ThisAssembly. There is a newer version of this package available. See the version list below for details....
Read more >
ThisAssembly 1.0.6
Meta-package that includes all ThisAssembly. ... There is a newer version of this package available. ... dotnet add package ThisAssembly --version 1.0.6.
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