Skip to content

Commit

Permalink
Update projects to .NET sdk, support netstandard2.0, drop tfms, etc (
Browse files Browse the repository at this point in the history
…#38)

create a modern package, use .net sdk, cleanup infra, add ci.

## Supported frameworks

add support for `netstandard2.0`

drop support for discontinued `net40-client` target framework.
it's not used anymore in .NET >= 4.5
ref https://docs.microsoft.com/en-us/dotnet/framework/deployment/client-profile

drop support for `netstandard1.6`, it's useful only in .NET Core v1.
replaced by `netstandard2.0`

drop support for `.NETPortable`( `portable-net45+win8+wp8+wpa81` ) target framework.
the PCL profiles are replaced by .NET Standard.
- the compiler defines `PCL` is not used anymore. The code is not yet removed
  because it's a big change, but because the compiler define is not set, the
  code is unused

## Dependencies

pin `FSharp.Core` to be >= v4.3.4 for all target framework to simplify deps

## Projects

add `global.json` to pin .net core sdk version to make build deterministic

upgrade form FSharp.NET.Sdk style (deprecated in .NET Core Sdk 1.0) to .NET Sdk fsproj

cleanup shared props and fsproj, using conventions of .NET Sdk:

- refactor common properties in an automatically imported `Directory.Build.props`
- move props near usage in projects
- remove now useless FParsec.Samples.Common.targets
- upgrade tests from netcoreapp2.0 to netcoreapp2.1

remove old VS11 projects, new projects works in VS

## Build script

update `pack.ps1` powershell script, to use `dotnet` commands instead of msbuild/nuget
nupkgs are generated in `~/bin/nupkg`

## CI

Add appveyor:
- run `pack.ps1`
- version suffix autogenerated by buildId/branch/PR. no suffix if is a tag (so just tag to generate a stable version)
- generated nupkgs are in the artifacts tab of appveyor, ready to download

Add travis:
- osx/ubuntu
- run `dotnet build` on both `Release` and `Release-LowTrust` configurations
- run tests only if `netcoreapp`. It can run also `net45` test using mono but i am too lazy to write the if in the travis script (but the matrix is there)

## Issues

fix #34 (support `netstandard` and `net` tfms)
fix #21 (just run `dotnet` commands, but replacing the powershell is easy too)
  • Loading branch information
enricosada authored Mar 2, 2019
1 parent 9e4763e commit 61894fe
Show file tree
Hide file tree
Showing 38 changed files with 539 additions and 1,438 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ obj/
*.swp
*.pdb
packages/
version.props
version.props
/.vs/
32 changes: 32 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
language: csharp

mono: 5.18.0
dotnet: 2.1.500

install:
# workaround for missing .net 4.5 targing pack
- export FrameworkPathOverride=$(dirname $(which mono))/../lib/mono/4.5/

script:
- dotnet build FParsec.sln -c $CONFIGURATION -v n
- |
if [ "$RUN_TESTS" == "1" ]; then
dotnet run --no-build -p Test -c $CONFIGURATION -f $TFM
fi
env:
- CONFIGURATION=Release
TFM=net45
- CONFIGURATION=Release-LowTrust
TFM=net45
- CONFIGURATION=Release-LowTrust
TFM=netcoreapp2.1
RUN_TESTS=1

matrix:
include:
- os: linux
dist: trusty
sudo: required
- os: osx
osx_image: xcode9
74 changes: 44 additions & 30 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,67 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"version": "2.0.0",
"tasks": [
{
"taskName": "Restore (Config: Debug-LowTrust)",
"suppressTaskName": true,
"args": ["restore", "/p:Configuration=Debug-LowTrust"],
"showOutput": "always",
"label": "Restore (Config: Debug-LowTrust)",
"command": "dotnet restore /p:Configuration=Debug-LowTrust",
"type": "shell",
"group": "build",
"presentation": {
"reveal": "always"
},
"problemMatcher": "$msCompile"
},
{
"taskName": "Build .NET Core Test (Config: Debug-LowTrust)",
"suppressTaskName": true,
"args": ["build", "Test", "-c", "Debug-LowTrust", "-f", "netcoreapp2.0"],
"isBuildCommand": true,
"showOutput": "silent",
"label": "Build .NET Core Test (Config: Debug-LowTrust)",
"command": "dotnet build Test -c Debug-LowTrust -f netcoreapp2.1",
"type": "shell",
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
},
{
"taskName": "Build .NET 4.5 Test (Config: Debug-LowTrust)",
"suppressTaskName": true,
"args": ["build", "Test", "-c", "Debug-LowTrust", "-f", "net45"],
"showOutput": "silent",
"label": "Build .NET 4.5 Test (Config: Debug-LowTrust)",
"command": "dotnet build Test -c Debug-LowTrust -f net45",
"type": "shell",
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
},
{
"taskName": "Build All (Config: Debug-LowTrust)",
"suppressTaskName": true,
"args": ["build", "-c", "Debug-LowTrust"],
"showOutput": "silent",
"label": "Build All (Config: Debug-LowTrust)",
"command": "dotnet build -c Debug-LowTrust",
"type": "shell",
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
},
{
"taskName": "Test .NET  Core (Config: Debug-LowTrust)",
"suppressTaskName": true,
"args": [ "Test/bin/Debug-LowTrust/netcoreapp2.0/Test.dll" ],
"isTestCommand": true,
"showOutput": "always"
"label": "Test .NET Core (Config: Debug-LowTrust)",
"command": "dotnet Test/bin/Debug-LowTrust/netcoreapp2.1/Test.dll",
"type": "shell",
"group": "test",
"presentation": {
"reveal": "always"
},
"problemMatcher": "$msCompile"
},

{
"taskName": "Test .NET 4.5 (Config: Debug-LowTrust)",
"suppressTaskName": true,
"label": "Test .NET 4.5 (Config: Debug-LowTrust)",
"command": "Test/bin/Debug-LowTrust/net45/Test.exe",
"showOutput": "always"
"type": "shell",
"group": "test",
"presentation": {
"reveal": "always"
},
"problemMatcher": "$msCompile"
}
]
}
150 changes: 8 additions & 142 deletions Build/FParsec.Common.targets
Original file line number Diff line number Diff line change
@@ -1,127 +1,22 @@
<Project>

<PropertyGroup>
<LowTrust>false</LowTrust>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug-LowTrust' or '$(Configuration)' == 'Release-LowTrust'">
<LowTrust>true</LowTrust>
<DefineConstants>$(DefineConstants);LOW_TRUST</DefineConstants>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>

<PropertyGroup>
<FSharpPortableLanguageTargets>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.Portable.FSharp.Targets</FSharpPortableLanguageTargets>
<FSharpPortableLanguageTargets Condition="!Exists('$(FSharpPortableLanguageTargets)')" />
</PropertyGroup>

<PropertyGroup>
<CoreOnNonWin>false</CoreOnNonWin>
<CoreOnNonWin Condition="'$(MSBuildRuntimeType)' == 'Core' and '$(OS)' != 'Windows_NT'">true</CoreOnNonWin>
</PropertyGroup>

<Target Name="CheckFParsecConfiguration" BeforeTargets="BeforeBuild;_GetProjectJsonPath">
<Error Condition="'$(LowTrust)' == 'false' and '$(CoreOnNonWin)' == 'true'"
Text="Currently, only the configurations 'Debug-LowTrust' and 'Release-LowTrust' are .NET Core compatible, but the selected configuration is: '$(Configuration)'." />
</Target>

<PropertyGroup Condition="'$(LowTrust)' != 'true'">
<TargetFrameworks>net40-client;net45</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="'$(LowTrust)' == 'true'">
<TargetFrameworks Condition="'$(OutputType)' != 'Exe'">netstandard1.6</TargetFrameworks>
<TargetFrameworks Condition="'$(OutputType)' != 'Exe' and '$(CoreOnNonWin)' == 'false'">$(TargetFrameworks);net40-client</TargetFrameworks>
<TargetFrameworks Condition="'$(OutputType)' != 'Exe' and '$(FSharpPortableLanguageTargets)' != ''">$(TargetFrameworks);portable-net45+win8+wp8+wpa81</TargetFrameworks>
<TargetFrameworks Condition="'$(OutputType)' == 'Exe'">netcoreapp2.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OutputType)' == 'Exe' and '$(CoreOnNonWin)' == 'false'">$(TargetFrameworks);net45</TargetFrameworks>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net40-client'">
<TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'portable-net45+win8+wp8+wpa81'">
<TargetFrameworkIdentifier>.NETPortable</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
<NugetTargetMoniker>.NETPortable,Version=v0.0,Profile=Profile259</NugetTargetMoniker>
<TargetProfile>netcore</TargetProfile>
<TargetFSharpCoreVersion>3.259.4.0</TargetFSharpCoreVersion>
<!-- https://github.com/NuGet/Home/issues/5021 -->
<IncludeProjectPriFile>false</IncludeProjectPriFile>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == ''">
<TargetFrameworkIdentifier Condition="'$(TargetFramework)' == 'net45'">.NETFramework</TargetFrameworkIdentifier>
<TargetFrameworkIdentifier Condition="'$(TargetFramework)' == 'netstandard1.6'">.NETStandard</TargetFrameworkIdentifier>
<TargetFrameworkIdentifier Condition="'$(TargetFramework)' == 'netstandard2.0'">.NETStandard</TargetFrameworkIdentifier>
<TargetFrameworkIdentifier Condition="'$(TargetFramework)' == 'netcoreapp1.1'">.NETCoreApp</TargetFrameworkIdentifier>
<TargetFrameworkIdentifier Condition="'$(TargetFramework)' == 'netcoreapp2.0'">.NETCoreApp</TargetFrameworkIdentifier>
</PropertyGroup>

<ItemGroup Condition="'$(MSBuildProjectExtension)' == '.fsproj'">
<PackageReference Include="FSharp.NET.Sdk" Version="1.*" PrivateAssets="All" />
</ItemGroup>

