Updating PublishVersion/MinimumRequiredVersion in .csproj

49 Views Asked by At

This is for a OneClick program.

Initially, I am getting the revision number from subwcrev and populating the assemblyinfo.cs.

I created a pre-build event with this logic. I am able to see the new revision in the assembly information pop-up in the properties dialog.

  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <PropertyGroup>
    <PreBuildEvent>subwcrev $(ProjectDir) "$(ProjectDir)Build\AssemblyInfo.cs.txt"  "$(ProjectDir)Properties\AssemblyInfo.cs" -f</PreBuildEvent>
  </PropertyGroup>

I am trying to sync the MinimumRequiredVersion and PublishVersion so they match the assembly information.

I created a Target for this:

<Target Name="AfterCompile">
    <GetAssemblyIdentity AssemblyFiles="$(IntermediateOutputPath)$(TargetFileName)">
      <Output TaskParameter="Assemblies" ItemName="TargetAssemblyIdentity" />
    </GetAssemblyIdentity>
    <PropertyGroup>
      <PublishVersion>%(TargetAssemblyIdentity.Version)</PublishVersion>
    </PropertyGroup>
    <PropertyGroup>
      <MinimumRequiredVersion>%(TargetAssemblyIdentity.Version)</MinimumRequiredVersion>
    </PropertyGroup>
</Target>

This does not update the PublishVersion or MinimumRequiredVersion, but it does allow me to show a message with it if I use the 'Message' tag.

This is the values I am trying to update. enter image description here

Any ideas what I am missing to get this done when I build the project.

0

There are 0 best solutions below