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

Commit

Permalink
use FscTask instead of dotnet-compile-fsc
Browse files Browse the repository at this point in the history
- 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)
  • Loading branch information
enricosada committed Feb 15, 2017
1 parent be66f60 commit 9392487
Show file tree
Hide file tree
Showing 15 changed files with 206 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,4 @@ _Pvt_Extensions
test/test-dotnet-new/

.dotnetsdk
src/FSharp.NET.Sdk/NuGet.Config
1 change: 1 addition & 0 deletions dev/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
log*.txt
6 changes: 6 additions & 0 deletions dev/preview4_fsctask/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="fsharpsdk-local" value="..\..\src\FSharp.NET.Sdk\bin\Debug" />
</packageSources>
</configuration>
8 changes: 8 additions & 0 deletions dev/preview4_fsctask/console/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Learn more about F# at http://fsharp.org

open System

[<EntryPoint>]
let main argv =
printfn "Hello World from F#!"
0 // return an integer exit code
21 changes: 21 additions & 0 deletions dev/preview4_fsctask/console/console.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk" ToolsVersion="15.0">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.fs" />
<EmbeddedResource Include="**\*.resx" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
<PackageReference Include="Microsoft.FSharp.Core.netcore" Version="1.0.0-alpha-161023" />
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.0-char-*">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions dev/preview4_fsctask/console451/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Learn more about F# at http://fsharp.org

open System

[<EntryPoint>]
let main argv =
printfn "Hello World from F#!"
0 // return an integer exit code
20 changes: 20 additions & 0 deletions dev/preview4_fsctask/console451/console451.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk" ToolsVersion="15.0">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net451</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.fs" />
<EmbeddedResource Include="**\*.resx" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FSharp.Core" Version="4.0.1.7-alpha" />
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.0-char-*">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions dev/preview4_fsctask/consolecs/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
17 changes: 17 additions & 0 deletions dev/preview4_fsctask/consolecs/consolecs.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="**\*.cs" />
<EmbeddedResource Include="**\*.resx" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
</ItemGroup>

</Project>
5 changes: 5 additions & 0 deletions dev/preview4_fsctask/lib/Library.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace Library

module Say =
let hello name =
printfn "Hello %s" name
20 changes: 20 additions & 0 deletions dev/preview4_fsctask/lib/lib.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk" ToolsVersion="15.0">

<PropertyGroup>
<TargetFramework>netstandard1.6</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="Library.fs" />
<EmbeddedResource Include="**\*.resx" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NETStandard.Library" Version="1.6" />
<PackageReference Include="Microsoft.FSharp.Core.netcore" Version="1.0.0-alpha-161023" />
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.0-char-*">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>
5 changes: 5 additions & 0 deletions dev/preview4_fsctask/libcross/Library.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace Library

module Say =
let hello name =
printfn "Hello %s" name
20 changes: 20 additions & 0 deletions dev/preview4_fsctask/libcross/libcross.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk" ToolsVersion="15.0">

<PropertyGroup>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<Compile Include="Library.fs" />
<EmbeddedResource Include="**\*.resx" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NETStandard.Library" Version="1.6" Condition=" '$(TargetFramework)' == 'netstandard1.6' " />
<PackageReference Include="FSharp.Core" Version="4.0.1.7-alpha" />
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.0-char-*">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions src/FSharp.NET.Sdk/FSharp.NET.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,10 @@
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.FSharp.Compiler.Sdk.netcore" Version="1.0.0-rc-170113">
<PrivateAssets>Compile</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>
95 changes: 59 additions & 36 deletions src/FSharp.NET.Sdk/build/FSharp.NET.Core.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ WARNING: You CAN MODIFY this file, doesnt matter if you are not knowledgeable a
This file defines the steps in the standard build process specific for F# .NET projects.
For example, it contains the step that actually calls the F# compiler.
Flow is: msbuild -> CoreCompile -> dotnet compile-fsc -> fsc
Flow is: msbuild -> CoreCompile -> FscTask -> fsc compiler
The remainder of the build process is defined in Microsoft.Common.targets, but is not imported by
this file.
Expand All @@ -19,6 +19,9 @@ this file.

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

<!--TODO error if FscTaskAssemblyPath is not defined-->
<UsingTask TaskName="Fsc" AssemblyFile="$(FscTaskAssemblyPath)" />

<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<DefaultLanguageSourceExtension>.fs</DefaultLanguageSourceExtension>
Expand Down Expand Up @@ -88,42 +91,24 @@ this file.
Returns="@(FscCommandLineArgs)"
DependsOnTargets="$(CoreCompileDependsOn)"
>
<PropertyGroup>
<_IntermediateOutputPathFull>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)'))</_IntermediateOutputPathFull>
<_TargetFrameworkDefine>$(TargetFramework.Replace('.','_').ToUpper())</_TargetFrameworkDefine>
</PropertyGroup>

<!--STEP1 Create the dotnet-compile-fsc response file lines-->
<ItemGroup>
<DotnetCompileFscResponseLines Include="--temp-output:$(_IntermediateOutputPathFull)" />
<DotnetCompileFscResponseLines Include="--out:$(_IntermediateOutputPathFull)$(TargetName)$(TargetExt)" />