<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETPortable'">
<LanguageTargets Condition="'$(MSBuildProjectExtension)' == '.csproj'">$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets</LanguageTargets>
<LanguageTargets Condition="'$(MSBuildProjectExtension)' == '.fsproj'">$(FSharpPortableLanguageTargets)</LanguageTargets>
</PropertyGroup>

<Choose>
<When Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard' or '$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<ItemGroup><PackageReference Include="FSharp.Core" Version="4.*" /></ItemGroup>
</When>
<When Condition="'$(TargetFrameworkIdentifier)' == '.NETPortable'">
<ItemGroup>
<Reference Include="FSharp.Core">
<Name>FSharp.Core</Name>
<AssemblyName>FSharp.Core.dll</AssemblyName>
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\.NETCore\$(TargetFSharpCoreVersion)\FSharp.Core.dll</HintPath>
</Reference>
</ItemGroup>
</When>
<Otherwise>
<ItemGroup><PackageReference Include="FSharp.Core" Version="4.0.0.1" /></ItemGroup>
</Otherwise>
</Choose>

<PropertyGroup>
<DisableImplicitConfigurationDefines>true</DisableImplicitConfigurationDefines>
</PropertyGroup>
<Choose>
<When Condition="'$(Configuration)' == 'Debug' or '$(Configuration)' == 'Debug-LowTrust'">
<PropertyGroup>
<DefineConstants>$(DefineConstants);DEBUG</DefineConstants>
</PropertyGroup>
</When>
<When Condition="'$(Configuration)' == 'Release' or '$(Configuration)' == 'Release-LowTrust'">
<PropertyGroup>
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
</PropertyGroup>
</When>
</Choose>

<PropertyGroup Condition="'$(LowTrust)' == 'true'">
<DefineConstants>$(DefineConstants);SMALL_STATETAG</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' != 'net40-client'">
<PropertyGroup>
<DefineConstants>$(DefineConstants);AGGRESSIVE_INLINING</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<PropertyGroup Condition="'$(TargetFramework)' == 'net45'">
<DefineConstants>$(DefineConstants);UNALIGNED_READS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETPortable'">
<DefineConstants>$(DefineConstants);PCL</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(LowTrust)' == 'false' and '$(AssemblyName)' != 'FParsecCS'">
<DefineConstants>$(DefineConstants);USE_STATIC_MAPPING_FOR_IS_ANY_OF</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(FParsecNuGet)' == 'true'">
<SignAssembly Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' or '$(TargetFrameworkIdentifier)' == '.NETPortable'">true</SignAssembly>
<SignAssembly Condition="'$(TargetFramework)' == 'net45'">true</SignAssembly>
</PropertyGroup>

<PropertyGroup>
<AssemblyVersion Condition="'$(SignAssembly)' == 'true'">1.0.0.0</AssemblyVersion>
<AssemblyVersion Condition="'$(SignAssembly)' != 'true'">$(FileVersion)</AssemblyVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(SignAssembly)' == 'true'">
Expand All @@ -130,33 +25,4 @@
<DefineConstants>$(DefineConstants);STRONG_NAME</DefineConstants>
</PropertyGroup>

<Import Project="..\Build\NuGet.props" />

<!-- See https://github.com/dotnet/netcorecli-fsc/issues/93 -->
<Target Name="FParsecAssemblyInfoWorkaround"
Condition="'$(AssemblyName)' == 'FParsec'"
AfterTargets="GetAssemblyVersion" BeforeTargets="GenerateAssemblyInfo">
<PropertyGroup>
<FParsecAssemblyInfoFile>$(IntermediateOutputPath)$(AssemblyName).ExtraAssemblyInfo.fs</FParsecAssemblyInfoFile>
<FParsecAssemblyInfo><![CDATA[
namespace FParsec
open System.Reflection
[<assembly: System.Runtime.Versioning.TargetFrameworkAttribute("$(TargetFrameworkMoniker)", FrameworkDisplayName = "$(TargetFrameworkMonikerDisplayName)")>]
[<assembly: AssemblyConfiguration("$(Configuration)")>]
[<assembly: AssemblyCopyright("$(Copyright)")>]
[<assembly: AssemblyFileVersion("$(FileVersion)")>]
[<assembly: AssemblyInformationalVersion("$(InformationalVersion)")>]
[<assembly: AssemblyProduct("$(Product)")>]
[<assembly: AssemblyTitle("$(AssemblyName)")>]
[<assembly: AssemblyVersion("$(AssemblyVersion)")>]
do ()
]]></FParsecAssemblyInfo>
</PropertyGroup>
<WriteLinesToFile File="$(FParsecAssemblyInfoFile)" Lines="$(FParsecAssemblyInfo)" Overwrite="true" Encoding="UTF-8" />
<ItemGroup>
<Compile Include="$(FParsecAssemblyInfoFile)" />
</ItemGroup>
</Target>

</Project>
40 changes: 0 additions & 40 deletions Build/NuGet.props

This file was deleted.

Loading

0 comments on commit 61894fe

Please sign in to comment.