Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ubuntu build #596

Open
wants to merge 5 commits into
base: master
from
Open
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -1,5 +1,5 @@
image:
- Visual Studio 2017
- Visual Studio 2019

This comment has been minimized.

Copy link
@jnm2

jnm2 Dec 2, 2019

Author Contributor

.NET Core 2.1 doesn't seem to be on the VS2017 image, so this change was necessary after removing the <RuntimeFrameworkVersion> element.

- Ubuntu
assembly_info:
patch: false
@@ -1,5 +1,8 @@
#tool "nuget:?package=GitReleaseNotes"
#tool nuget:?package=GitVersion.CommandLine
// Enable Cake aliases to execute .NET global tools
#module nuget:?package=Cake.DotNetTool.Module&version=0.4.0

#tool nuget:?package=GitReleaseNotes&version=0.7.1
#tool dotnet:?package=GitVersion.Tool&version=5.1.2
Comment on lines +2 to +5

This comment has been minimized.

Copy link
@jnm2

jnm2 Dec 2, 2019

Author Contributor

Cake adds warnings to the build output if specific versions are not used. The nice part is that it also speeds up the NuGet querying to compile on each run.

This comment has been minimized.

Copy link
@gep13

gep13 Dec 2, 2019

@jnm2 we actually always recommend pinning to specific versions of all tools/addins/modules, we are just becoming a little bit more vocal about it 😄


var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
@@ -33,7 +36,7 @@ Task("Version")
OutputType = GitVersionOutput.BuildServer
});
versionInfo = GitVersion(new GitVersionSettings{ OutputType = GitVersionOutput.Json });

msBuildSettings = new DotNetCoreMSBuildSettings()
.WithProperty("Version", versionInfo.NuGetVersion)
.WithProperty("AssemblyVersion", versionInfo.AssemblySemVer)
@@ -55,7 +58,10 @@ Task("Build")
Task("Test")
.IsDependentOn("Build")
.Does(() => {
DotNetCoreTool("./src/Shouldly.Tests/Shouldly.Tests.csproj", "xunit", "-configuration Debug");
DotNetCoreTest("./src/Shouldly.Tests/Shouldly.Tests.csproj", new DotNetCoreTestSettings
{
Configuration = "Debug"
});
});

Task("Package")
@@ -77,13 +83,13 @@ Task("Package")

var gitReleaseNotesTool = Context.Tools.Resolve("GitReleaseNotes.exe");

var releaseNotesExitCode =
var releaseNotesExitCode =
StartProcess(gitReleaseNotesTool,
new ProcessSettings { Arguments = ". /OutputFile artifacts/releasenotes.md", RedirectStandardOutput = true },
out var redirectedOutput);

Information(string.Join("\n", redirectedOutput));

if (string.IsNullOrEmpty(System.IO.File.ReadAllText("./artifacts/releasenotes.md")))
System.IO.File.WriteAllText("./artifacts/releasenotes.md", "No issues closed since last release");

@@ -25,10 +25,6 @@ Specifies the amount of information to be displayed.
Shows description about tasks.
.PARAMETER DryRun
Performs a dry run.
.PARAMETER Experimental
Uses the nightly builds of the Roslyn script engine.
.PARAMETER Mono
Uses the Mono Compiler rather than the Roslyn script engine.
.PARAMETER SkipToolPackageRestore
Skips restoring of packages.
.PARAMETER ScriptArgs
@@ -49,13 +45,28 @@ Param(
[switch]$ShowDescription,
[Alias("WhatIf", "Noop")]
[switch]$DryRun,
[switch]$Experimental,
[switch]$Mono,
[switch]$SkipToolPackageRestore,
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$ScriptArgs
)

