|
| 1 | +<Project> |
| 2 | + |
| 3 | + <TargetName="GenerateAssemblyFileVersion" |
| 4 | +BeforeTargets="CoreCompile"> |
| 5 | + |
| 6 | + <PropertyGroup> |
| 7 | + <GeneratedFSharpAssemblyVersionFile>$(IntermediateOutputPath)$(MSBuildProjectName).AssemblyVersion$(DefaultLanguageSourceExtension)</GeneratedFSharpAssemblyVersionFile> |
| 8 | +<!-- 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.--> |
| 9 | + <NoWarnCondition="'$(Language)' == 'F#'">2003;$(NoWarn)</NoWarn> |
| 10 | + </PropertyGroup> |
| 11 | + |
| 12 | + <PropertyGroup> |
| 13 | +<!-- xbuild and older versions of msbuild don't have F# support for WriteCodeFragment--> |
| 14 | + <_UseWriteCodeFragmentHackCondition="'$(OS)' == 'Unix' and '$(Language)' == 'F#'">true</_UseWriteCodeFragmentHack> |
| 15 | + </PropertyGroup> |
| 16 | + |
| 17 | + <ItemGroup> |
| 18 | + <_AssemblyVersionAttributesInclude="System.Reflection.AssemblyCompanyAttribute"> |
| 19 | + <_Parameter1>Microsoft Corporation</_Parameter1> |
| 20 | + </_AssemblyVersionAttributes> |
| 21 | + <_AssemblyVersionAttributesInclude="System.Reflection.AssemblyCopyrightAttribute"> |
| 22 | + <_Parameter1>© Microsoft Corporation. All Rights Reserved.</_Parameter1> |
| 23 | + </_AssemblyVersionAttributes> |
| 24 | + <_AssemblyVersionAttributesInclude="System.Reflection.AssemblyDescriptionAttribute"> |
| 25 | + <_Parameter1>$(AssemblyName)</_Parameter1> |
| 26 | + </_AssemblyVersionAttributes> |
| 27 | + <_AssemblyVersionAttributesInclude="System.Reflection.AssemblyFileVersionAttribute"> |
| 28 | + <_Parameter1>$(Build_FileVersion)</_Parameter1> |
| 29 | + </_AssemblyVersionAttributes> |
| 30 | + <_AssemblyVersionAttributesInclude="System.Reflection.AssemblyInformationalVersionAttribute"> |
| 31 | + <_Parameter1>$(MicroBuildAssemblyVersion). Commit Hash: $(GitHeadSha).</_Parameter1> |
| 32 | + </_AssemblyVersionAttributes> |
| 33 | + <_AssemblyVersionAttributesInclude="System.Reflection.AssemblyProductAttribute"> |
| 34 | + <_Parameter1>Microsoft® F#</_Parameter1> |
| 35 | + </_AssemblyVersionAttributes> |
| 36 | + <_AssemblyVersionAttributesInclude="System.Reflection.AssemblyTitleAttribute"> |
| 37 | + <_Parameter1>$(AssemblyName)</_Parameter1> |
| 38 | + </_AssemblyVersionAttributes> |
| 39 | + <_AssemblyVersionAttributesInclude="System.Reflection.AssemblyVersionAttribute"> |
| 40 | + <_Parameter1>$(MicroBuildAssemblyVersion)</_Parameter1> |
| 41 | + </_AssemblyVersionAttributes> |
| 42 | + </ItemGroup> |
| 43 | + |
| 44 | + <ItemGroupCondition="'$(_UseWriteCodeFragmentHack)' == 'true'"> |
| 45 | + <_LinesToWriteInclude="//<auto-generated>" /> |
| 46 | + <_LinesToWriteInclude="namespace FSharp" /> |
| 47 | + <_LinesToWriteInclude="open System" /> |
| 48 | + <_LinesToWriteInclude="open System.Reflection" /> |
| 49 | + <_LinesToWriteInclude="[<assembly: %(_AssemblyVersionAttributes.Identity)("%(_AssemblyVersionAttributes._Parameter1)")>]" /> |
| 50 | + <_LinesToWriteInclude="do()" /> |
| 51 | + |
| 52 | + <CompileInclude="$(GeneratedFSharpAssemblyVersionFile)"Condition="'$(Language)' != 'F#' or '$(AssemblyName)' == 'FSharp.Core'" /> |
| 53 | + <CompileBeforeInclude="$(GeneratedFSharpAssemblyVersionFile)"Condition="'$(Language)' == 'F#' and '$(AssemblyName)' != 'FSharp.Core'" /> |
| 54 | + <FileWritesInclude="$(GeneratedFSharpAssemblyVersionFile)" /> |
| 55 | + </ItemGroup> |
| 56 | + |
| 57 | + <WriteCodeFragmentAssemblyAttributes="@(_AssemblyVersionAttributes)" |
| 58 | +Language="$(Language)" |
| 59 | +OutputFile="$(GeneratedFSharpAssemblyVersionFile)" |
| 60 | +Condition="'$(_UseWriteCodeFragmentHack)' != 'true'"> |
| 61 | +<!-- For FSharp.Core, assembly version must be inserted after all Core files, as it defines F# basic types (strings)--> |
| 62 | + <OutputTaskParameter="OutputFile"ItemName="Compile"Condition="'$(Language)' != 'F#' or '$(AssemblyName)' == 'FSharp.Core'" /> |
| 63 | +<!-- For other assemblies, this must be inserted before all source files, to keep exe's EntryPoints (if any) as the last source file--> |
| 64 | + <OutputTaskParameter="OutputFile"ItemName="CompileBefore"Condition="'$(Language)' == 'F#' and '$(AssemblyName)' != 'FSharp.Core'" /> |
| 65 | + <OutputTaskParameter="OutputFile"ItemName="FileWrites" /> |
| 66 | + </WriteCodeFragment> |
| 67 | + |
| 68 | + <WriteLinesToFileFile="$(GeneratedFSharpAssemblyVersionFile)" |
| 69 | +Lines="@(_LinesToWrite)" |
| 70 | +Overwrite="true" |
| 71 | +Encoding="Unicode" |
| 72 | +Condition="'$(_UseWriteCodeFragmentHack)' == 'true' and !Exists('$(GeneratedFSharpAssemblyVersionFile)')" /> |
| 73 | + |
| 74 | + </Target> |
| 75 | + |
| 76 | +</Project> |