69

I can't use * in assembly version

Represents text as sequence of UTF-16 code units.To browse the .NET Framework source code for this type, see the Reference Source.

The specifed version string contains wildcards, which are not compatible with determinism. Either remove wildcards from the version string, or disable determinism for this compilation

SCRAssembly

d219
  • 2,275
  • 5
  • 21
  • 29
Lucyper
  • 749
  • 1
  • 6
  • 9
  • 1
    @SamW and how does he do that? – Cataklysim Dec 14 '18 at 14:59
  • 1
    Specific to .NETCore projects, /deterministic compile option. You'd have to edit the .csproj file by hand to turn it off. Do beware that the version is considerably worse that non-deterministic, as written the revision number will be the time of day. So version numbers can go backwards or repeat, you might as well not use them at all. – Hans Passant Dec 14 '18 at 15:11
  • 4
    Always post error message (and code) as text, not as images. – Henk Holterman Dec 14 '18 at 15:28

3 Answers3

68

Add <Deterministic> tag with false value and use * for the 3'rd part of AssemblyVersion inside <PropertyGroup> in .csproj file:

<PropertyGroup>
    <ProduceReferenceAssembly>true</ProduceReferenceAssembly>
    <Version>1.0.0</Version>
    <AssemblyVersion>1.0.*</AssemblyVersion>
    <Deterministic>false</Deterministic>
</PropertyGroup>
John Deer
  • 1,105
  • 1
  • 8
  • 15
  • 2
    But what does the `````` tag do? – Jay Jun 03 '20 at 22:48
  • 12
    To answer my own question for those who also want to know - Deterministic means something like - the compiler will use the same versions of the files if no changes have happened resulting faster builds/tests. What does changing it adversely affect if it was disabled originally and you want to do a wildcard in the version number? Basically Nothing. It just allows that to be possible. https://blog.paranoidcoding.com/2016/04/05/deterministic-builds-in-roslyn.html – Jay Jun 03 '20 at 22:56
  • 4
    For those who want to use the wildcard to auto-generate version info, this is actually a more direct answer. Note that it is the AssemblyVersion (not AssemblyFileVersion) that you should use a wildcard in. If you provide AssemblyVersion with wildcard, just don't include AssemblyFileVersion at all. (I use a Properties\AssemblyInfo.cs file and leave them blank in the project settings, but it looks like it's supported there too, above.) – Appurist - Paul W Jun 16 '20 at 15:04
  • 1
    Note also: There are two forms. One where the asterisk wildcard is in the third position (x.y.*) and one where it is in the fourth position (x.y.z.*). In the x.y.* case, the build will auto-generate two version numbers, the first will be the number of days since some epoch, thus it only changes once each day. Today, for example, an AssemblyVersion of '1.0.*' will generate a specific '7472', e.g. '1.0.7472.20737'. The 5-digit final number will be different every build, at least if changes. I find this is better than 1.0.0.* for support as it indicates age (.7300 would be almost 6 months old). – Appurist - Paul W Jun 16 '20 at 15:06
  • @Appurist-PaulW: `1.0.*` auto-generates the BUILD and REVISION numbers. BUILD is the "number of days since 1st January 2000" and REVISION is "half the number seconds since 00:00". Your example, `1.0.7472.20737`, means "this assembly was built on 2020-06-16 at 11:31:14". – AlainD Feb 09 '21 at 12:22
60

I guess you were able to use it earlier and can't anymore.

Reason - There have been some changes to Visual Studio as the new project files now default to 'True' for 'Deterministic' attribute.

Solution - as Hans Passant says, edit project file by hand. Cons to doing it, also as he says.

Specifically, edit .csproj to <Deterministic>false</Deterministic>.

Source - https://marinovdh.wordpress.com/2018/10/22/68/

StayOnTarget
  • 7,829
  • 8
  • 42
  • 59
Animesh
  • 906
  • 1
  • 10
  • 11
2

VS2019 can auto-create an .editorconfig file putting severity as 'suggest', which content is like this:

[*.cs]

    # CS7035: The specified version string does not conform to the recommended format - major.minor.build.revision
    dotnet_diagnostic.CS7035.severity = suggestion

enter image description here

John Deer
  • 1,105
  • 1
  • 8
  • 15