-
Notifications
You must be signed in to change notification settings - Fork 803
/
Copy pathGenerateAssemblyAttributes.targets
97 lines (82 loc) · 5.38 KB
/
GenerateAssemblyAttributes.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<Project>
<Import Project="GitHash.props" />
<Target Name="GenerateAssemblyLevelAttributes"
BeforeTargets="CoreCompile">
<PropertyGroup>
<GeneratedFSharpAssemblyLevelAttributesFile>$(IntermediateOutputPath)$(MSBuildProjectName).AssemblyLevelAttributes$(DefaultLanguageSourceExtension)</GeneratedFSharpAssemblyLevelAttributesFile>
</PropertyGroup>
<WriteCodeFragment AssemblyAttributes="@(AssemblyLevelAttribute)"
Language="$(Language)"
OutputFile="$(GeneratedFSharpAssemblyLevelAttributesFile)"
Condition="'@(AssemblyLevelAttribute)' != ''">
<Output TaskParameter="OutputFile" ItemName="Compile" Condition="'$(Language)' != 'F#'" />
<Output TaskParameter="OutputFile" ItemName="CompileBefore" Condition="'$(Language)' == 'F#'" />
<Output TaskParameter="OutputFile" ItemName="FileWrites" />
</WriteCodeFragment>
</Target>
<Target Name="GenerateAssemblyFileVersion"
BeforeTargets="CoreCompile"
Condition="'$(Configuration)' != 'Proto'">
<PropertyGroup>
<GeneratedFSharpAssemblyVersionFile>$(IntermediateOutputPath)$(MSBuildProjectName).AssemblyVersion$(DefaultLanguageSourceExtension)</GeneratedFSharpAssemblyVersionFile>
<!-- AssemblyInformationalVersionAttribute issues a by-design warning if the value passed isn't of the form #.#.#.#, but we specifically want to suppress this to allow the commit hash to be embedded. -->
<NoWarn Condition="'$(Language)' == 'F#'">2003;$(NoWarn)</NoWarn>
</PropertyGroup>
<PropertyGroup>
<!-- xbuild and older versions of msbuild don't have F# support for WriteCodeFragment -->
<_UseWriteCodeFragmentHack Condition="'$(OS)' == 'Unix' and '$(Language)' == 'F#'">true</_UseWriteCodeFragmentHack>
</PropertyGroup>
<ItemGroup>
<_AssemblyVersionAttributes Include="System.Reflection.AssemblyCompanyAttribute">
<_Parameter1>Microsoft Corporation</_Parameter1>
</_AssemblyVersionAttributes>
<_AssemblyVersionAttributes Include="System.Reflection.AssemblyCopyrightAttribute">
<_Parameter1>© Microsoft Corporation. All Rights Reserved.</_Parameter1>
</_AssemblyVersionAttributes>
<_AssemblyVersionAttributes Include="System.Reflection.AssemblyDescriptionAttribute">
<_Parameter1>$(AssemblyName)</_Parameter1>
</_AssemblyVersionAttributes>
<_AssemblyVersionAttributes Include="System.Reflection.AssemblyFileVersionAttribute">
<_Parameter1>$(Build_FileVersion)</_Parameter1>
</_AssemblyVersionAttributes>
<_AssemblyVersionAttributes Include="System.Reflection.AssemblyInformationalVersionAttribute">
<_Parameter1>$(MicroBuildAssemblyVersion). Commit Hash: $(GitHeadSha).</_Parameter1>
</_AssemblyVersionAttributes>
<_AssemblyVersionAttributes Include="System.Reflection.AssemblyProductAttribute">
<_Parameter1>Microsoft® F#</_Parameter1>
</_AssemblyVersionAttributes>
<_AssemblyVersionAttributes Include="System.Reflection.AssemblyTitleAttribute">
<_Parameter1>$(AssemblyName)</_Parameter1>
</_AssemblyVersionAttributes>
<_AssemblyVersionAttributes Include="System.Reflection.AssemblyVersionAttribute">
<_Parameter1>$(MicroBuildAssemblyVersion)</_Parameter1>
</_AssemblyVersionAttributes>
</ItemGroup>
<WriteCodeFragment AssemblyAttributes="@(_AssemblyVersionAttributes)"
Language="$(Language)"
OutputFile="$(GeneratedFSharpAssemblyVersionFile)"
Condition="'$(_UseWriteCodeFragmentHack)' != 'true'">
<!-- For FSharp.Core, assembly version must be inserted after all Core files, as it defines F# basic types (strings) -->
<Output TaskParameter="OutputFile" ItemName="Compile" Condition="'$(Language)' != 'F#' or '$(AssemblyName)' == 'FSharp.Core'" />
<!-- For other assemblies, this must be inserted before all source files, to keep exe's EntryPoints (if any) as the last source file -->
<Output TaskParameter="OutputFile" ItemName="CompileBefore" Condition="'$(Language)' == 'F#' and '$(AssemblyName)' != 'FSharp.Core'" />
<Output TaskParameter="OutputFile" ItemName="FileWrites" />
</WriteCodeFragment>
<ItemGroup Condition="'$(_UseWriteCodeFragmentHack)' == 'true'">
<_LinesToWrite Include="// <auto-generated>" />
<_LinesToWrite Include="namespace FSharp" />
<_LinesToWrite Include="open System" />
<_LinesToWrite Include="open System.Reflection" />
<_LinesToWrite Include="[<assembly: %(_AssemblyVersionAttributes.Identity)("%(_AssemblyVersionAttributes._Parameter1)")>]" />
<_LinesToWrite Include="do()" />
<Compile Include="$(GeneratedFSharpAssemblyVersionFile)" Condition="'$(Language)' != 'F#' or '$(AssemblyName)' == 'FSharp.Core'" />
<CompileBefore Include="$(GeneratedFSharpAssemblyVersionFile)" Condition="'$(Language)' == 'F#' and '$(AssemblyName)' != 'FSharp.Core'" />
<FileWrites Include="$(GeneratedFSharpAssemblyVersionFile)" />
</ItemGroup>
<WriteLinesToFile File="$(GeneratedFSharpAssemblyVersionFile)"
Lines="@(_LinesToWrite)"
Overwrite="true"
Encoding="Unicode"
Condition="'$(_UseWriteCodeFragmentHack)' == 'true' and !Exists('$(GeneratedFSharpAssemblyVersionFile)')" />
</Target>
</Project>