The specified version string does not conform to the required format - major[.minor[.build[.revision]]]

C#.NetAssemblyinfo

C# Problem Overview


I want to append our application version with the build number. For example, 1.3.0.201606071.

When setting this in the AssemblyInfo, I get the following compilation error:

> Error CS7034 The specified version string does not conform to the > required format - major[.minor[.build[.revision]]]

Assembly info:

[assembly:System.Reflection.AssemblyFileVersionAttribute("1.0.0.201606071")]
[assembly:System.Reflection.AssemblyVersionAttribute("1.0.0.201606071")]
[assembly:System.Reflection.AssemblyInformationalVersionAttribute("1.0.0.201606071")]

Why would this be happening?

C# Solutions


Solution 1 - C#

The maximum value for either of the parts is 65534, as you read here. This is a limit imposed by the operating system, so not even specific to .NET. Windows puts the version numbers into two integers, which together form four unsigned shorts.

Adding some metadata to it (for the * option I guess) makes the maximum allowed value UInt16.MaxValue - 1 = 65534 (Thanks to Gary Walker for noticing):

> All components of the version must be integers greater than or equal to 0. Metadata restricts the major, minor, build, and revision components for an assembly to a maximum value of UInt16.MaxValue - 1. If a component exceeds this value, a compilation error occurs.

Your 201606071 exceeds this limit.

Solution 2 - C#

If you are targeting netcoreapp2.0 and don't have AssemblyInfo.cs at all you can fix

> error CS7034: The specified version string does not conform to the required format

by adding this into your .csproj file:

<PropertyGroup>
  <GenerateAssemblyInfo>False</GenerateAssemblyInfo>
  <Deterministic>False</Deterministic>
</PropertyGroup>

Solution 3 - C#

Solution 4 - C#

In the .csproj file you must set Deterministic to false. Then accepts the compiler a '*' in the Build or Revision.

Solution 5 - C#

This limitation only applies to the Assembly and File version so if you are using .Net Core 2.x you can get around this limitation by settings a separate version of each in the csproj.

</PropertyGroup>
    <VersionPrefix>1.1.1.9000001</VersionPrefix>
    <VersionSuffix>$(VersionSuffix)</VersionSuffix>
    <AssemblyVersion>1.1.1.0</AssemblyVersion>
    <FileVersion>1.1.1.0</FileVersion>
</PropertyGroup>

Solution 6 - C#

In some cases maybe Treat warnings as errors is enabled in project properties and versions like 1.3.0-4011 will cause following error:

> Properties\AssemblyInfo.cs(35,32): error CS7035: The specified version string does not conform to the recommended format - major.minor.build.revision

So you can Change it using Visual Studio by selecting None or by setting TreatWarningsAsErrors to false in .csproj file.

Treat warnings as errors in project properties

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>none</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>..\..\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
  </PropertyGroup>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDave NewView Question on Stackoverflow
Solution 1 - C#Patrick HofmanView Answer on Stackoverflow
Solution 2 - C#Dmitry PavlovView Answer on Stackoverflow
Solution 3 - C#Dave NewView Answer on Stackoverflow
Solution 4 - C#HRolleView Answer on Stackoverflow
Solution 5 - C#J.D. CainView Answer on Stackoverflow
Solution 6 - C#ZiaaView Answer on Stackoverflow