|
1 | 1 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
2 | 2 |
|
| 3 | + <!-- Ensure BaseVersion is set --> |
| 4 | + <PropertyGroup Condition="'$(BaseVersion)' == ''"> |
| 5 | + <BaseVersion>0.1.0</BaseVersion> <!-- Fallback default --> |
| 6 | + </PropertyGroup> |
| 7 | + |
| 8 | + <!-- Set BuildMetadata if not already defined --> |
| 9 | + <PropertyGroup Condition="'$(BuildMetadata)' == ''"> |
| 10 | + <BuildMetadata></BuildMetadata> |
| 11 | + </PropertyGroup> |
| 12 | + |
| 13 | + <!-- Set BuildIdentifier if not already defined --> |
| 14 | + <PropertyGroup Condition="'$(BuildIdentifier)' == ''"> |
| 15 | + <BuildIdentifier></BuildIdentifier> |
| 16 | + </PropertyGroup> |
| 17 | + |
| 18 | + <!-- Assembly and File version = fixed numeric version --> |
| 19 | + <PropertyGroup> |
| 20 | + <AssemblyVersion>$(BaseVersion).0</AssemblyVersion> |
| 21 | + <FileVersion>$(BaseVersion).0</FileVersion> |
| 22 | + </PropertyGroup> |
| 23 | + |
| 24 | + <!-- NuGet version (semver + metadata) --> |
| 25 | + <PropertyGroup Condition="'$(BuildMetadata)' != ''"> |
| 26 | + <Version>$(BaseVersion)-$(BuildMetadata)</Version> |
| 27 | + <InformationalVersion Condition="'$(BuildIdentifier)' != ''">$(BaseVersion)-$(BuildMetadata)+$(BuildIdentifier)</InformationalVersion> |
| 28 | + <InformationalVersion Condition="'$(BuildIdentifier)' == ''">$(BaseVersion)-$(BuildMetadata)</InformationalVersion> |
| 29 | + </PropertyGroup> |
| 30 | + |
| 31 | + <PropertyGroup Condition="'$(BuildMetadata)' == ''"> |
| 32 | + <Version>$(BaseVersion).0</Version> |
| 33 | + <InformationalVersion Condition="'$(BuildIdentifier)' != ''">$(BaseVersion)+$(BuildIdentifier)</InformationalVersion> |
| 34 | + <InformationalVersion Condition="'$(BuildIdentifier)' == ''">$(BaseVersion).0</InformationalVersion> |
| 35 | + </PropertyGroup> |
| 36 | + |
3 | 37 | <PropertyGroup> |
4 | 38 | <LogVersionInfo Condition="'$(LogVersionInfo)' == ''">true</LogVersionInfo> |
5 | 39 | </PropertyGroup> |
|
17 | 51 | <Message Importance="High" Text="=====================================================" /> |
18 | 52 | </Target> |
19 | 53 |
|
| 54 | + <Target Name="GenerateAssemblyInfo" AfterTargets="LogSelectedVersion" BeforeTargets="BeforeCompile"> |
| 55 | + <PropertyGroup> |
| 56 | + <_GeneratedAssemblyInfoFile Condition="'$(Language)' == 'C#'">$(IntermediateOutputPath)Versioning.Common.GeneratedAssemblyInfo.cs</_GeneratedAssemblyInfoFile> |
| 57 | + <_GeneratedAssemblyInfoFile Condition="'$(Language)' == 'VB'">$(IntermediateOutputPath)Versioning.Common.GeneratedAssemblyInfo.vb</_GeneratedAssemblyInfoFile> |
| 58 | + <_GeneratedAssemblyInfoFile Condition="'$(Language)' == 'F#'">$(IntermediateOutputPath)Versioning.Common.GeneratedAssemblyInfo.fs</_GeneratedAssemblyInfoFile> |
| 59 | + </PropertyGroup> |
| 60 | + |
| 61 | + <ItemGroup> |
| 62 | + <Compile Include="$(_GeneratedAssemblyInfoFile)" /> |
| 63 | + </ItemGroup> |
| 64 | + |
| 65 | + <!-- C# Lines --> |
| 66 | + <ItemGroup Condition="'$(Language)' == 'C#'"> |
| 67 | + <_AssemblyInfoLines Include="using System.Reflection;" /> |
| 68 | + <_AssemblyInfoLines Include="[assembly: AssemblyVersion("$(AssemblyVersion)")]" /> |
| 69 | + <_AssemblyInfoLines Include="[assembly: AssemblyFileVersion("$(FileVersion)")]" /> |
| 70 | + <_AssemblyInfoLines Condition="'$(TargetFramework)' != 'net35'" Include="[assembly: AssemblyInformationalVersion("$(InformationalVersion)")]" /> |
| 71 | + </ItemGroup> |
| 72 | + |
| 73 | + <!-- VB.NET Lines --> |
| 74 | + <ItemGroup Condition="'$(Language)' == 'VB'"> |
| 75 | + <_AssemblyInfoLines Include="Imports System.Reflection" /> |
| 76 | + <_AssemblyInfoLines Include="<Assembly: AssemblyVersion("$(AssemblyVersion)")>" /> |
| 77 | + <_AssemblyInfoLines Include="<Assembly: AssemblyFileVersion("$(FileVersion)")>" /> |
| 78 | + <_AssemblyInfoLines Condition="'$(TargetFramework)' != 'net35'" Include="<Assembly: AssemblyInformationalVersion("$(InformationalVersion)")>" /> |
| 79 | + </ItemGroup> |
| 80 | + |
| 81 | + <ItemGroup Condition="'$(Language)' == 'F#'"> |
| 82 | + <_AssemblyInfoLines Include="open System.Reflection" /> |
| 83 | + <_AssemblyInfoLines Include="[<assembly: AssemblyVersion("$(AssemblyVersion)")>]" /> |
| 84 | + <_AssemblyInfoLines Include="[<assembly: AssemblyFileVersion("$(FileVersion)")>]" /> |
| 85 | + <_AssemblyInfoLines Condition="'$(TargetFramework)' != 'net35'" Include="[<assembly: AssemblyInformationalVersion("$(InformationalVersion)")>]" /> |
| 86 | + <_AssemblyInfoLines Include="do ()" /> |
| 87 | + </ItemGroup> |
| 88 | + |
| 89 | + <WriteLinesToFile |
| 90 | + File="$(_GeneratedAssemblyInfoFile)" |
| 91 | + Overwrite="true" |
| 92 | + Lines="@(_AssemblyInfoLines)" /> |
| 93 | + </Target> |
| 94 | + |
20 | 95 | </Project> |
0 commit comments