# Attempt to set highest encryption available for SecurityProtocol.
# PowerShell will not set this by default (until maybe .NET 4.6.x). This
# will typically produce a message for PowerShell v2 (just an info
# message though)
try {
# Set TLS 1.2 (3072), then TLS 1.1 (768), then TLS 1.0 (192), finally SSL 3.0 (48)
# Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't
# exist in .NET 4.0, even though they are addressable if .NET 4.5+ is
# installed (.NET 4.5 is an in-place upgrade).
# PowerShell Core already has support for TLS 1.2 so we can skip this if running in that.
if (-not $IsCoreCLR) {
[System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48
}
} catch {
Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to upgrade to .NET Framework 4.5+ and PowerShell v3'
}

[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
function MD5HashFile([string] $filePath)
{
@@ -85,7 +96,7 @@ function GetProxyEnabledWebClient
{
$wc = New-Object System.Net.WebClient
$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$wc.Proxy = $proxy
return $wc
}
@@ -110,15 +121,16 @@ $MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config"
# Make sure tools folder exists
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
Write-Verbose -Message "Creating tools directory..."
New-Item -Path $TOOLS_DIR -Type directory | out-null
New-Item -Path $TOOLS_DIR -Type Directory | Out-Null
}

# Make sure that packages.config exist.
if (!(Test-Path $PACKAGES_CONFIG)) {
Write-Verbose -Message "Downloading packages.config..."
try {
Write-Verbose -Message "Downloading packages.config..."
try {
$wc = GetProxyEnabledWebClient
$wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch {
$wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG)
} catch {
Throw "Could not download packages.config."
}
}
@@ -146,23 +158,30 @@ if (!(Test-Path $NUGET_EXE)) {
}

# Save nuget.exe path to environment to be available to child processed
$ENV:NUGET_EXE = $NUGET_EXE
$env:NUGET_EXE = $NUGET_EXE
$env:NUGET_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
"mono `"$NUGET_EXE`""
} else {
"`"$NUGET_EXE`""
}

# Restore tools from NuGet?
if(-Not $SkipToolPackageRestore.IsPresent) {
Push-Location
Set-Location $TOOLS_DIR

# Check for changes in packages.config and remove installed tools if true.
[string] $md5Hash = MD5HashFile($PACKAGES_CONFIG)
[string] $md5Hash = MD5HashFile $PACKAGES_CONFIG
if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
Write-Verbose -Message "Missing or changed package.config hash..."
Remove-Item * -Recurse -Exclude packages.config,nuget.exe
Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery |
Remove-Item -Recurse -Force
}

Write-Verbose -Message "Restoring tools from NuGet..."
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""

$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""

if ($LASTEXITCODE -ne 0) {
Throw "An error occurred while restoring NuGet tools."
@@ -171,7 +190,7 @@ if(-Not $SkipToolPackageRestore.IsPresent) {
{
$md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
}
Write-Verbose -Message ($NuGetOutput | out-string)
Write-Verbose -Message ($NuGetOutput | Out-String)

Pop-Location
}
@@ -182,13 +201,13 @@ if (Test-Path $ADDINS_PACKAGES_CONFIG) {
Set-Location $ADDINS_DIR

Write-Verbose -Message "Restoring addins from NuGet..."
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""

if ($LASTEXITCODE -ne 0) {
Throw "An error occurred while restoring NuGet addins."
}

Write-Verbose -Message ($NuGetOutput | out-string)
Write-Verbose -Message ($NuGetOutput | Out-String)

Pop-Location
}
@@ -199,13 +218,13 @@ if (Test-Path $MODULES_PACKAGES_CONFIG) {
Set-Location $MODULES_DIR

Write-Verbose -Message "Restoring modules from NuGet..."
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""

if ($LASTEXITCODE -ne 0) {
Throw "An error occurred while restoring NuGet modules."
}

Write-Verbose -Message ($NuGetOutput | out-string)
Write-Verbose -Message ($NuGetOutput | Out-String)

Pop-Location
}
@@ -215,20 +234,24 @@ if (!(Test-Path $CAKE_EXE)) {
Throw "Could not find Cake.exe at $CAKE_EXE"
}

$CAKE_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
"mono `"$CAKE_EXE`""
} else {
"`"$CAKE_EXE`""
}


# Build Cake arguments
$cakeArguments = @("$Script");
if ($Target) { $cakeArguments += "-target=$Target" }
# Build an array (not a string) of Cake arguments to be joined later
$cakeArguments = @()
if ($Script) { $cakeArguments += "`"$Script`"" }
if ($Target) { $cakeArguments += "-target=`"$Target`"" }
if ($Configuration) { $cakeArguments += "-configuration=$Configuration" }
if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" }
if ($ShowDescription) { $cakeArguments += "-showdescription" }
if ($DryRun) { $cakeArguments += "-dryrun" }
if ($Experimental) { $cakeArguments += "-experimental" }
if ($Mono) { $cakeArguments += "-mono" }
$cakeArguments += $ScriptArgs

# Start Cake
Write-Host "Running build script..."
&$CAKE_EXE $cakeArguments
exit $LASTEXITCODE
Invoke-Expression "& $CAKE_EXE_INVOCATION $($cakeArguments -join " ") --bootstrap"

This comment has been minimized.

Copy link
@jnm2

jnm2 Dec 2, 2019

Author Contributor

The --bootstrap call is needed if #module is used.

This comment has been minimized.

Copy link
@gep13

gep13 Dec 2, 2019

@jnm2 in a soon to be released version of Cake, the bootstrapping will happen automatically without the need to have this step in your bootstrapper, but for now, this is the correct approach.

Invoke-Expression "& $CAKE_EXE_INVOCATION $($cakeArguments -join " ")"
exit $LASTEXITCODE
@@ -9,10 +9,14 @@
# Define directories.
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
TOOLS_DIR=$SCRIPT_DIR/tools
ADDINS_DIR=$TOOLS_DIR/Addins
MODULES_DIR=$TOOLS_DIR/Modules
NUGET_EXE=$TOOLS_DIR/nuget.exe
CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe
PACKAGES_CONFIG=$TOOLS_DIR/packages.config
PACKAGES_CONFIG_MD5=$TOOLS_DIR/packages.config.md5sum
ADDINS_PACKAGES_CONFIG=$ADDINS_DIR/packages.config
MODULES_PACKAGES_CONFIG=$MODULES_DIR/packages.config

# Define md5sum or md5 depending on Linux/OSX
MD5_EXE=
@@ -24,24 +28,14 @@ fi

# Define default arguments.
SCRIPT="build.cake"
TARGET="Default"
CONFIGURATION="Release"
VERBOSITY="verbose"
DRYRUN=
SHOW_VERSION=false
SCRIPT_ARGUMENTS=()
CAKE_ARGUMENTS=()

# Parse arguments.
for i in "$@"; do
case $1 in
-s|--script) SCRIPT="$2"; shift ;;
-t|--target) TARGET="$2"; shift ;;
-c|--configuration) CONFIGURATION="$2"; shift ;;
-v|--verbosity) VERBOSITY="$2"; shift ;;
-d|--dryrun) DRYRUN="-dryrun" ;;
--version) SHOW_VERSION=true ;;
--) shift; SCRIPT_ARGUMENTS+=("$@"); break ;;
*) SCRIPT_ARGUMENTS+=("$1") ;;
--) shift; CAKE_ARGUMENTS+=("$@"); break ;;
*) CAKE_ARGUMENTS+=("$1") ;;
esac
shift
done
@@ -73,29 +67,52 @@ fi

