AssemblyInfo version information asterisks

前端 未结 4 1699
梦毁少年i
梦毁少年i 2020-12-25 09:54

It says in AssemblyInfo.cs for C# projects that it\'s possible to specify version information with *

// Version information for an assembly cons         


        
相关标签:
4条回答
  • 2020-12-25 10:24

    In my opinion, using [assembly: AssemblyVersion("x.y.z.*")], Patch shouldn't be automatically numbered. Eg:

    [assembly: AssemblyVersion("1.2.3.*")]

    Using '*' in AssemblyVersion is good, but follow seemver.org we should use * for the revision part from version structure <major version>.<minor version>.<build number>.<revision>).

    Given a version number MAJOR.MINOR.PATCH, increment the:

    MAJOR version when you make incompatible API changes,

    MINOR version when you add functionality in a backwards-compatible manner, and

    PATCH version when you make backwards-compatible bug fixes.

    0 讨论(0)
  • 2020-12-25 10:32
    [assembly: AssemblyVersion("1.0.*")] 
    //[assembly: AssemblyFileVersion("1.0.*")] 
    

    just remember to comment the AssemblyFileVersion line, otherwise the automatically generated assembly version will always be "1.0.0.0".

    0 讨论(0)
  • 2020-12-25 10:35

    So why does the supplied comment say

    // You can specify all the values or you can default the Build and Revision Numbers
    // by using the '*' as shown below:
    // [assembly: AssemblyVersion("1.0.*")]
    [assembly: AssemblyVersion("1.0.*")]
    [assembly: AssemblyFileVersion("1.0.0.0")]
    

    but builds generate CS8357? Somebody didn't get the memo.

    Work around:
    
     1. Close all open documents
     2. In the Solution Explorer, right-click the Project and select Unload Project
     3. In the Solution Explorer, right-click the Project (now marked as unavailable) and select Edit to access the `.CSPROJ` file
     4. In the opened window, find `<Deterministic>true</Deterministic>` and change it to `<Deterministic>false</Deterministic>`
     5. Save the file and ensure that the edit window is closed
     6. In the Solution Explorer, right-click the Project and select Reload Project
    
    Your build (should then) work. :)
    
    0 讨论(0)
  • 2020-12-25 10:42

    Syntax (see MSDN) for "automatic" build number can be:

    [assembly: AssemblyVersion("1.0.0.*")]
    

    or:

    [assembly: AssemblyVersion("1.0.*")]
    

    * means after this everything is automatic. You can't have automatic build number and fixed revision number then this syntax isn't correct:

    [assembly: AssemblyVersion("1.0.*.0")]
    

    For the AssemblyFileVersionAttribute you cannot use the * special character so you have to provide a full and valid version number. Please note that if you do not provide an AssemblyFileVersionAttribute then you'll get the right FileVersionInfo automatically (with the same version of AssemblyVersionAttribute). You need to specify that attribute only if you need to set a different version.

    0 讨论(0)
提交回复
热议问题