Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

73 lines (62 sloc) 3.182 kb
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="GitDescribeToVersion" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Describe ParameterType="System.String" Required="true" />
<Version ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Using Namespace="System.Reflection" />
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
var m = Regex.Match(Describe, @"^([a-zA-Z]*)(?'Major'\d+)\.(?'Minor'\d+)(-(?'Revision'\d+))?");
if (m.Success)
{
var major = m.Groups["Major"].Value;
var minor = m.Groups["Minor"].Value;
var gr = m.Groups["Revision"];
var revision = gr.Success ? gr.Value : "0";
Version = major + "." + minor + "." + revision + ".0";
}
]]>
</Code>
</Task>
</UsingTask>
<PropertyGroup>
<ShouldGenerate Condition="$(IsReleaseBuild) == 'true'">true</ShouldGenerate>
<GeneratedAssemblyInfo>obj\$(Configuration)\__versioninfo.cs</GeneratedAssemblyInfo>
<GitDescribe>obj\$(Configuration)\__gitinfo.cs</GitDescribe>
<GitTagMatch Condition=" '$(GitTagMatch)' == '' ">*</GitTagMatch>
</PropertyGroup>
<PropertyGroup Condition="$(ShouldGenerate) == 'true'">
<AssemblyOriginatorKeyFile></AssemblyOriginatorKeyFile>
</PropertyGroup>
<Target Name="CreateAssemblyInfoFromGit" DependsOnTargets="CreateRandomFileNames" Condition="$(ShouldGenerate) == 'true'">
<MakeDir Directories="obj\$(Configuration)" ContinueOnError="true" />
<Exec Command="git describe --tags --match $(GitTagMatch) > $(GitDescribe)" />
<ReadLinesFromFile File="$(GitDescribe)">
<Output TaskParameter="Lines" PropertyName="_Describe"/>
</ReadLinesFromFile>
<GitDescribeToVersion Describe="$(_Describe)">
<Output TaskParameter="Version" PropertyName="_AssemblyVersion"/>
</GitDescribeToVersion>
<Delete Files="$(GeneratedAssemblyInfo)" />
<WriteLinesToFile File="$(GeneratedAssemblyInfo)" Lines="
[assembly: System.Reflection.AssemblyKeyName(&quot;enyim&quot;)]
[assembly: System.Reflection.AssemblyFileVersion(&quot;$(_AssemblyVersion)&quot;)]
[assembly: System.Reflection.AssemblyTitle(&quot;$(_Describe)&quot;)]
[assembly: System.Reflection.AssemblyVersion(&quot;$(_AssemblyVersion)&quot;)]" />
</Target>
<Target Name="CreateStaticAssemblyInfo" Condition="$(ShouldGenerate) != 'true' And !Exists('$(GeneratedAssemblyInfo)')">
<MakeDir Directories="obj\$(Configuration)" ContinueOnError="true" />
<WriteLinesToFile File="$(GeneratedAssemblyInfo)" Lines="
[assembly: System.Reflection.AssemblyTitle(&quot;2.4.6-custom&quot;)]
[assembly: System.Reflection.AssemblyFileVersion(&quot;2.4.6.0&quot;)]
[assembly: System.Reflection.AssemblyVersion(&quot;2.4.6.0&quot;)]" />
</Target>
<Target Name="BeforeBuild" DependsOnTargets="CreateAssemblyInfoFromGit;CreateStaticAssemblyInfo">
<CreateItem Include="$(GeneratedAssemblyInfo)">
<Output TaskParameter="Include" ItemName="Compile"/>
</CreateItem>
</Target>
</Project>
Jump to Line
Something went wrong with that request. Please try again.