Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

106 lines (91 sloc) 4.24 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>
<UsingTask TaskName="GetRandomFileName" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Name ParameterType="System.String" Output="true" />
<Format ParameterType="System.String" Required="false"/>
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
<![CDATA[
var tmp = System.IO.Path.GetRandomFileName();
Name = String.IsNullOrEmpty(Format) ? tmp : String.Format(Format, tmp);
]]>
</Code>
</Task>
</UsingTask>
<PropertyGroup>
<ShouldGenerate Condition="$(IsReleaseBuild) == 'true'">true</ShouldGenerate>
</PropertyGroup>
<PropertyGroup Condition="$(ShouldGenerate) == 'true'">
<AssemblyOriginatorKeyFile></AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<GitTagMatch Condition=" '$(GitTagMatch)' == '' ">*</GitTagMatch>
</PropertyGroup>
<Target Name="CreateRandomFileNames">
<MakeDir Directories="obj\$(Configuration)" ContinueOnError="true" />
<GetRandomFileName Format="obj\$(Configuration)\{0}.cs">
<Output TaskParameter="Name" PropertyName="GeneratedAssemblyInfo" />
</GetRandomFileName>
<GetRandomFileName Format="obj\$(Configuration)\{0}.txt">
<Output TaskParameter="Name" PropertyName="GitDescribe" />
</GetRandomFileName>
</Target>
<Target Name="CreateAssemblyInfoFromGit" DependsOnTargets="CreateRandomFileNames" Condition="$(ShouldGenerate) == '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" DependsOnTargets="CreateRandomFileNames" Condition="$(ShouldGenerate) != 'true'">
<Delete Files="$(GeneratedAssemblyInfo)" />
<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="Cleanup">
<Delete Files="$(GeneratedAssemblyInfo)" Condition="'$(GeneratedAssemblyInfo)' != ''" ContinueOnError="true" />
<Delete Files="$(GitDescribe)" Condition="'$(GitDescribe)' != ''" ContinueOnError="true" />
</Target>
<Target Name="BeforeBuild" DependsOnTargets="CreateAssemblyInfoFromGit;CreateStaticAssemblyInfo">
<CreateItem Include="$(GeneratedAssemblyInfo)">
<Output TaskParameter="Include" ItemName="Compile"/>
</CreateItem>
</Target>
<Target Name="AfterBuild">
<CallTarget Targets="Cleanup" />
</Target>
</Project>
Jump to Line
Something went wrong with that request. Please try again.