Skip to content
This repository was archived by the owner on Jan 8, 2019. It is now read-only.

Commit 9392487

Browse files
committed
use FscTask instead of dotnet-compile-fsc
- replace project.json with csproj - the FscTask assembly path is read from property $(FscTaskAssemblyPath) - the $(FscTaskAssemblyPath) property is set in a .prop file inside compiler package - use $(FscToolPath) and $(FscToolExe), but run these with dotnet add examples of fsproj with new sdk (who use fsctask) use rc package with Framework-dependent deployment of fsc add property $(DontRunFscWithDotnet) to not run fsc tool with dotnet exec use new compiler package, the manifest is not required anymore (is near fsc.dll)
1 parent be66f60 commit 9392487

File tree

15 files changed

+206
-36
lines changed

15 files changed

+206
-36
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,4 @@ _Pvt_Extensions
240240
test/test-dotnet-new/
241241

242242
.dotnetsdk
243+
src/FSharp.NET.Sdk/NuGet.Config

dev/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
log*.txt

dev/preview4_fsctask/NuGet.Config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="fsharpsdk-local" value="..\..\src\FSharp.NET.Sdk\bin\Debug" />
5+
</packageSources>
6+
</configuration>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Learn more about F# at http://fsharp.org
2+
3+
open System
4+
5+
[<EntryPoint>]
6+
let main argv =
7+
printfn "Hello World from F#!"
8+
0 // return an integer exit code
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk" ToolsVersion="15.0">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp1.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<Compile Include="Program.fs" />
10+
<EmbeddedResource Include="**\*.resx" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
15+
<PackageReference Include="Microsoft.FSharp.Core.netcore" Version="1.0.0-alpha-161023" />
16+
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.0-char-*">
17+
<PrivateAssets>All</PrivateAssets>
18+
</PackageReference>
19+
</ItemGroup>
20+
21+
</Project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Learn more about F# at http://fsharp.org
2+
3+
open System
4+
5+
[<EntryPoint>]
6+
let main argv =
7+
printfn "Hello World from F#!"
8+
0 // return an integer exit code
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk" ToolsVersion="15.0">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net451</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<Compile Include="Program.fs" />
10+
<EmbeddedResource Include="**\*.resx" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="FSharp.Core" Version="4.0.1.7-alpha" />
15+
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.0-char-*">
16+
<PrivateAssets>All</PrivateAssets>
17+
</PackageReference>
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System;
2+
3+
class Program
4+
{
5+
static void Main(string[] args)
6+
{
7+
Console.WriteLine("Hello World!");
8+
}
9+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp1.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<Compile Include="**\*.cs" />
10+
<EmbeddedResource Include="**\*.resx" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
15+
</ItemGroup>
16+
17+
</Project>

dev/preview4_fsctask/lib/Library.fs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace Library
2+
3+
module Say =
4+
let hello name =
5+
printfn "Hello %s" name

dev/preview4_fsctask/lib/lib.fsproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk" ToolsVersion="15.0">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard1.6</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<Compile Include="Library.fs" />
9+
<EmbeddedResource Include="**\*.resx" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="NETStandard.Library" Version="1.6" />
14+
<PackageReference Include="Microsoft.FSharp.Core.netcore" Version="1.0.0-alpha-161023" />
15+
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.0-char-*">
16+
<PrivateAssets>All</PrivateAssets>
17+
</PackageReference>
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace Library
2+
3+
module Say =
4+
let hello name =
5+
printfn "Hello %s" name
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk" ToolsVersion="15.0">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<Compile Include="Library.fs" />
9+
<EmbeddedResource Include="**\*.resx" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="NETStandard.Library" Version="1.6" Condition=" '$(TargetFramework)' == 'netstandard1.6' " />
14+
<PackageReference Include="FSharp.Core" Version="4.0.1.7-alpha" />
15+
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.0-char-*">
16+
<PrivateAssets>All</PrivateAssets>
17+
</PackageReference>
18+
</ItemGroup>
19+
20+
</Project>

src/FSharp.NET.Sdk/FSharp.NET.Sdk.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,10 @@
3737
</Content>
3838
</ItemGroup>
3939

40+
<ItemGroup>
41+
<PackageReference Include="Microsoft.FSharp.Compiler.Sdk.netcore" Version="1.0.0-rc-170113">
42+
<PrivateAssets>Compile</PrivateAssets>
43+
</PackageReference>
44+
</ItemGroup>
45+
4046
</Project>

src/FSharp.NET.Sdk/build/FSharp.NET.Core.Sdk.targets

Lines changed: 59 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ WARNING: You CAN MODIFY this file, doesnt matter if you are not knowledgeable a
1010
1111
This file defines the steps in the standard build process specific for F# .NET projects.
1212
For example, it contains the step that actually calls the F# compiler.
13-
Flow is: msbuild -> CoreCompile -> dotnet compile-fsc -> fsc
13+
Flow is: msbuild -> CoreCompile -> FscTask -> fsc compiler
1414
The remainder of the build process is defined in Microsoft.Common.targets, but is not imported by
1515
this file.
1616
@@ -19,6 +19,9 @@ this file.
1919

2020
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2121

22+
<!--TODO error if FscTaskAssemblyPath is not defined-->
23+
<UsingTask TaskName="Fsc" AssemblyFile="$(FscTaskAssemblyPath)" />
24+
2225
<PropertyGroup>
2326
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
2427
<DefaultLanguageSourceExtension>.fs</DefaultLanguageSourceExtension>
@@ -88,42 +91,24 @@ this file.
8891
Returns="@(FscCommandLineArgs)"
8992
DependsOnTargets="$(CoreCompileDependsOn)"
9093
>
91-
<PropertyGroup>
92-
<_IntermediateOutputPathFull>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)'))</_IntermediateOutputPathFull>
93-
<_TargetFrameworkDefine>$(TargetFramework.Replace('.','_').ToUpper())</_TargetFrameworkDefine>
94-
</PropertyGroup>
95-
96-
<!--STEP1 Create the dotnet-compile-fsc response file lines-->
97-
<ItemGroup>
98-
<DotnetCompileFscResponseLines Include="--temp-output:$(_IntermediateOutputPathFull)" />
99-
<DotnetCompileFscResponseLines Include="--out:$(_IntermediateOutputPathFull)$(TargetName)$(TargetExt)" />
100-
101-
<DotnetCompileFscResponseLines Condition="'$(OutputType)' == 'Exe'" Include="--emit-entry-point:True" />
102-
<DotnetCompileFscResponseLines Condition="'$(GenerateDocumentationFile)' == 'true'" Include="--generate-xml-documentation:True" />
103-
104-
<!--DOC: $(DefineConstants) is a string separated by ';' so let's convert to array-->
105-
<DefineConstantsArray Include="$(DefineConstants.Split(';'))" />
106-
<DotnetCompileFscResponseLines Include="@(DefineConstantsArray -> '--define:%(Identity)')" />
10794

