Skip to content

Commit

Permalink
Auto-generate F# program file (#1664)
Browse files Browse the repository at this point in the history
* Auto-generate F# program file

* Update Microsoft.NET.Test.Sdk.targets

* Update Microsoft.NET.Test.Sdk.targets

* Don't generate a Program.fs if one already exists.
  • Loading branch information
saul authored and mayankbansal018 committed Jul 10, 2018
1 parent a4c5506 commit 0c0270a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/package/nuspec/Microsoft.NET.Test.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
Condition="'$(GenerateProgramFile)' == 'true'" />

<Target Name="CoreGenerateProgramFile"
Condition="'$(Language)'=='VB' or '$(Language)'=='C#'"
Condition="'$(Language)'=='VB' or '$(Language)'=='C#' or '$(Language)'=='F#'"
Inputs="$(MSBuildAllProjects)"
Outputs="$(GeneratedProgramFile)">

Expand All @@ -76,15 +76,31 @@
<Line Include="End Sub"/>
<Line Include="End Module"/>
</ItemGroup>

<ItemGroup Condition="'$(Language)'=='F#'">
<Line Include="// &lt;auto-generated&gt; This file has been auto generated. &lt;/auto-generated&gt;"/>
<Line Include="module AutoGeneratedProgram"/>
<Line Include="[&lt;EntryPoint&gt;]"/>
<Line Include="[&lt;Microsoft.VisualStudio.TestPlatform.TestSDKAutoGeneratedCode&gt;]"/>
<Line Include="let main _ = 0"/>
</ItemGroup>

<WriteLinesToFile
File="$(GeneratedProgramFile)" Lines="@(Line)" Overwrite="true" Encoding="Unicode">
</WriteLinesToFile>

<!--
Compile Include the generated Program File
-->
<ItemGroup>
<ItemGroup Condition="'$(Language)'!='F#'">
<Compile Include="$(GeneratedProgramFile)"/>
</ItemGroup>

<ItemGroup Condition="'$(Language)'=='F#'">
<ProgramCompiles Include="@(Compile)" Condition=" '%(Identity)' == 'Program.fs' "/>
<CompileAfter Include="$(GeneratedProgramFile)" Condition="@(ProgramCompiles-&gt;Count()) == 0"/>
</ItemGroup>

<Warning Condition=" @(ProgramCompiles-&gt;Count()) != 0 " Text="A 'Program.fs' file can be automatically generated for F# .NET Core test projects. To fix this warning, either delete the file from the project, or set the &lt;GenerateProgramFile&gt; property to 'false'." />
</Target>
</Project>

0 comments on commit 0c0270a

Please sign in to comment.