|
| 1 | +<Project> |
| 2 | + |
| 3 | + <Target Name="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 | + <NoWarn Condition="'$(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 | + <_UseWriteCodeFragmentHack Condition="'$(OS)' == 'Unix' and '$(Language)' == 'F#'">true</_UseWriteCodeFragmentHack> |
| 15 | + </PropertyGroup> |
| 16 | + |
| 17 | + <ItemGroup> |
| 18 | + <_AssemblyVersionAttributes Include="System.Reflection.AssemblyCompanyAttribute"> |
| 19 | + <_Parameter1>Microsoft Corporation</_Parameter1> |
| 20 | + </_AssemblyVersionAttributes> |
| 21 | + <_AssemblyVersionAttributes Include="System.Reflection.AssemblyCopyrightAttribute"> |
| 22 | + <_Parameter1>© Microsoft Corporation. All Rights Reserved.</_Parameter1> |
| 23 | + </_AssemblyVersionAttributes> |
| 24 | + <_AssemblyVersionAttributes Include="System.Reflection.AssemblyDescriptionAttribute"> |
| 25 | + <_Parameter1>$(AssemblyName)</_Parameter1> |
| 26 | + </_AssemblyVersionAttributes> |
| 27 | + <_AssemblyVersionAttributes Include="System.Reflection.AssemblyFileVersionAttribute"> |
| 28 | + <_Parameter1>$(Build_FileVersion)</_Parameter1> |
| 29 | + </_AssemblyVersionAttributes> |
| 30 | + <_AssemblyVersionAttributes Include="System.Reflection.AssemblyInformationalVersionAttribute"> |
| 31 | + <_Parameter1>$(MicroBuildAssemblyVersion). Commit Hash: $(GitHeadSha).</_Parameter1> |
| 32 | + </_AssemblyVersionAttributes> |
| 33 | + <_AssemblyVersionAttributes Include="System.Reflection.AssemblyProductAttribute"> |
| 34 | + <_Parameter1>Microsoft® F#</_Parameter1> |
| 35 | + </_AssemblyVersionAttributes> |
| 36 | + <_AssemblyVersionAttributes Include="System.Reflection.AssemblyTitleAttribute"> |
| 37 | + <_Parameter1>$(AssemblyName)</_Parameter1> |
| 38 | + </_AssemblyVersionAttributes> |
| 39 | + <_AssemblyVersionAttributes Include="System.Reflection.AssemblyVersionAttribute"> |
| 40 | + <_Parameter1>$(MicroBuildAssemblyVersion)</_Parameter1> |
| 41 | + </_AssemblyVersionAttributes> |
| 42 | + </ItemGroup> |
| 43 | + |
| 44 | + <ItemGroup Condition="'$(_UseWriteCodeFragmentHack)' == 'true'"> |
| 45 | + <_LinesToWrite Include="// <auto-generated>" /> |
| 46 | + <_LinesToWrite Include="namespace FSharp" /> |
| 47 | + <_LinesToWrite Include="open System" /> |
| 48 | + <_LinesToWrite Include="open System.Reflection" /> |
| 49 | + <_LinesToWrite Include="[<assembly: %(_AssemblyVersionAttributes.Identity)("%(_AssemblyVersionAttributes._Parameter1)")>]" /> |
| 50 | + <_LinesToWrite Include="do()" /> |
| 51 | + |
| 52 | + <Compile Include="$(GeneratedFSharpAssemblyVersionFile)" Condition="'$(Language)' != 'F#' or '$(AssemblyName)' == 'FSharp.Core'" /> |
| 53 | + <CompileBefore Include="$(GeneratedFSharpAssemblyVersionFile)" Condition="'$(Language)' == 'F#' and '$(AssemblyName)' != 'FSharp.Core'" /> |
| 54 | + <FileWrites Include="$(GeneratedFSharpAssemblyVersionFile)" /> |
| 55 | + </ItemGroup> |
| 56 | + |
| 57 | + <WriteCodeFragment AssemblyAttributes="@(_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 | + <Output TaskParameter="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 | + <Output TaskParameter="OutputFile" ItemName="CompileBefore" Condition="'$(Language)' == 'F#' and '$(AssemblyName)' != 'FSharp.Core'" /> |
| 65 | + <Output TaskParameter="OutputFile" ItemName="FileWrites" /> |
| 66 | + </WriteCodeFragment> |
| 67 | + |
| 68 | + <WriteLinesToFile File="$(GeneratedFSharpAssemblyVersionFile)" |
| 69 | + Lines="@(_LinesToWrite)" |
| 70 | + Overwrite="true" |
| 71 | + Encoding="Unicode" |
| 72 | + Condition="'$(_UseWriteCodeFragmentHack)' == 'true' and !Exists('$(GeneratedFSharpAssemblyVersionFile)')" /> |
| 73 | + |
| 74 | + </Target> |
| 75 | + |
| 76 | +</Project> |
0 commit comments