Skip to content

Instantly share code, notes, and snippets.

@baronfel
Last active April 27, 2021 14:39
Show Gist options
  • Save baronfel/43faa9e85178f7a2abb3a579e942587d to your computer and use it in GitHub Desktop.
Save baronfel/43faa9e85178f7a2abb3a579e942587d to your computer and use it in GitHub Desktop.
Build target for seamless signature file includes
<Project>
<PropertyGroup>
<!-- Provide an escape hatch/opt-in to this feature -->
<AutoIncludeExistingSignatures Condition="$(AutoIncludeExistingSignatures) == '' " >false</AutoIncludeExistingSignatures>
</PropertyGroup>
<Target Name="CollectFSharpSourcesAndSignatures" BeforeTargets="CoreCompile" Condition="$(AutoIncludeExistingSignatures)">
<ItemGroup>
<!-- Cache the current set of compile options -->
<_Sources Include="@(Compile)" />
<!-- clear out the Compile order because we need to insert the sigs before their associated source files -->
<Compile Remove="@(Compile)" />
<!-- N.B: the %(<array name>) syntax is a way of saying 'iterate over the collection and do X for each member of the collection' -->
<!-- Include X.fsi if X.fsi exists. -->
<Compile Include="$([System.IO.Path]::ChangeExtension(%(_Sources.Identity), &quot;fsi&quot;))" Condition="$([System.IO.File]::Exists($([System.IO.Path]::ChangeExtension(%(_Sources.Identity), &quot;fsi&quot;))))" />
<!-- but don't forget to also include X.fs -->
<Compile Include="%(_Sources.Identity)" />
</ItemGroup>
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment