Skip to content

Commit

Permalink
Make type providers usable in *.fsx scripts
Browse files Browse the repository at this point in the history
Package builds now generate a copy of FSharp.Data.DesignTime.dll

This avoids the assembly path resolution problems reported in many
places, for example:

- fsprojects/FSharp.Data/issues/844
- dotnet/netcorecli-fsc/issues/16
- https://stackoverflow.com/q/3102472

Unfortunately we can't use any of the better solutions explained at
dotnet/fsharp/issues/3303, since they only apply to full-fledged
.NET projects, not scripts
  • Loading branch information
rdipardo committed Apr 26, 2021
1 parent a1ded15 commit eb0c52f
Show file tree
Hide file tree
Showing 19 changed files with 123 additions and 52 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
* -text
**.sln text eol=crlf
**.fsproj text eol=crlf
**.props text eol=crlf
**.cmd text eol=crlf
**.bat text eol=crlf
scripts/changelog text eol=lf
scripts/ci text eol=lf
scripts/gendocs text eol=lf
example/**/build text eol=lf
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
name: Unit Tests
on:
push:
branches:
- !ma*
pull_request:
branches:
- '**'
- main
jobs:
unit_tests:
runs-on: ubuntu-20.04
Expand All @@ -19,12 +16,12 @@ jobs:
- name: Pre-test install
uses: actions/setup-dotnet@v1.7.2
with:
dotnet-version: '5.0.102'
dotnet-version: '5.0.202'
- name: Cache packages
uses: actions/cache@v2.1.5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('test/Fornax.Seo.Tests/Fornax.Seo.Tests.fsproj') }}
key: ${{ runner.os }}-nuget-${{ hashFiles('src/Fornax.Seo/Directory.Build.props') }}
restore-keys: |-
${{ runner.os }}-nuget-
${{ runner.os }}-
Expand Down
74 changes: 52 additions & 22 deletions .github/workflows/nuget.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,88 @@
name: NuGet
on:
push:
tags:
- '**'
branches:
- main
jobs:
test:
runs-on: ubuntu-20.04
package:
runs-on: windows-latest
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Pre-test install
- name: Pre-build Install
uses: actions/setup-dotnet@v1.7.2
with:
dotnet-version: '5.0.102'
- name: Cache packages
uses: actions/cache@v2.1.5
dotnet-version: '5.0.202'
- name: Build package
run: scripts\pack
- name: Save package
uses: actions/upload-artifact@v2.2.3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('src/Fornax.Seo/Fornax.Seo.fsproj') }}
restore-keys: |-
${{ runner.os }}-nuget-
${{ runner.os }}-
- name: Run tests
run: scripts/ci
name: Fornax.Seo.nupkg
path: release/*.nupkg
retention-days: 30
if-no-files-found: error

publish:
needs: test
runs-on: windows-latest
needs: package
runs-on: ubuntu-20.04
if: startsWith(github.ref, 'refs/tags/')
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
fetch-depth: 0
- name: Pre-build Install
uses: actions/setup-dotnet@v1.7.2
with:
dotnet-version: '5.0.102'
- name: Release package
dotnet-version: '5.0.202'
- name: Cache packages
uses: actions/cache@v2.1.5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('src/Fornax.Seo/Directory.Build.props') }}
restore-keys: |-
${{ runner.os }}-nuget-
${{ runner.os }}-
- name: Collect release info
run: |-
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo -e $(scripts/changelog) > release_notes.txt
- name: Retrieve package
uses: actions/download-artifact@v2.0.9
id: fetch
with:
name: Fornax.Seo.nupkg
path: '~/release'
- name: Prepare release
uses: ncipollo/release-action@v1
with:
artifacts: ${{ steps.fetch.outputs.download-path }}/*.nupkg
bodyFile: release_notes.txt
name: ${{ env.RELEASE_VERSION }}
draft: true
allowUpdates: true
artifactErrorsFailBuild: true
replacesArtifacts: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish release
run: |-
scripts\gendocs
scripts\pack
# dotnet nuget push release\*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
dotnet nuget push release/Fornax.Seo.*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
scripts/gendocs
- name: Publish docs
uses: peaceiris/actions-gh-pages@v3.8.0
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
enable_jekyll: false
publish_dir: './output'
publish_branch: docs
user_name: 'Fornax.Seo [action]'
user_email: 'Fornax.Seo@users.noreply.github.com'
commit_message: '${{ github.event.head_commit.message }}'
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "src/Fornax"]
path = src/Fornax
url = https://github.com/ionide/Fornax.git
url = https://github.com/ionide/Fornax.git
[submodule "src/FSharp.Data"]
path = src/FSharp.Data
url = https://github.com/fsprojects/FSharp.Data.git
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
## 0.1.0
Initial release

## 0.1.0-a60fd1f
Start bundling FSharp.Data.DesignTime.dll since consuming F# scripts will be broken without it.
See, for example, <https://stackoverflow.com/q/3102472>

## 0.1.0-d8291ee (DEPRECATED)
Initial preview release
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![NuGet workflow status][]][NuGet Workflow]
[![Test workflow status][]][Test Workflow]

SEO metadata generator for Fornax
A SEO meta tag generator for [Fornax](https://ionide.io/Tools/fornax.html)

## Goals

Expand All @@ -19,7 +19,7 @@ SEO metadata generator for Fornax

## Usage example

- Install [Fornax](https://ionide.io/Tools/fornax.html)
- [Install Fornax](https://github.com/ionide/Fornax#installation)

dotnet tool install fornax -g

Expand Down Expand Up @@ -182,7 +182,13 @@ let layout (ctx: SiteContents) (active: string) (content: HtmlElement seq) =

## Development

_All platforms need a .NET SDK at version 5.0.102 or later_
_All platforms need a .NET SDK at version 5.0.200 or later_

_Linux users should consider 5.0.202 the [safest minimum version][]_

Checkout the source tree and submodules:

git clone --recursive https://github.com/rdipardo/Fornax.Seo

### Windows

Expand Down Expand Up @@ -241,6 +247,7 @@ Distributed under the terms of the [Mozilla Public License Version 2.0][].

[structured data]: https://developers.google.com/search/docs/guides/intro-structured-data
[absolute URLs]: https://stackoverflow.com/a/64830732
[safest minimum version]: https://github.com/NuGet/Announcements/issues/56#issue-847215025
[the documentation]: https://heredocs.io/Fornax.Seo

[Nuget version]: https://img.shields.io/nuget/vpre/Fornax.Seo?color=blueviolet&logo=nuget
Expand Down
5 changes: 5 additions & 0 deletions THIRD_PARTY
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ Fornax
------
The Fornax CLI tool and libraries are distributed under the terms of the MIT License.
More information is available at https://github.com/ionide/Fornax/blob/master/LICENSE.md

FSharp.Data
------------
FSharp.Data is distributed under the terms of the Apache License, Version 2.0.
More information is available at https://github.com/fsprojects/FSharp.Data/blob/master/LICENSE.md
2 changes: 1 addition & 1 deletion example/Fornax.Seo.Example/build
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ FORNAX_CMD=build
if [ "$1" = "live" ]; then FORNAX_CMD=watch; fi
dotnet tool restore --tool-manifest ../../src/Fornax/.config/dotnet-tools.json
dotnet build /v:m ../../src/Fornax/src/Fornax/Fornax.fsproj -o ../bin -c Release
dotnet build /v:m -o _lib -c Release
dotnet build /v:m /p:nowarn="3218 3390" -o _lib -c Release
dotnet ../bin/Fornax.dll $FORNAX_CMD
2 changes: 1 addition & 1 deletion example/Fornax.Seo.Example/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ SET "FORNAX_CMD=build"
IF "%1"=="live" ( SET "FORNAX_CMD=watch" )
dotnet tool restore --tool-manifest ../../src/Fornax/.config/dotnet-tools.json
dotnet build /v:m ../../src/Fornax/src/Fornax/Fornax.fsproj -o ../bin -c Release
dotnet build /v:m -o _lib -c Release
dotnet build /v:m /p:nowarn="3218 3390" -o _lib -c Release
dotnet ../bin/Fornax.dll %FORNAX_CMD%
ENDLOCAL
5 changes: 5 additions & 0 deletions scripts/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
HEAD=$(git describe --always)
PREV_REF=$(git describe --always $HEAD)^
PREV=$(git describe --always --abbrev=0 ${PREV_REF})
git log --oneline ${PREV}..${HEAD} | awk '{printf("%s\\n",$0)}'
3 changes: 1 addition & 2 deletions scripts/ci
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env bash
dotnet tool restore --tool-manifest src/Fornax/.config/dotnet-tools.json
dotnet test /v:m test/Fornax.Seo.Tests/Fornax.Seo.Tests.fsproj
dotnet test /v:m /p:nowarn="3218 3390" test/Fornax.Seo.Tests/Fornax.Seo.Tests.fsproj
cd example/Fornax.Seo.Example
./build $1
cd ../..
3 changes: 1 addition & 2 deletions scripts/ci.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@echo off
dotnet tool restore --tool-manifest src/Fornax/.config/dotnet-tools.json
dotnet test /v:m test/Fornax.Seo.Tests/Fornax.Seo.Tests.fsproj
dotnet test /v:m /p:nowarn="3218 3390" test/Fornax.Seo.Tests/Fornax.Seo.Tests.fsproj
cd example\Fornax.Seo.Example
build %1
cd ..\..
2 changes: 1 addition & 1 deletion scripts/gendocs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if [ "$1" = "live" ]; then
SITE_ROOT=
fi
dotnet tool restore
dotnet build src/Fornax.Seo/Fornax.Seo.fsproj -c Release
dotnet build /v:m /p:nowarn="3218 3390" src/Fornax.Seo/Fornax.Seo.fsproj -c Release
cp ./README.md docs/index.md

dotnet fsdocs $FORNAX_CMD --projects $(pwd)/src/Fornax.Seo/Fornax.Seo.fsproj \
Expand Down
2 changes: 1 addition & 1 deletion scripts/gendocs.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ IF "%1"=="live" (
SET SITE_ROOT=
)
dotnet tool restore
dotnet build src/Fornax.Seo/Fornax.Seo.fsproj -c Release
dotnet build /v:m /p:nowarn="3218 3390" src/Fornax.Seo/Fornax.Seo.fsproj -c Release

copy README.md docs\index.md
dotnet fsdocs %FSDOCS_CMD% --projects %CD%/src/Fornax.Seo/Fornax.Seo.fsproj ^
Expand Down
6 changes: 2 additions & 4 deletions scripts/pack.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ FOR /F "tokens=* USEBACKQ" %%F IN (`type release\notes.txt`) DO (
SET "PackageReleaseNotes=%%F"
)

git describe >NUL
git describe --tags >NUL
IF NOT %ERRORLEVEL% == 0 (
FOR /F "tokens=* USEBACKQ" %%F IN (`git rev-parse --short HEAD`) DO (
SET "BUILD_NUMBER=--version-suffix %%F"
)
)

dotnet tool restore --tool-manifest src/Fornax/.config/dotnet-tools.json
dotnet restore src/Fornax.Seo/Fornax.Seo.fsproj
dotnet build --no-restore src/Fornax.Seo/Fornax.Seo.fsproj -c Release -o release
dotnet pack src/Fornax.Seo/Fornax.Seo.fsproj -c Release -o release %BUILD_NUMBER%
dotnet pack /v:m /p:nowarn="3218 3390" src/Fornax.Seo/Fornax.Seo.fsproj -c Release -o release %BUILD_NUMBER%

:END
ENDLOCAL
2 changes: 1 addition & 1 deletion scripts/release-notes.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ try
FileInfo(noteText).Directory.Create()
File.WriteAllText(noteText, notes)

printfn "---\n%s\n---" <| (File.ReadAllText(noteText)).Replace("!NL!", "\n")
printfn "---\n%s\n---" <| (File.ReadAllText(noteText)).Replace("!NL!", Environment.NewLine)
with exc -> printfn "%s" <| (sprintf "%s: %s" <| exc.GetType().Name <| exc.Message)
1 change: 1 addition & 0 deletions src/FSharp.Data
Submodule FSharp.Data added at 311fa4
5 changes: 5 additions & 0 deletions src/Fornax.Seo/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<FSharpDataVersion>4.1.0</FSharpDataVersion>
</PropertyGroup>
</Project>
27 changes: 20 additions & 7 deletions src/Fornax.Seo/Fornax.Seo.fsproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk" InitialTargets="ToolRestore">
<PropertyGroup>
<VersionPrefix>0.1.0</VersionPrefix>
<VersionSuffix>alpha</VersionSuffix>
<Authors>Robert Di Pardo</Authors>
<Copyright>Copyright (c) 2021 Robert Di Pardo and Contributors</Copyright>
<Description>SEO metadata generator for Fornax</Description>
<Description>A SEO meta tag generator for Fornax (https://ionide.io/Tools/fornax.html)</Description>
<RepositoryUrl>https://github.com/rdipardo/Fornax.Seo</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseExpression>MPL-2.0</PackageLicenseExpression>
Expand All @@ -22,24 +22,37 @@
<Compile Include="Core.fs"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="FSharp.Data" Version="4.1.0"/>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3"/>
<PackageReference Include="FSharp.Data" Version="$(FSharpDataVersion)"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../Fornax/src/Fornax.Core/Fornax.Core.fsproj">
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<IncludeAssets>Fornax.Core.dll</IncludeAssets>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../FSharp.Data/src/FSharp.Data.DesignTime/FSharp.Data.DesignTime.fsproj">
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<IncludeAssets>FSharp.Data.DesignTime.dll</IncludeAssets>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<Target DependsOnTargets="ResolveReferences" Name="CopyProjectReferencesToPackage">
<ItemGroup>
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths-&gt;WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))"/>
</ItemGroup>
</Target>
<Target Name="ConfigureProjectDependencies">
<Exec EchoOff="true" Command="git config --local core.longpaths true"/>
<Exec EchoOff="true" Command="git submodule update --init --remote"/>
<Exec EchoOff="true" Command="git --git-dir=../FSharp.Data/.git --work-tree=../FSharp.Data checkout $(FSharpDataVersion)"/>
<Copy SourceFiles="../../global.json" DestinationFolder="../Fornax"/>
</Target>
<Target Name="ToolRestore" DependsOnTargets="ConfigureProjectDependencies">
<Exec Command="dotnet tool restore --tool-manifest ../Fornax/.config/dotnet-tools.json" EchoOff="true"/>
<Exec Command="dotnet tool restore --tool-manifest ../FSharp.Data/.config/dotnet-tools.json" EchoOff="true"/>
</Target>
</Project>

0 comments on commit eb0c52f

Please sign in to comment.