108-
<!--HACK: for compatibility with previous sdk-->
109-
<DotnetCompileFscResponseLines Include="--define:$(_TargetFrameworkDefine)" />
110-
111-
<DotnetCompileFscResponseLines Include="--optimize:$(Optimize)" />
112-
<DotnetCompileFscResponseLines Include="--debug-type:$(DebugType)" />
113-
<DotnetCompileFscResponseLines Include="--output-name:$(TargetName)" />
114-
<DotnetCompileFscResponseLines Include="--file-version:1.0.0.0" />
115-
<DotnetCompileFscResponseLines Include="--version:1.0.0.0" />
116-
<DotnetCompileFscResponseLines Include="--informational-version:1.0.0" />
117-
<DotnetCompileFscResponseLines Include="--target-framework:$(NuGetTargetMoniker)" />
95+
<PropertyGroup>
96+
<TargetProfile Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' " >mscorlib</TargetProfile>
97+
<TargetProfile Condition=" '$(TargetFrameworkIdentifier)' != '.NETFramework' " >netcore</TargetProfile>
11898

119-
<DotnetCompileFscResponseLines Include="@(ReferencePath -> '--reference:%(FullPath)')" />
99+
<_OtherFscFlags>--simpleresolution --nocopyfsharpcore</_OtherFscFlags>
100+
</PropertyGroup>
120101

121-
<DotnetCompileFscResponseLines Include="@(Compile -> '%(FullPath)')" />
122-
</ItemGroup>
102+
<PropertyGroup Condition=" '$(DontRunFscWithDotnet)' == '' ">
103+
<_FscTask_FscToolExe>dotnet.exe</_FscTask_FscToolExe>
104+
<_FscTask_FscToolPath>$(MSBuildExtensionsPath)/../..</_FscTask_FscToolPath>
105+
<_FscTask_DotnetFscCompilerPath> "$(FscToolPath)/$(FscToolExe)"</_FscTask_DotnetFscCompilerPath>
106+
</PropertyGroup>
123107