<DotnetCompileFscResponseLines Condition="'$(OutputType)' == 'Exe'" Include="--emit-entry-point:True" />
<DotnetCompileFscResponseLines Condition="'$(GenerateDocumentationFile)' == 'true'" Include="--generate-xml-documentation:True" />

<!--DOC: $(DefineConstants) is a string separated by ';' so let's convert to array-->
<DefineConstantsArray Include="$(DefineConstants.Split(';'))" />
<DotnetCompileFscResponseLines Include="@(DefineConstantsArray -> '--define:%(Identity)')" />

<!--HACK: for compatibility with previous sdk-->
<DotnetCompileFscResponseLines Include="--define:$(_TargetFrameworkDefine)" />

<DotnetCompileFscResponseLines Include="--optimize:$(Optimize)" />
<DotnetCompileFscResponseLines Include="--debug-type:$(DebugType)" />
<DotnetCompileFscResponseLines Include="--output-name:$(TargetName)" />
<DotnetCompileFscResponseLines Include="--file-version:1.0.0.0" />
<DotnetCompileFscResponseLines Include="--version:1.0.0.0" />
<DotnetCompileFscResponseLines Include="--informational-version:1.0.0" />
<DotnetCompileFscResponseLines Include="--target-framework:$(NuGetTargetMoniker)" />
<PropertyGroup>
<TargetProfile Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' " >mscorlib</TargetProfile>
<TargetProfile Condition=" '$(TargetFrameworkIdentifier)' != '.NETFramework' " >netcore</TargetProfile>

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

<DotnetCompileFscResponseLines Include="@(Compile -> '%(FullPath)')" />
</ItemGroup>
<PropertyGroup Condition=" '$(DontRunFscWithDotnet)' == '' ">
<_FscTask_FscToolExe>dotnet.exe</_FscTask_FscToolExe>
<_FscTask_FscToolPath>$(MSBuildExtensionsPath)/../..</_FscTask_FscToolPath>
<_FscTask_DotnetFscCompilerPath> "$(FscToolPath)/$(FscToolExe)"</_FscTask_DotnetFscCompilerPath>
</PropertyGroup>

<!--STEP2 Create the dotnet-compile-fsc response file-->
<PropertyGroup>
<DotnetCompileFscResponseFilePath>$(_IntermediateOutputPathFull)dotnet-compile.rsp</DotnetCompileFscResponseFilePath>
<PropertyGroup Condition=" '$(DontRunFscWithDotnet)' != '' "> <!-- check fsc extension? -->
<_FscTask_FscToolExe>$(FscToolExe)</_FscTask_FscToolExe>
<_FscTask_FscToolPath>$(FscToolPath)</_FscTask_FscToolPath>
<_FscTask_DotnetFscCompilerPath></_FscTask_DotnetFscCompilerPath>

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

<WriteLinesToFile File="$(DotnetCompileFscResponseFilePath)" Lines="@(DotnetCompileFscResponseLines)" Overwrite="True" />
<Fsc BaseAddress="$(BaseAddress)"
CodePage="$(CodePage)"
DebugSymbols="$(DebugSymbols)"
DebugType="$(DebugType)"
DefineConstants="$(DefineConstants)"
DisabledWarnings="$(NoWarn)"
DocumentationFile="$(DocumentationFile)"
EmbedAllSources="$(EmbedAllSources)"
Embed="$(Embed)"
GenerateInterfaceFile="$(GenerateInterfaceFile)"
KeyFile="$(KeyOriginatorFile)"
LCID="$(LCID)"
NoFramework="true"
Optimize="$(Optimize)"
OtherFlags="$(_OtherFscFlags) $(OtherFlags)"
OutputAssembly="@(IntermediateAssembly)"
PdbFile="$(PdbFile)"
Platform="$(PlatformTarget)"
Prefer32Bit="$(Actual32Bit)"
References="@(ReferencePath)"
ReferencePath="$(ReferencePath)"
Resources="@(_CoreCompileResourceInputs);@(CompiledLicenseFile);@(AdditionalEmbeddedResource)"
SourceLink="$(SourceLink)"
Sources="@(CompileBefore -> '%(FullPath)');@(Compile -> '%(FullPath)');@(CompileAfter -> '%(FullPath)')"
Tailcalls="$(Tailcalls)"
TargetType="$(OutputType)"
ToolExe="$(_FscTask_FscToolExe)"
ToolPath="$(_FscTask_FscToolPath)"
TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
Utf8Output="$(Utf8Output)"
VersionFile="$(VersionFile)"
VisualStudioStyleErrors="$(VisualStudioStyleErrors)"
WarningLevel="$(WarningLevel)"
WarningsAsErrors="$(WarningsAsErrors)"
Win32ManifestFile="$(Win32Manifest)"
Win32ResourceFile="$(Win32Resource)"
SubsystemVersion="$(SubsystemVersion)"
HighEntropyVA="$(HighEntropyVA)"
TargetProfile="$(TargetProfile)"
DotnetFscCompilerPath="$(_FscTask_DotnetFscCompilerPath)"
/>

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

<!--End Required Task by .Common.target-->
Expand Down

0 comments on commit 9392487

Please sign in to comment.