0

I want to set the System.Reflection.AssemblyVersionAttribute for a blazor-web-app without changing it allways manualy.

Google didn't know the answer :-(

How can I influence the value?

Thanks! Peter

PBum
  • 123
  • 10

2 Answers2

1

MSBump seems to work with .net5.0. Search it in nuget.

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">

    <PropertyGroup>
        <TargetFramework>net5.0</TargetFramework>
        <Version>1.0.1.2</Version>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="MSBump" Version="2.3.2">
            <PrivateAssets>all</PrivateAssets>
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
    </ItemGroup>
    <PropertyGroup Condition="$(Configuration) == 'Debug'">
        <BumpLabel>dev</BumpLabel>
        <BumpLabelDigits>4</BumpLabelDigits>
    </PropertyGroup>
    <PropertyGroup Condition="$(Configuration) == 'Release'">
        <BumpRevision>True</BumpRevision>
        <BumpResetLabel>dev</BumpResetLabel>
    </PropertyGroup>
</Project>

Brian Parker
  • 11,946
  • 2
  • 31
  • 41
0

A way to change the value of AssemblyVersionAttribute is to use a msbuild task. This thread points out a good examples Specify assembly version number as a command line argument in MSBuild. There is no difference between a "normal" app or a Blazor app.

If you want to use the version number, here is a sample component named SiteFooter

@using System.Reflection

<footer class="main-footer">
    <span>
        Version: @_version
    </span> 
</footer>

@code {

    private String _version = typeof(SiteFooter).Assembly.GetCustomAttribute<AssemblyFileVersionAttribute>().Version;

}
Just the benno
  • 2,306
  • 8
  • 12