Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version issue with Multi-target projects #202

Closed
kikaragyozov opened this issue Aug 26, 2022 · 1 comment
Closed

Version issue with Multi-target projects #202

kikaragyozov opened this issue Aug 26, 2022 · 1 comment
Labels

Comments

@kikaragyozov
Copy link

kikaragyozov commented Aug 26, 2022

If I have a normal project that only targets one framework, and I define the following target in its .csproj file:

  <Target Name="PopulateNETSDKAssemblyVersion" AfterTargets="_GitPopulateVersionInfo">
    <PropertyGroup>
      <Version>$(GitBaseVersionMajor).$(GitBaseVersionMinor).$(GitBaseVersionPatch).0</Version>
      <FileVersion>$(GitBaseVersionMajor).$(GitBaseVersionMinor).$(GitBaseVersionPatch).$(GitCommits)</FileVersion>
      <PackageVersion>$(FileVersion)</PackageVersion>
      <InformationalVersion>$(FileVersion)+branch.$(GitBranch).commit.$(GitCommit)</InformationalVersion>
    </PropertyGroup>
    <Message Importance="high" Text="PackageVersion: $(PackageVersion)" />
  </Target>

Everything works - when packing the version it's correct. But once we move to a multi-target project, this doesn't do anything.

@kzu
Copy link
Member

kzu commented Feb 6, 2023

Change it to this:

<Target Name="PopulateNETSDKAssemblyVersion" BeforeTargets="CoreCompile;GenerateNuspec" DependsOnTargets="GitVersion">

When multi-targeting, the .NET SDK won't invoke most of the "normal" targets it does for a regular build. You can learn a lot by running dotnet build -bl on the projects and using msbuildlog.com to inspect the targets that are being run and when.

@kzu kzu closed this as not planned Won't fix, can't repro, duplicate, stale Feb 6, 2023
@devlooped devlooped locked and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants