117 строки
7.0 KiB
XML
117 строки
7.0 KiB
XML
<!--
|
|
****************************************************************************************************
|
|
Project global versioning targets.
|
|
****************************************************************************************************-->
|
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
|
|
<!-- Input parameters -->
|
|
|
|
<!-- NOTE: The VersionFileAttribute ItemGroup can be used to add assembly-level attributes to the generated version file, ex:
|
|
<VersionFileAttribute Include="[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2243:AttributeStringLiteralsShouldParseCorrectly", Justification = "Justification here")]" />
|
|
-->
|
|
|
|
<PropertyGroup>
|
|
<VersionFileGenerationEnabled Condition="'$(VersionFileGenerationEnabled)' == '' AND '$(MSBuildProjectExtension)' == '.csproj'">true</VersionFileGenerationEnabled>
|
|
<VersionFileGenerationEnabled Condition="'$(VersionFileGenerationEnabled)' == ''">false</VersionFileGenerationEnabled>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<VersionStartYear Condition="'$(VersionStartYear)' == ''">2019</VersionStartYear>
|
|
<VersionMajor Condition="'$(VersionMajor)' == ''">INVALID_VersionMajor</VersionMajor>
|
|
<VersionMinor Condition="'$(VersionMinor)' == ''">INVALID_VersionMinor</VersionMinor>
|
|
<VersionBuild Condition="'$(VersionBuild)' == '' OR '$(VersionBuild)' == '0'">$([MSBuild]::Add(1, $([MSBuild]::Subtract($([System.DateTime]::Now.Year), $(VersionStartYear)))))$([System.DateTime]::Now.ToString("MMdd"))</VersionBuild>
|
|
<VersionRevision Condition="'$(VersionRevision)' == ''">0</VersionRevision>
|
|
<VersionRelease Condition="'$(VersionRelease)' == ''">0</VersionRelease>
|
|
</PropertyGroup>
|
|
|
|
<!-- Comptued parameters -->
|
|
|
|
<PropertyGroup>
|
|
<AssemblyVersion>$(VersionMajor).$(VersionMinor).0.$(VersionRevision)</AssemblyVersion>
|
|
<AssemblyFileVersion>$(VersionMajor).$(VersionMinor).$(VersionBuild).$(VersionRevision)</AssemblyFileVersion>
|
|
<AssemblyInfoVersion Condition="'$(VersionRelease)' != ''">$(VersionMajor).$(VersionMinor).$(VersionRelease)-$(VersionBuild)</AssemblyInfoVersion>
|
|
<AssemblyInfoVersion Condition="'$(AssemblyInfoVersion)' == ''">$(AssemblyFileVersion)</AssemblyInfoVersion>
|
|
<AssemblyVersionFile>$(IntermediateOutputPath)$(MSBuildProjectName).version.cs</AssemblyVersionFile>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<NuGetPackageVersion Condition="'$(NuGetPackageVersion)' == ''">$(VersionMajor).$(VersionMinor).$(VersionRelease)</NuGetPackageVersion>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<SatelliteContractVersion Condition="'$(SatelliteContractVersion)' == ''">$(AssemblyVersion)</SatelliteContractVersion>
|
|
</PropertyGroup>
|
|
|
|
<ItemGroup Condition="'$(VersionFileGenerationEnabled)' == 'true'">
|
|
<Compile Include="$(AssemblyVersionFile)" />
|
|
</ItemGroup>
|
|
|
|
<ItemGroup>
|
|
<Clean Include="$(AssemblyVersionFile)" Condition="'$(MSBuildProjectExtension)' == '.csproj'"/>
|
|
</ItemGroup>
|
|
|
|
<PropertyGroup Condition="'$(VersionFileGenerationEnabled)' == 'true'">
|
|
<!-- Disable assembly version defined in CommonAssemblyInfo.cs file -->
|
|
<DefineConstants>$(DefineConstants);BUILD_GENERATED_VERSION</DefineConstants>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<!--Force a rebuild if this file is changed -->
|
|
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
|
</PropertyGroup>
|
|
|
|
<!--
|
|
==================================================================================================
|
|
GenerateVersionFile target: generates assembly attributes into a source file that is included
|
|
in the items to compile.
|
|
================================================================================================== -->
|
|
<PropertyGroup Condition="'$(VersionFileGenerationEnabled)' == 'true'">
|
|
<CompileDependsOn>GenerateVersionFile;$(CompileDependsOn)</CompileDependsOn>
|
|
<GenerateVersionFileDependsOn>ValidateVersionValues;ShouldGenerateVersionFile;GenerateVersionFileCore</GenerateVersionFileDependsOn>
|
|
</PropertyGroup>
|
|
<Target Name="GenerateVersionFile" DependsOnTargets="$(GenerateVersionFileDependsOn)" />
|
|
|
|
<Target Name="GenerateVersionFileCore" Condition="'$(ShouldGenerateVersionFile)' == 'true'">
|
|
<ItemGroup>
|
|
<LinesToWrite Include="// $(SourceFileCopyright)" Condition="'$(SourceFileCopyright)' != ''"/>
|
|
<LinesToWrite Include="// <auto-generated>" />
|
|
<LinesToWrite Include="// This code was generated by a tool." />
|
|
<LinesToWrite Include="// </auto-generated>" />
|
|
<LinesToWrite Include="[assembly: System.Reflection.AssemblyCompany("$(AssemblyCompany)")]" Condition="'$(AssemblyCompany)' != ''"/>
|
|
<LinesToWrite Include="[assembly: System.Reflection.AssemblyCopyright("$(AssemblyCopyright)")]" Condition="'$(AssemblyCopyright)' != ''"/>
|
|
<LinesToWrite Include="[assembly: System.Reflection.AssemblyVersion("$(AssemblyVersion)")]" Condition="'$(AssemblyVersion)' != ''"/>
|
|
<LinesToWrite Include="[assembly: System.Reflection.AssemblyFileVersion("$(AssemblyFileVersion)")]" Condition="'$(AssemblyFileVersion)' != ''"/>
|
|
<LinesToWrite Include="[assembly: System.Reflection.AssemblyInformationalVersion("$(AssemblyInfoVersion)")]" Condition="'$(AssemblyInfoVersion)' != ''" />
|
|
<LinesToWrite Include="[assembly: System.Resources.SatelliteContractVersionAttribute("$(SatelliteContractVersion)")]" Condition="'$(SatelliteContractVersion)' != ''"/>
|
|
<LinesToWrite Include="@(VersionFileAttribute)" Condition="'@(VersionFileAttribute)' != ''" />
|
|
</ItemGroup>
|
|
<WriteLinesToFile File="$(AssemblyVersionFile)" Lines="@(LinesToWrite)" Overwrite="true" Encoding="Unicode"/>
|
|
<Message Text="Assembly Version File: $(AssemblyVersionFile)" />
|
|
</Target>
|
|
|
|
<!--
|
|
==================================================================================================
|
|
ShouldGenerateVersionFile target: determines whether a version needs to be generated.
|
|
================================================================================================== -->
|
|
<Target Name="ShouldGenerateVersionFile">
|
|
<ReadLinesFromFile File="$(AssemblyVersionFile)" Condition="Exists('$(AssemblyVersionFile)')">
|
|
<Output ItemName="VersionText" TaskParameter="Lines"/>
|
|
</ReadLinesFromFile>
|
|
<PropertyGroup>
|
|
<VersionText>@(VersionText)</VersionText>
|
|
<ShouldGenerateVersionFile>!$(VersionText.Contains('$(AssemblyFileVersion)'))</ShouldGenerateVersionFile>
|
|
</PropertyGroup>
|
|
</Target>
|
|
|
|
<Target Name="ValidateVersionValues">
|
|
<!-- Throw if any of the version values is not int16 -->
|
|
<PropertyGroup>
|
|
<VersionMajor>$([System.Convert]::ToInt16('$(VersionMajor)'))</VersionMajor>
|
|
<VersionMinor>$([System.Convert]::ToInt16('$(VersionMinor)'))</VersionMinor>
|
|
<VersionBuild>$([System.Convert]::ToInt16('$(VersionBuild)'))</VersionBuild>
|
|
<VersionRevision>$([System.Convert]::ToInt16('$(VersionRevision)'))</VersionRevision>
|
|
</PropertyGroup>
|
|
</Target>
|
|
|
|
</Project>
|