Skip to content

Commit

Permalink
Update tooling to .NET 5
Browse files Browse the repository at this point in the history
* Rename 'TaskCompletionSource' to 'DefaultPromise' (#30)
  • Loading branch information
cuteant committed May 14, 2021
1 parent 7e2252b commit dd9f9c2
Show file tree
Hide file tree
Showing 95 changed files with 604 additions and 507 deletions.
20 changes: 19 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
<Import Project="$(SourceRoot)/build/Dependencies.3rdParty.props" />
<Import Project="$(SourceRoot)/build/Dependencies.AspNetCore.props" />
<Import Project="$(SourceRoot)/build/Dependencies.AspNetCore2.props" />
<Import Project="$(SourceRoot)/build/Dependencies.AspNetCore3.props" />
<Import Project="$(SourceRoot)/build/Dependencies.CuteAnt.props" />
<Import Project="$(SourceRoot)/build/Dependencies.Extensions.props" />
<Import Project="$(SourceRoot)/build/Dependencies.Extensions2.props" />
<Import Project="$(SourceRoot)/build/Dependencies.Extensions3.props" />
<Import Project="$(SourceRoot)/build/Dependencies.Roslyn.props" />
<Import Project="$(SourceRoot)/build/Dependencies.System.props" />
<Import Project="$(SourceRoot)/build/Dependencies.System2.props" />
Expand All @@ -29,7 +31,7 @@

<!-- Common compile parameters -->
<PropertyGroup>
<LangVersion>8.0</LangVersion>
<LangVersion>9.0</LangVersion>
<!--<LangVersion>latest</LangVersion>-->
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
Expand All @@ -44,6 +46,9 @@
<ImportLibs>netcore</ImportLibs>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net5.0' or '$(TargetFramework)' == 'net5.0-windows' or '$(TargetFramework)' == 'net5.0-windows7.0' ">
<DefineConstants>$(DefineConstants);NET50;NETCOREAPP;NETCOREAPP_2_0_GREATER;NETCOREAPP_2_1_GREATER;NETCOREAPP_2_X_GREATER;NETCOREAPP_3_0_GREATER;NETCOREAPP_3_1_GREATER;NET_4_0_GREATER;NET_4_5_GREATER;NET_4_6_GREATER</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<DefineConstants>$(DefineConstants);NETCOREAPP;NETCOREAPP_2_0_GREATER;NETCOREAPP_2_1_GREATER;NETCOREAPP_2_X_GREATER;NETCOREAPP_3_0_GREATER;NET_4_0_GREATER;NET_4_5_GREATER;NET_4_6_GREATER</DefineConstants>
</PropertyGroup>
Expand Down Expand Up @@ -334,6 +339,19 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net5.0|AnyCPU'">
<DebugSymbols>True</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>5</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net5.0|AnyCPU'">
<DebugType>portable</DebugType>
<Optimize>true</Optimize>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>5</WarningLevel>
</PropertyGroup>

<!-- Set output folder for created NuGet packages -->
<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion DotnetCLIVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.404
5.0.203
67 changes: 48 additions & 19 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ let testNetFrameworkVersion = "net471"
let testNetFramework451Version = "net452"
let testNetCoreVersion = "netcoreapp3.1"
let testNetCore21Version = "netcoreapp2.1"
let testNetVersion = "net5.0"

Target "Clean" (fun _ ->
ActivateFinalTarget "KillCreatedProcesses"
Expand All @@ -64,10 +65,10 @@ Target "Clean" (fun _ ->


//--------------------------------------------------------------------------------
// Incrementalist targets
// Incrementalist targets
//--------------------------------------------------------------------------------
// Pulls the set of all affected projects detected by Incrementalist from the cached file
let getAffectedProjectsTopology =
let getAffectedProjectsTopology =
lazy(
log (sprintf "Checking inside %s for changes" incrementalistReport)

Expand All @@ -82,7 +83,7 @@ let getAffectedProjectsTopology =
Some(d)
)

let getAffectedProjects =
let getAffectedProjects =
lazy(
let finalProjects = getAffectedProjectsTopology.Value
match finalProjects with
Expand All @@ -102,8 +103,8 @@ Target "ComputeIncrementalChanges" (fun _ ->
match globalTool with
| Some t -> t
| None -> if isWindows then findToolInSubPath "incrementalist.exe" incrementalistDir
elif isMacOS then incrementalistDir @@ "incrementalist"
else incrementalistDir @@ "incrementalist"
elif isMacOS then incrementalistDir @@ "incrementalist"
else incrementalistDir @@ "incrementalist"


let args = StringBuilder()
Expand All @@ -115,12 +116,12 @@ Target "ComputeIncrementalChanges" (fun _ ->
|> append incrementalistReport
|> toText

let result = ExecProcess(fun info ->
let result = ExecProcess(fun info ->
info.FileName <- incrementalistPath
info.WorkingDirectory <- __SOURCE_DIRECTORY__
info.Arguments <- args) (System.TimeSpan.FromMinutes 5.0) (* Reasonably long-running task. *)

if result <> 0 then failwithf "Incrementalist failed. %s" args
if result <> 0 then failwithf "Incrementalist failed. %s" args
else
log "Skipping Incrementalist - not enabled for this build"
)
Expand All @@ -145,9 +146,9 @@ let filterProjects selectedProject =
Some selectedProject

//--------------------------------------------------------------------------------
// Build targets
// Build targets
//--------------------------------------------------------------------------------
let skipBuild =
let skipBuild =
lazy(
match getAffectedProjects.Value with
| None when runIncrementally -> true
Expand All @@ -162,12 +163,12 @@ let headProjects =
| Some p -> p.Keys |> Seq.toArray
)

Target "Build" (fun _ ->
Target "Build" (fun _ ->
if not skipBuild.Value then
let additionalArgs = if versionSuffix.Length > 0 then [sprintf "/p:VersionSuffix=%s" versionSuffix] else []
let additionalArgs = if versionSuffix.Length > 0 then [sprintf "/p:VersionSuffix=%s" versionSuffix] else []
let buildProject proj =
DotNetCli.Build
(fun p ->
(fun p ->
{ p with
Project = proj
Configuration = configuration
Expand All @@ -179,16 +180,18 @@ Target "Build" (fun _ ->
)

//--------------------------------------------------------------------------------
// Tests targets
// Tests targets
//--------------------------------------------------------------------------------
type Runtime =
| NetCore
| Net
| NetFramework

let getTestAssembly runtime project =
let assemblyPath = match runtime with
| NetCore -> !! ("test" @@ "**" @@ "bin" @@ "Debug" @@ testNetCoreVersion @@ fileNameWithoutExt project + ".dll")
| NetFramework -> !! ("test" @@ "**" @@ "bin" @@ "Debug" @@ "win-x64" @@ testNetFrameworkVersion @@ fileNameWithoutExt project + ".dll")
| Net -> !! ("src" @@ "**" @@ "bin" @@ "Release" @@ testNetVersion @@ fileNameWithoutExt project + ".dll")

if Seq.isEmpty assemblyPath then
None
Expand Down Expand Up @@ -269,7 +272,7 @@ Target "RunTests451" (fun _ ->
projects |> Seq.iter (runSingleProject)
)

Target "RunTestsNetCore" (fun _ ->
Target "RunTestsNet" (fun _ ->
if not skipBuild.Value then
let projects =
let rawProjects = match (isWindows) with
Expand All @@ -281,6 +284,31 @@ Target "RunTestsNetCore" (fun _ ->
-- "./test/*.Tests/DotNetty.Suite.Tests.csproj"
rawProjects |> Seq.choose filterProjects

let runSingleProject project =
let arguments =
match (hasTeamCity) with
| true -> (sprintf "test -c Debug --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s -- RunConfiguration.TargetPlatform=x64 --results-directory \"%s\" -- -parallel none -teamcity" testNetVersion outputTests)
| false -> (sprintf "test -c Debug --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s -- RunConfiguration.TargetPlatform=x64 --results-directory \"%s\" -- -parallel none" testNetVersion outputTests)

let result = ExecProcess(fun info ->
info.FileName <- "dotnet"
info.WorkingDirectory <- (Directory.GetParent project).FullName
info.Arguments <- arguments) (TimeSpan.FromMinutes 30.0)

ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result

CreateDir outputTests
projects |> Seq.iter (runSingleProject)
)

Target "RunTestsNetCore" (fun _ ->
if not skipBuild.Value then
let projects =
let rawProjects = match (isWindows) with
| true -> !! "./test/*.Tests/*.Tests.csproj"
| _ -> !! "./test/*.Tests/*.Tests.csproj" // if you need to filter specs for Linux vs. Windows, do it here
rawProjects |> Seq.choose filterProjects

let runSingleProject project =
let arguments =
match (hasTeamCity) with
Expand All @@ -303,9 +331,7 @@ Target "RunTestsNetCore21" (fun _ ->
let projects =
let rawProjects = match (isWindows) with
| true -> !! "./test/*.Tests/*.Tests.csproj"
-- "./test/*.Tests/DotNetty.Suite.Tests.csproj"
| _ -> !! "./test/*.Tests/*.Tests.csproj" // if you need to filter specs for Linux vs. Windows, do it here
-- "./test/*.Tests/DotNetty.Suite.Tests.csproj"
rawProjects |> Seq.choose filterProjects

let runSingleProject project =
Expand All @@ -327,15 +353,15 @@ Target "RunTestsNetCore21" (fun _ ->

FinalTarget "KillCreatedProcesses" (fun _ ->
log "Shutting down dotnet build-server"
let result = ExecProcess(fun info ->
let result = ExecProcess(fun info ->
info.FileName <- "dotnet"
info.WorkingDirectory <- __SOURCE_DIRECTORY__
info.Arguments <- "build-server shutdown") (System.TimeSpan.FromMinutes 2.0)
if result <> 0 then failwithf "dotnet build-server shutdown failed"
)

//--------------------------------------------------------------------------------
// Help
// Help
//--------------------------------------------------------------------------------

Target "Help" <| fun _ ->
Expand All @@ -349,7 +375,7 @@ Target "Help" <| fun _ ->
" * All Builds, run tests, creates and optionally publish nuget packages"
""
" Other Targets"
" * Help Display this help"
" * Help Display this help"
""]

//--------------------------------------------------------------------------------
Expand All @@ -370,13 +396,16 @@ Target "RunTestsNetCoreFull" DoNothing
// tests dependencies
"Build" ==> "RunTests"
"Build" ==> "RunTests451"
"Build" ==> "RunTestsNet"
"Build" ==> "RunTestsNetCore"
"Build" ==> "RunTestsNetCore21"

// all
"BuildDebug" ==> "All"
"RunTests" ==> "All"
"RunTestsNet" ==> "All"
"RunTests451" ==> "All"
"RunTestsNetCore" ==> "All"
"RunTestsNetCore21" ==> "All"

RunTargetOrDefault "Help"
50 changes: 2 additions & 48 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@ Param(
)

$FakeVersion = "4.63.0"
$DotNetChannel = "LTS";
$DotNetVersion = "3.1.402";
$DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1";
$NugetVersion = "5.7.0";
$NugetVersion = "5.8.0";
$NugetUrl = "https://dist.nuget.org/win-x86-commandline/v$NugetVersion/nuget.exe"

$IncrementalistVersion = "0.2.2";
$IncrementalistVersion = "0.4.0";

# Make sure tools folder exists
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
Expand All @@ -46,49 +43,6 @@ if (!(Test-Path $ToolPath)) {
New-Item -Path $ToolPath -Type directory | out-null
}

###########################################################################
# INSTALL .NET CORE CLI
###########################################################################

Function Remove-PathVariable([string]$VariableToRemove)
{
$path = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($path -ne $null)
{
$newItems = $path.Split(';', [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove }
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User")
}

$path = [Environment]::GetEnvironmentVariable("PATH", "Process")
if ($path -ne $null)
{
$newItems = $path.Split(';', [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove }
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process")
}
}

# Get .NET Core CLI path if installed.
$FoundDotNetCliVersion = $null;
if (Get-Command dotnet -ErrorAction SilentlyContinue) {
$FoundDotNetCliVersion = dotnet --version;
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1
}

if($FoundDotNetCliVersion -ne $DotNetVersion) {
$InstallPath = Join-Path $PSScriptRoot ".dotnet"
if (!(Test-Path $InstallPath)) {
mkdir -Force $InstallPath | Out-Null;
}
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1");
& $InstallPath\dotnet-install.ps1 -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath -Architecture x64;

Remove-PathVariable "$InstallPath"
$env:PATH = "$InstallPath;$env:PATH"
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1
}

###########################################################################
# INSTALL NUGET
###########################################################################
Expand Down
25 changes: 5 additions & 20 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ TOOLS_DIR=$SCRIPT_DIR/tools
INCREMENTALIST_DIR=$TOOLS_DIR/incrementalist
INCREMENTALIST_EXE=$INCREMENTALIST_DIR/Incrementalist.Cmd.exe
NUGET_EXE=$TOOLS_DIR/nuget.exe
NUGET_URL=https://dist.nuget.org/win-x86-commandline/v5.7.0/nuget.exe
NUGET_URL=https://dist.nuget.org/win-x86-commandline/v5.8.0/nuget.exe
FAKE_VERSION=4.63.0
FAKE_EXE=$TOOLS_DIR/FAKE/tools/FAKE.exe
DOTNET_EXE=$SCRIPT_DIR/.dotnet/dotnet
DOTNET_VERSION=3.1.402
DOTNETCORE_VERSION=3.1.409
DOTNET_VERSION=5.0.203
DOTNET_INSTALLER_URL=https://dot.net/v1/dotnet-install.sh
DOTNET_CHANNEL=LTS
PROTOBUF_VERSION=3.4.0
INCREMENTALIST_VERSION=0.2.2
INCREMENTALIST_VERSION=0.4.0

# Define default arguments.
TARGET="Default"
Expand All @@ -44,22 +45,6 @@ if [ ! -d "$TOOLS_DIR" ]; then
mkdir "$TOOLS_DIR"
fi

###########################################################################
# INSTALL .NET CORE CLI
###########################################################################

echo "Installing .NET CLI..."
if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then
mkdir "$SCRIPT_DIR/.dotnet"
fi
curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" $DOTNET_INSTALLER_URL
bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version $DOTNET_VERSION --channel $DOTNET_CHANNEL --install-dir .dotnet --no-path
export PATH="$SCRIPT_DIR/.dotnet":$PATH
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export DOTNET_CLI_TELEMETRY_OPTOUT=1
chmod -R 0755 ".dotnet"
"$SCRIPT_DIR/.dotnet/dotnet" --info

###########################################################################
# INSTALL NUGET
###########################################################################
Expand Down Expand Up @@ -96,7 +81,7 @@ fi
# INSTALL Incrementalist
###########################################################################
if [ ! -f "$INCREMENTALIST_EXE" ]; then
"$SCRIPT_DIR/.dotnet/dotnet" tool install Incrementalist.Cmd --version $INCREMENTALIST_VERSION --tool-path "$INCREMENTALIST_DIR"
dotnet tool install Incrementalist.Cmd --version $INCREMENTALIST_VERSION --tool-path "$INCREMENTALIST_DIR"
if [ $? -ne 0 ]; then
echo "Incrementalist already installed."
fi
Expand Down
Loading

0 comments on commit dd9f9c2

Please sign in to comment.