diff --git a/src/FSharp.Build/Microsoft.FSharp.Targets b/src/FSharp.Build/Microsoft.FSharp.Targets
index 3e5e347d12f..26999e6a646 100644
--- a/src/FSharp.Build/Microsoft.FSharp.Targets
+++ b/src/FSharp.Build/Microsoft.FSharp.Targets
@@ -235,7 +235,7 @@ this file.
-
+
@@ -247,7 +247,7 @@ this file.
-
+
@@ -255,6 +255,27 @@ this file.
+
+
+
+ <__Sources Remove="@(__Sources)" />
+ <__Sources Include="@(Compile->WithMetadataValue('CompileOrder', 'CompileFirst'))" />
+ <__Sources Include="@(CompileBefore)" />
+ <__Sources Include="@(Compile->WithMetadataValue('CompileOrder', 'CompileBefore'))" />
+ <__Sources Include="@(Compile->WithMetadataValue('CompileOrder', ''))" />
+ <__Sources Include="@(Compile->WithMetadataValue('CompileOrder', 'CompileAfter'))" />
+ <__Sources Include="@(CompileAfter)" />
+ <__Sources Include="@(Compile->WithMetadataValue('CompileOrder', 'CompileLast'))" />
+
+
+
+
+
+
+
+
+
+
+
--simpleresolution $(OtherFlags)
@@ -371,7 +393,7 @@ this file.
Resources="@(ActualEmbeddedResources)"
SkipCompilerExecution="$(SkipCompilerExecution)"
SourceLink="$(SourceLink)"
- Sources="@(CompileBefore);@(Compile);@(CompileAfter)"
+ Sources="@(Compile)"
SubsystemVersion="$(SubsystemVersion)"
Tailcalls="$(Tailcalls)"
TargetType="$(OutputType)"
@@ -434,7 +456,7 @@ this file.
Overwrite="true"/>
-
+ CompileBefore
<_FsGeneratedTfmAttributesSource Include="$(TargetFrameworkMonikerAssemblyAttributesPath)" />
diff --git a/src/FSharp.Core/FSharp.Core.fsproj b/src/FSharp.Core/FSharp.Core.fsproj
index 0f9fe0fb624..f3e27acaee6 100644
--- a/src/FSharp.Core/FSharp.Core.fsproj
+++ b/src/FSharp.Core/FSharp.Core.fsproj
@@ -61,12 +61,25 @@
+
+
+
Primitives/prim-types-prelude.fsi
Primitives/prim-types-prelude.fs
+
+
+
+ Primitives/prim-types-prelude.fsi
+
+
+ Primitives/prim-types-prelude.fs
+
+
+
Primitives/prim-types.fsi
diff --git a/tests/fsharp/SDKTests/tests/CompileOrder - BeforeAndAfter.proj b/tests/fsharp/SDKTests/tests/CompileOrder - BeforeAndAfter.proj
new file mode 100644
index 00000000000..55134523861
--- /dev/null
+++ b/tests/fsharp/SDKTests/tests/CompileOrder - BeforeAndAfter.proj
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+ true
+ /Common7/IDE/CommonExtensions/Microsoft/FSharp/Tools/
+ fscAnyCpu.exe
+ _VsInstallRoot_/Common7/IDE/CommonExtensions/Microsoft/FSharp/Tools/
+
+ One;Two;Three;Four;Five;Six;Seven;Eight;Nine;Ten;Eleven;Twelve;Thirteen;Fourteen
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/fsharp/SDKTests/tests/ToolsTest.targets b/tests/fsharp/SDKTests/tests/ToolsTest.targets
index 7a4138e5eed..3e68a5af856 100644
--- a/tests/fsharp/SDKTests/tests/ToolsTest.targets
+++ b/tests/fsharp/SDKTests/tests/ToolsTest.targets
@@ -4,10 +4,11 @@
-
+
+
@@ -17,6 +18,8 @@
+
+