diff --git a/README.md b/README.md index 2e6c502..c13bed6 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,12 @@ the cached package is used. Use `-VersionSuffix 013076` argument ( for example `build -VersionSuffix 013076`) to create the package `dotnet-compile-fsc.1.0.0-preview2-013076` + +## The .NET Core SDK preview3 and msbuild based project system + +Work in progress. + +Require .NET Core SDK preview3 ( http://github.com/dotnet/cli ), tested with `1.0.0-preview3-003884` + +Example apps in `examples/preview3` +See also `src/FSharp.Net.Sdk` and `test-msbuild` directories. diff --git a/examples/preview3/console/ExampleConsoleApp.fsproj b/examples/preview3/console/ExampleConsoleApp.fsproj new file mode 100644 index 0000000..234cec4 --- /dev/null +++ b/examples/preview3/console/ExampleConsoleApp.fsproj @@ -0,0 +1,44 @@ + + + + + Exe + netcoreapp1.0 + + + + 1.0.0-preview3 + Enrico Sada + + + + + + + + + + 1.0.1 + + + 1.0.0-alpha-* + + + 1.0.0-alpha-20161012-3 + All + + + 0.2.* + All + + + + + + 1.0.0-preview2-020000 + + + + + + diff --git a/examples/preview3/console/NuGet.Config b/examples/preview3/console/NuGet.Config new file mode 100644 index 0000000..0350a3c --- /dev/null +++ b/examples/preview3/console/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + diff --git a/examples/preview3/console/Program.fs b/examples/preview3/console/Program.fs new file mode 100644 index 0000000..a4928de --- /dev/null +++ b/examples/preview3/console/Program.fs @@ -0,0 +1,8 @@ +// Learn more about F# at http://fsharp.org + +open System + +[] +let main argv = + printfn "Hello World from F#!" + 0 // return an integer exit code diff --git a/examples/preview3/console/README.md b/examples/preview3/console/README.md new file mode 100644 index 0000000..fe7d601 --- /dev/null +++ b/examples/preview3/console/README.md @@ -0,0 +1,7 @@ + +Require .NET Core sdk preview3 +Tested with .NET Core sdk v1.0.0-preview3-003884 + +- dotnet restore3 +- dotnet build3 +- dotnet run3 diff --git a/examples/preview3/lib/ExampleLibrary.fsproj b/examples/preview3/lib/ExampleLibrary.fsproj new file mode 100644 index 0000000..252251f --- /dev/null +++ b/examples/preview3/lib/ExampleLibrary.fsproj @@ -0,0 +1,43 @@ + + + + + netstandard1.6 + + + + 1.0.0-preview3 + Enrico Sada + + + + + + + + + + 1.6.0 + + + 1.0.0-alpha-* + + + 1.0.0-alpha-20161012-3 + All + + + 0.2.* + All + + + + + + 1.0.0-preview2-020000 + + + + + + diff --git a/examples/preview3/lib/Library.fs b/examples/preview3/lib/Library.fs new file mode 100644 index 0000000..ae53d09 --- /dev/null +++ b/examples/preview3/lib/Library.fs @@ -0,0 +1,5 @@ +namespace Library + +module Say = + let hello name = + printfn "Hello %s" name \ No newline at end of file diff --git a/examples/preview3/lib/NuGet.Config b/examples/preview3/lib/NuGet.Config new file mode 100644 index 0000000..0350a3c --- /dev/null +++ b/examples/preview3/lib/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + diff --git a/examples/preview3/lib/README.md b/examples/preview3/lib/README.md new file mode 100644 index 0000000..2300dc9 --- /dev/null +++ b/examples/preview3/lib/README.md @@ -0,0 +1,6 @@ + +Require .NET Core sdk preview3 +Tested with .NET Core sdk v1.0.0-preview3-003884 + +- dotnet restore3 +- dotnet build3 diff --git a/src/FSharp.NET.Sdk/FSharp.NET.Sdk.props b/src/FSharp.NET.Sdk/FSharp.NET.Sdk.props new file mode 100644 index 0000000..85cc1ee --- /dev/null +++ b/src/FSharp.NET.Sdk/FSharp.NET.Sdk.props @@ -0,0 +1,25 @@ + + + + + 4 + 1701 + + + DEBUG;TRACE + + + TRACE + + + diff --git a/src/FSharp.NET.Sdk/FSharp.NET.Sdk.targets b/src/FSharp.NET.Sdk/FSharp.NET.Sdk.targets new file mode 100644 index 0000000..d5c46ea --- /dev/null +++ b/src/FSharp.NET.Sdk/FSharp.NET.Sdk.targets @@ -0,0 +1,156 @@ + + + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + .fs + F# + Managed + true + true + true + true + + + + _ComputeNonExistentFileProperty;ResolveCodeAnalysisRuleSet + + + + Microsoft.CSharp.Core.targets + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_IntermediateOutputPathFull>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)')) + <_MicrosoftNETBuildTasksTFMDefine>$(MicrosoftNETBuildTasksTFM.Replace('.','_').ToUpper()) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(_IntermediateOutputPathFull)dotnet-compile.rsp + + + + + + + + + + + + dotnet exec --depsfile $(NuGetPackageRoot).tools\dotnet-compile-fsc\@(DotnetCompileFscVersion)\netcoreapp1.0\dotnet-compile-fsc.deps.json --additionalprobingpath $(NuGetPackageRoot.TrimEnd('\\')) $(NuGetPackageRoot)dotnet-compile-fsc\@(DotnetCompileFscVersion)\lib\netcoreapp1.0\dotnet-compile-fsc.dll + + + + + + + + + + $(MSBuildProjectFullPath) + + + diff --git a/src/FSharp.NET.Sdk/README.md b/src/FSharp.NET.Sdk/README.md new file mode 100644 index 0000000..afb2a57 --- /dev/null +++ b/src/FSharp.NET.Sdk/README.md @@ -0,0 +1,26 @@ + +Tested with .NET Core sdk v1.0.0-preview3-003884 + +## On restore + +The targets and props file are auto imported if the package is referenced. + +The auto-import is from `obj\{ProjectName}.fsproj.nuget.g.targets` and `obj\{ProjectName}.fsproj.nuget.g.props` +generated on `dotnet restore3` + + +## The `CoreCompile` task + +- create the `obj\{Configuration}\dotnet-compile-fsc.rsp` response file +- invoke the `dotnet compile-fsc` (it's the `dotnet-compile-fsc` tool app). + - like `preview2`, the `dotnet-compile-fsc` invoke the `fsc` passing `obj\{Configuration}\dotnet-compile-fsc.rsp` response + file who contains the `fsc` arguments + +## Notes + +The `Authors` property is required for `dotnet pack3` +Because the `obj\{Configuration}\dotnet-compile-fsc.rsp` is created (like preview2) the intellisense in VS Code already works using Ionide. + +## TODO + +Next version should use the an MSBuild task instead of invoking the `dotnet-compile-fsc` diff --git a/src/FSharp.NET.Sdk/project.json b/src/FSharp.NET.Sdk/project.json new file mode 100644 index 0000000..375d8cb --- /dev/null +++ b/src/FSharp.NET.Sdk/project.json @@ -0,0 +1,24 @@ +{ + "version": "0.2.0", + "frameworks": { + "netstandard1.3": {} + }, + "packOptions": { + "summary": "Sample .NET Sdk and F# integration using dotnet-compile-fsc.", + "tags": [ "f#", "sdk" ], + "owners": [ "Enrico Sada" ], + "releaseNotes": "", + "projectUrl": "https://github.com/dotnet/netcorecli-fsc", + "requireLicenseAcceptance": false, + "repository": { + "type": "git", + "url": "https://github.com/exampleorg/example" + }, + "files": { + "mappings": { + "build/netstandard1.0/FSharp.NET.Sdk.props": "FSharp.NET.Sdk.props", + "build/netstandard1.0/FSharp.NET.Sdk.targets": "FSharp.NET.Sdk.targets" + } + } + } +} diff --git a/test-msbuild/NuGet.Config b/test-msbuild/NuGet.Config new file mode 100644 index 0000000..5d8cd8b --- /dev/null +++ b/test-msbuild/NuGet.Config @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/test-msbuild/README.md b/test-msbuild/README.md new file mode 100644 index 0000000..9e3bbaf --- /dev/null +++ b/test-msbuild/README.md @@ -0,0 +1,18 @@ + +Tested with .NET Core sdk v1.0.0-preview3-003884 + +See also `src\FSharp.NET.Sdk\README.md` + +To use msbuild based fsproj, use the same sdk commands of `preview2`, but with `3` suffix. +So `dotnet build3` instead of `dotnet build`, etc. + +The normal commands like `dotnet build`, `dotnet restore` atm, expect the `project.json` so +like `preview2`. + +Tested: + +- `dotnet restore3` +- `dotnet build3` +- `dotnet run3` +- `dotnet pack3` + diff --git a/test-msbuild/TestApp/Program.fs b/test-msbuild/TestApp/Program.fs new file mode 100644 index 0000000..7375d5c --- /dev/null +++ b/test-msbuild/TestApp/Program.fs @@ -0,0 +1,16 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace TestApp + +open System +open System.Diagnostics + +module Program = + + open TestLibrary + + [] + let Main (args: string array) = + printfn "%s" (TestLibrary.Helper.GetMessage()) + 0 diff --git a/test-msbuild/TestApp/TestApp.fsproj b/test-msbuild/TestApp/TestApp.fsproj new file mode 100644 index 0000000..a37cc8f --- /dev/null +++ b/test-msbuild/TestApp/TestApp.fsproj @@ -0,0 +1,47 @@ + + + + + Exe + netcoreapp1.0 + + + + 1.0.0-preview3 + Enrico Sada + + + + + + + + + + 1.0.1 + + + 1.0.0-alpha-* + + + 1.0.0-alpha-20161012-3 + All + + + 0.2.* + All + + + TestLibrary + + + + + + 1.0.0-preview2-020000 + + + + + + diff --git a/test-msbuild/TestApp/project.json b/test-msbuild/TestApp/project.json new file mode 100644 index 0000000..fd03d36 --- /dev/null +++ b/test-msbuild/TestApp/project.json @@ -0,0 +1,45 @@ +{ + "version": "1.0.0-*", + "buildOptions": { + "emitEntryPoint": true, + "debugType": "portable", + "compilerName": "fsc", + "compile": { + "includeFiles": [ + "Program.fs" + ] + } + }, + "dependencies": { + "TestLibrary": { + "version": "1.0.0-*", + "target": "project" + }, + "Microsoft.NETCore.App": "1.0.0", + "Microsoft.FSharp.Core.netcore": "1.0.0-alpha-*" + }, + "frameworks": { + "netcoreapp1.0": { + "imports": "dnxcore50" + } + }, + "tools": { + "dotnet-compile-fsc": { + "version": "1.0.0-preview2-*", + "imports": "dnxcore50" + } + }, + "runtimes": { + "win7-x64": {}, + "win7-x86": {}, + "osx.10.10-x64": {}, + "osx.10.11-x64": {}, + "ubuntu.14.04-x64": {}, + "ubuntu.16.04-x64": {}, + "centos.7-x64": {}, + "rhel.7.2-x64": {}, + "debian.8-x64": {}, + "fedora.23-x64": {}, + "opensuse.13.2-x64": {} + } +} diff --git a/test-msbuild/TestAppConsole/Program.fs b/test-msbuild/TestAppConsole/Program.fs new file mode 100644 index 0000000..a4928de --- /dev/null +++ b/test-msbuild/TestAppConsole/Program.fs @@ -0,0 +1,8 @@ +// Learn more about F# at http://fsharp.org + +open System + +[] +let main argv = + printfn "Hello World from F#!" + 0 // return an integer exit code diff --git a/test-msbuild/TestAppConsole/TestAppConsole.fsproj b/test-msbuild/TestAppConsole/TestAppConsole.fsproj new file mode 100644 index 0000000..234cec4 --- /dev/null +++ b/test-msbuild/TestAppConsole/TestAppConsole.fsproj @@ -0,0 +1,44 @@ + + + + + Exe + netcoreapp1.0 + + + + 1.0.0-preview3 + Enrico Sada + + + + + + + + + + 1.0.1 + + + 1.0.0-alpha-* + + + 1.0.0-alpha-20161012-3 + All + + + 0.2.* + All + + + + + + 1.0.0-preview2-020000 + + + + + + diff --git a/test-msbuild/TestAppUsingSdkTargetDirectly/Console1.fsproj b/test-msbuild/TestAppUsingSdkTargetDirectly/Console1.fsproj new file mode 100644 index 0000000..ef389ca --- /dev/null +++ b/test-msbuild/TestAppUsingSdkTargetDirectly/Console1.fsproj @@ -0,0 +1,41 @@ + + + + + Exe + netcoreapp1.0 + + + + 1.0.0-preview3 + Enrico Sada + + + + + + + + + + 1.0.1 + + + 1.0.0-alpha-* + + + 1.0.0-alpha-20161012-3 + All + + + + + + 1.0.0-preview2-020005 + + + + + + + diff --git a/test-msbuild/TestAppUsingSdkTargetDirectly/Program.fs b/test-msbuild/TestAppUsingSdkTargetDirectly/Program.fs new file mode 100644 index 0000000..a4928de --- /dev/null +++ b/test-msbuild/TestAppUsingSdkTargetDirectly/Program.fs @@ -0,0 +1,8 @@ +// Learn more about F# at http://fsharp.org + +open System + +[] +let main argv = + printfn "Hello World from F#!" + 0 // return an integer exit code diff --git a/test-msbuild/TestLibrary/Helper.fs b/test-msbuild/TestLibrary/Helper.fs new file mode 100644 index 0000000..a29f6ac --- /dev/null +++ b/test-msbuild/TestLibrary/Helper.fs @@ -0,0 +1,12 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace TestLibrary + +open Lib + +type Helper() = + + static member GetMessage () = Lib.message () + + static member SayHi () = Lib.sayHi () diff --git a/test-msbuild/TestLibrary/Helper2.fs b/test-msbuild/TestLibrary/Helper2.fs new file mode 100644 index 0000000..6d374f7 --- /dev/null +++ b/test-msbuild/TestLibrary/Helper2.fs @@ -0,0 +1,12 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +module Lib + +open System + +let message () = + "This string came from the test library!" + +let sayHi () = + Console.WriteLine("Hello there!") diff --git a/test-msbuild/TestLibrary/TestLibrary.fsproj b/test-msbuild/TestLibrary/TestLibrary.fsproj new file mode 100644 index 0000000..8da3fcf --- /dev/null +++ b/test-msbuild/TestLibrary/TestLibrary.fsproj @@ -0,0 +1,44 @@ + + + + + netstandard1.6 + + + + 1.0.0-preview3 + Enrico Sada + + + + + + + + + + + 1.6.0 + + + 1.0.0-alpha-* + + + 1.0.0-alpha-20161012-3 + All + + + 0.2.* + All + + + + + + 1.0.0-preview2-020000 + + + + + +