124-
<!--STEP2 Create the dotnet-compile-fsc response file-->
125-
<PropertyGroup>
126-
<DotnetCompileFscResponseFilePath>$(_IntermediateOutputPathFull)dotnet-compile.rsp</DotnetCompileFscResponseFilePath>
108+
<PropertyGroup Condition=" '$(DontRunFscWithDotnet)' != '' "> <!-- check fsc extension? -->
109+
<_FscTask_FscToolExe>$(FscToolExe)</_FscTask_FscToolExe>
110+
<_FscTask_FscToolPath>$(FscToolPath)</_FscTask_FscToolPath>
111+
<_FscTask_DotnetFscCompilerPath></_FscTask_DotnetFscCompilerPath>
127112

128113
<!-- ref https://github.com/Microsoft/msbuild/issues/1669
129114
the dotnet in PATH can be different from the dotnet who run msbuild,
@@ -132,10 +117,48 @@ this file.
132117
<_DotNetHostExecutableName Condition=" '$(OS)' == 'Windows_NT' ">$(_DotNetHostExecutableName).exe</_DotNetHostExecutableName>
133118
</PropertyGroup>
134119

135-
<WriteLinesToFile File="$(DotnetCompileFscResponseFilePath)" Lines="@(DotnetCompileFscResponseLines)" Overwrite="True" />
120+
<Fsc BaseAddress="$(BaseAddress)"
121+
CodePage="$(CodePage)"
122+
DebugSymbols="$(DebugSymbols)"
123+
DebugType="$(DebugType)"
124+
DefineConstants="$(DefineConstants)"
125+
DisabledWarnings="$(NoWarn)"
126+
DocumentationFile="$(DocumentationFile)"
127+
EmbedAllSources="$(EmbedAllSources)"
128+
Embed="$(Embed)"
129+
GenerateInterfaceFile="$(GenerateInterfaceFile)"
130+
KeyFile="$(KeyOriginatorFile)"
131+
LCID="$(LCID)"
132+
NoFramework="true"
133+
Optimize="$(Optimize)"
134+
OtherFlags="$(_OtherFscFlags) $(OtherFlags)"
135+
OutputAssembly="@(IntermediateAssembly)"
136+
PdbFile="$(PdbFile)"
137+
Platform="$(PlatformTarget)"
138+
Prefer32Bit="$(Actual32Bit)"
139+
References="@(ReferencePath)"
140+
ReferencePath="$(ReferencePath)"
141+
Resources="@(_CoreCompileResourceInputs);@(CompiledLicenseFile);@(AdditionalEmbeddedResource)"
142+
SourceLink="$(SourceLink)"
143+
Sources="@(CompileBefore -> '%(FullPath)');@(Compile -> '%(FullPath)');@(CompileAfter -> '%(FullPath)')"
144+
Tailcalls="$(Tailcalls)"
145+
TargetType="$(OutputType)"
146+
ToolExe="$(_FscTask_FscToolExe)"
147+
ToolPath="$(_FscTask_FscToolPath)"
148+
TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
149+
Utf8Output="$(Utf8Output)"
150+
VersionFile="$(VersionFile)"
151+
VisualStudioStyleErrors="$(VisualStudioStyleErrors)"
152+
WarningLevel="$(WarningLevel)"
153+
WarningsAsErrors="$(WarningsAsErrors)"
154+
Win32ManifestFile="$(Win32Manifest)"
155+
Win32ResourceFile="$(Win32Resource)"
156+
SubsystemVersion="$(SubsystemVersion)"
157+
HighEntropyVA="$(HighEntropyVA)"
158+
TargetProfile="$(TargetProfile)"
159+
DotnetFscCompilerPath="$(_FscTask_DotnetFscCompilerPath)"
160+
/>
136161

137-
<!--STEP3 HACK: invoke dotnet-compile-fsc because already works-->
138-
<Exec Command='"$(_DotNetHostExecutableName)" compile-fsc "@$(DotnetCompileFscResponseFilePath)" ' />
139162
</Target>
140163

141164
<!--End Required Task by .Common.target-->

0 commit comments

Comments
 (0)