'Read Assembly Version in a Post Build Event in Visual Studio 2022 targeting Netstandard2 .0

I have a project in netstandard 2.0 and I use post build events to create a nuget package and to push it automatically to my feed, that was working on .NetFramework. I know that with netstandard and netcore I can create them through the package function automatically but this is not an option because I override the assembly properties to increase automatically my version number.

Anyway I found a solution that in Visual Studio 2019 with .NetFramework 4.8 was working perfectly, nevertheless for Visual Studio 2022 with netStandard this macro does not work.

<Target Name="PostBuildMacros">
  <GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
    <Output TaskParameter="Assemblies" ItemName="Targets" />
  </GetAssemblyIdentity>
  <ItemGroup>
    <VersionNumber Include="@(Targets->'%(Version)')" />
  </ItemGroup>
</Target>

Does anyone have an idea why is not working? is there an alternative solution used for netcore or netstadard?

I appreciate your comments

PS: The version number increment is working, I double checked in the build folders.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source