How to use release date as build version for .net project?

I know the assembly version format is:

<major version>.<minor version>.<build number>.<revision>

Is there a way to make the version number the current date?

For example, if I compile the assembly today, the version number should look like this:

2016.02.11.xxxxx

Where xxxxx is what you usually get if you set the build version to 1.0.0. *.

I googled around, but didn't find an answer (not even a question) for this.

+4
source share
2 answers

MSBUILD. . . MSBUILD BeforeBuild . csproj :

<!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
+1

: " " > " " " " :

"D:\SomePath\MyAssemblyInfoPatcher.exe" "$(ProjectDir)Properties\AssemblyInfo.cs"

:. MyAssemblyInfoPatcher.exe, , , , ( ):

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

( ):

[assembly: AssemblyVersion("2016.11.05.2359")]
[assembly: AssemblyVersion("2016.1105.2359.1")]
[assembly: AssemblyVersion("8888.2016.1105.2359")]

.

, :

yyyy.mm.dd.hhmm
yyyy.mmdd.hhmm.counter
arbitrary.yyyy.mmdd.hhmm

, , . ( ) , . (UInt16), 65535 0. , reset , , , AssemblyInfo. CS. , , .

: . ( ) ( ). , UTC , , , Daylight Savings Time. - , - -, VS ( ab * ab { 1 2000 00:00}. { 1 2000 00:00, 2}, ).

: • "AssemblyInfo.cs", : "$ (ProjectDir) Properties". • VS , "D:\Users\myusername\Documents\Visual Studio 2010\Projects\solutionfolder\projectfolder\Properties", .

• AssemblyVersion System.Reflection.Assembly.GetExecutingAssembly(). GetName(). .
• : AssemblyFileVersion.
• AssemblyFileVersion ( ) AssemblyVersion.

+1

Source: https://habr.com/ru/post/1628201/


All Articles