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)
This commit is contained in:
Enrico Sada 2017-01-09 18:28:27 +01:00
Родитель be66f60fdd
Коммит 939248783c
15 изменённых файлов: 206 добавлений и 36 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -240,3 +240,4 @@ _Pvt_Extensions
test/test-dotnet-new/
.dotnetsdk
src/FSharp.NET.Sdk/NuGet.Config

1
dev/.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1 @@
log*.txt

Просмотреть файл

@ -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>

Просмотреть файл

@ -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

Просмотреть файл

@ -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>

Просмотреть файл

@ -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

Просмотреть файл

@ -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>

Просмотреть файл

@ -0,0 +1,9 @@
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}

Просмотреть файл

@ -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>

Просмотреть файл

@ -0,0 +1,5 @@
namespace Library
module Say =
let hello name =
printfn "Hello %s" name

Просмотреть файл

@ -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>

Просмотреть файл

@ -0,0 +1,5 @@
namespace Library
module Say =
let hello name =
printfn "Hello %s" name

Просмотреть файл

@ -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>

Просмотреть файл

@ -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>

Просмотреть файл

@ -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.
@ -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>
@ -88,42 +91,24 @@ this file.
Returns="@(FscCommandLineArgs)"
DependsOnTargets="$(CoreCompileDependsOn)"
>
<PropertyGroup>
<_IntermediateOutputPathFull>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)'))</_IntermediateOutputPathFull>
<_TargetFrameworkDefine>$(TargetFramework.Replace('.','_').ToUpper())</_TargetFrameworkDefine>
<TargetProfile Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' " >mscorlib</TargetProfile>
<TargetProfile Condition=" '$(TargetFrameworkIdentifier)' != '.NETFramework' " >netcore</TargetProfile>
<_OtherFscFlags>--simpleresolution --nocopyfsharpcore</_OtherFscFlags>
</PropertyGroup>
<!--STEP1 Create the dotnet-compile-fsc response file lines-->
<ItemGroup>
<DotnetCompileFscResponseLines Include="--temp-output:$(_IntermediateOutputPathFull)" />
<DotnetCompileFscResponseLines Include="--out:$(_IntermediateOutputPathFull)$(TargetName)$(TargetExt)" />
<PropertyGroup Condition=" '$(DontRunFscWithDotnet)' == '' ">
<_FscTask_FscToolExe>dotnet.exe</_FscTask_FscToolExe>
<_FscTask_FscToolPath>$(MSBuildExtensionsPath)/../..</_FscTask_FscToolPath>
<_FscTask_DotnetFscCompilerPath> "$(FscToolPath)/$(FscToolExe)"</_FscTask_DotnetFscCompilerPath>
</PropertyGroup>
<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)" />
<DotnetCompileFscResponseLines Include="@(ReferencePath -> '--reference:%(FullPath)')" />
<DotnetCompileFscResponseLines Include="@(Compile -> '%(FullPath)')" />
</ItemGroup>
<!--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,
@ -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-->