How do I set AssemblyVersion with * for auto build number in MBUILD 15?

281 Views Asked by At

I still want to let my new csproj generate the version number for my library with the new msbuild. But how do I allow the old msbuild behavior of filling in a random build number with an asterix * placeholder?

1

There are 1 best solutions below

0
jbtule On

First you need to turn off rosyln deterministic builds <Deterministic>False</Deterministic>

Then you can use * safely in <AssemblyVersion> If want to get rid of compiler warnings, us <VersionPrefix> to set <AssemblyVersion> and <FileVersion> separately without duplication.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
...
    <VersionPrefix>1.11.31</VersionPrefix>
    <AssemblyVersion>$(VersionPrefix).*</AssemblyVersion>
    <FileVersion>$(VersionPrefix)</FileVersion>
    <Deterministic>False</Deterministic>
  </PropertyGroup>