# Restore tools from NuGet.
pushd "$TOOLS_DIR" >/dev/null
if [ ! -f $PACKAGES_CONFIG_MD5 ] || [ "$( cat $PACKAGES_CONFIG_MD5 | sed 's/\r$//' )" != "$( $MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' )" ]; then
find . -type d ! -name . | xargs rm -rf
if [ ! -f "$PACKAGES_CONFIG_MD5" ] || [ "$( cat "$PACKAGES_CONFIG_MD5" | sed 's/\r$//' )" != "$( $MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' )" ]; then
find . -type d ! -name . ! -name 'Cake.Bakery' | xargs rm -rf
fi

mono "$NUGET_EXE" install -ExcludeVersion
if [ $? -ne 0 ]; then
echo "Could not restore NuGet packages."
echo "Could not restore NuGet tools."
exit 1
fi

$MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' >| $PACKAGES_CONFIG_MD5
$MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' >| "$PACKAGES_CONFIG_MD5"

popd >/dev/null

# Restore addins from NuGet.
if [ -f "$ADDINS_PACKAGES_CONFIG" ]; then
pushd "$ADDINS_DIR" >/dev/null

mono "$NUGET_EXE" install -ExcludeVersion
if [ $? -ne 0 ]; then
echo "Could not restore NuGet addins."
exit 1
fi

popd >/dev/null
fi

# Restore modules from NuGet.
if [ -f "$MODULES_PACKAGES_CONFIG" ]; then
pushd "$MODULES_DIR" >/dev/null

mono "$NUGET_EXE" install -ExcludeVersion
if [ $? -ne 0 ]; then
echo "Could not restore NuGet modules."
exit 1
fi

popd >/dev/null
fi

# Make sure that Cake has been installed.
if [ ! -f "$CAKE_EXE" ]; then
echo "Could not find Cake.exe at '$CAKE_EXE'."
exit 1
fi

# Start Cake
if $SHOW_VERSION; then
exec mono "$CAKE_EXE" -version
else
exec mono "$CAKE_EXE" $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}"
fi
mono "$CAKE_EXE" $SCRIPT --bootstrap

This comment has been minimized.

Copy link
@jnm2

jnm2 Dec 2, 2019

Author Contributor

The --bootstrap call is needed if #module is used.

This comment has been minimized.

Copy link
@gep13

gep13 Dec 2, 2019

@jnm2 in a soon to be released version of Cake, the bootstrapping will happen automatically without the need to have this step in your bootstrapper, but for now, this is the correct approach.

exec mono "$CAKE_EXE" $SCRIPT "${CAKE_ARGUMENTS[@]}"
@@ -5,7 +5,6 @@
<LangVersion>latest</LangVersion>
<Optimize>false</Optimize>
<DebugType Condition=" '$(OS)' == 'Windows_NT' ">full</DebugType>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">2.0.9</RuntimeFrameworkVersion>

This comment has been minimized.

Copy link
@jnm2

jnm2 Dec 2, 2019

Author Contributor

This had to be removed because .NET Core 2.0 was not found on the Ubuntu image. (It is EOL.)

</PropertyGroup>
<ItemGroup>
<Compile Remove="**\*.approved.cs;**\*.received.cs" />
@@ -19,7 +18,6 @@
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="PublicApiGenerator" Version="8.0.1" />
<PackageReference Include="TestStack.ConventionTests" Version="3.0.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />

This comment has been minimized.

Copy link
@jnm2

jnm2 Dec 2, 2019

Author Contributor

Once the <RuntimeFrameworkVersion> element was removed, dotnet-xunit caused this error on Ubuntu:

Running .NET Core  tests for framework netcoreapp2.1...
A fatal error was encountered. The library 'libhostpolicy.so' required to execute the application was not found in '/home/appveyor/.nuget/packages/dotnet-xunit/2.3.1/tools/netcoreapp2.0/xunit.console.dll'.

dotnet-xunit was discontinued: https://github.com/xunit/xunit/issues/1835#issuecomment-431199286

Version 2.3.1 has no rollforward policy and can only run on .NET Core 2.0 which is EOL.

</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
<Reference Include="System.Runtime" />
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Cake" version="0.30.0" />
<package id="Cake" version="0.35.0" />
</packages>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.