Skip to content

Commit

Permalink
Merge pull request #13 from cake-contrib/update_cake
Browse files Browse the repository at this point in the history
Added support for Cake 1.0 (#11), Added tag for nuget package (#12)
  • Loading branch information
deqenq authored Mar 28, 2021
2 parents f0aed2e + 3d99d5a commit 15eeb8a
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ branches:
install: true
mono:
- latest
dotnet: 2.1.603
dist: trusty
dotnet: 5.0.200
dist: xenial
sudo: required
script:
- ./build.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Cake.Wget is wrapper for command line [Wget](https://www.gnu.org/software/wget/)
You can also specify version which should be used:

```csharp
#addin nuget:?package=Cake.Wget&version=1.0.0
#addin nuget:?package=Cake.Wget&version=1.1.0
```

Command line switches are passed to the tool by `WgetSettings` object properties. Most `WgetSettings` properties names can be derived from Wget command line switches (long version) and vice versa. For example command line switch `--input-file` is translated to `WgetSettings` property name `InputFile`.
Expand Down
12 changes: 9 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
version: 1.0.0.{build}
image: Visual Studio 2017
version: 1.1.0.{build}
image: Visual Studio 2019
environment:
Configuration: Release
CoverallsRepoToken:
secure: ejW6wWM/UFiJrab/vcmLNmkgUU+nb3R4uPC3yLgEoQ5+74P+WZ2o+K0Vf+LShFSQ
install:
- ps: >-
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile './dotnet-install.ps1'
./dotnet-install.ps1 -JSonFile global.json -InstallDir 'C:\Program Files\dotnet'
build_script:
- ps: ./build.ps1 -Target Coverage-Report
- ps: ./build.ps1 --Target="Coverage-Report" --Configuration="$env:Configuration"
4 changes: 2 additions & 2 deletions azure-pipelines-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ trigger:
- master

variables:
sdk_version: 2.1.603
sdk_version: 5.0.200

jobs:
- job: macOS
pool:
vmImage: 'macOS-10.14'
vmImage: 'macOS-10.15'
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ trigger:
- master

variables:
sdk_version: 2.1.603
sdk_version: 5.0.200

jobs:
- job: Linux
pool:
vmImage: 'ubuntu-16.04'
vmImage: 'ubuntu-20.04'
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ trigger:
- master

variables:
sdk_version: 2.1.603
sdk_version: 5.0.200

jobs:
- job: Windows
Expand Down
6 changes: 3 additions & 3 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#tool nuget:?package=coveralls.io&version=1.4.2

#addin nuget:?package=Cake.Coveralls&version=0.10.0
#addin nuget:?package=Cake.Coveralls&version=1.0.0

var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
Expand Down Expand Up @@ -52,8 +52,8 @@ Task("Test")
var settings = new DotNetCoreTestSettings
{
Configuration = configuration,
Framework = "netcoreapp2.1",
Logger = "trx",
Framework = "netcoreapp5.0",
Loggers = new List<string>() {"trx"},
VSTestReportPath = testReport.FullPath,
};

Expand Down
91 changes: 68 additions & 23 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ https://cakebuild.net

[CmdletBinding()]
Param(
[string]$Script = "build.cake",
[string]$Script,
[string]$Target,
[string]$Configuration,
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
Expand All @@ -50,6 +50,11 @@ Param(
[string[]]$ScriptArgs
)

# This is an automatic variable in PowerShell Core, but not in Windows PowerShell 5.x
if (-not (Test-Path variable:global:IsCoreCLR)) {
$IsCoreCLR = $false
}

# 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
Expand All @@ -59,7 +64,10 @@ try {
# 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).
[System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48
# 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'
}
Expand All @@ -86,6 +94,11 @@ function MD5HashFile([string] $filePath)
{
$file.Dispose()
}

if ($md5 -ne $null)
{
$md5.Dispose()
}
}
}

Expand All @@ -104,6 +117,9 @@ if(!$PSScriptRoot){
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
}

if(!$Script){
$Script = Join-Path $PSScriptRoot "build.cake"
}
$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
$ADDINS_DIR = Join-Path $TOOLS_DIR "Addins"
$MODULES_DIR = Join-Path $TOOLS_DIR "Modules"
Expand All @@ -115,10 +131,14 @@ $PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum"
$ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config"
$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config"

$env:CAKE_PATHS_TOOLS = $TOOLS_DIR
$env:CAKE_PATHS_ADDINS = $ADDINS_DIR
$env:CAKE_PATHS_MODULES = $MODULES_DIR

# 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.
Expand Down Expand Up @@ -154,25 +174,37 @@ if (!(Test-Path $NUGET_EXE)) {
}
}

# These are automatic variables in PowerShell Core, but not in Windows PowerShell 5.x
if (-not (Test-Path variable:global:ismacos)) {
$IsLinux = $false
$IsMacOS = $false
}

# 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..."
Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery |
Remove-Item -Recurse
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."
Expand All @@ -181,7 +213,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
}
Expand All @@ -192,13 +224,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
}
Expand All @@ -209,13 +241,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
}
Expand All @@ -225,18 +257,31 @@ 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" }
if ($Configuration) { $cakeArguments += "-configuration=$Configuration" }
if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" }
if ($ShowDescription) { $cakeArguments += "-showdescription" }
if ($DryRun) { $cakeArguments += "-dryrun" }
# 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" }
$cakeArguments += $ScriptArgs

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

# Clean up environment variables that were created earlier in this bootstrapper
$env:CAKE_PATHS_TOOLS = $null
$env:CAKE_PATHS_ADDINS = $null
$env:CAKE_PATHS_MODULES = $null

# Return exit code
exit $cakeExitCode
11 changes: 10 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ PACKAGES_CONFIG_MD5=$TOOLS_DIR/packages.config.md5sum
ADDINS_PACKAGES_CONFIG=$ADDINS_DIR/packages.config
MODULES_PACKAGES_CONFIG=$MODULES_DIR/packages.config

export CAKE_PATHS_TOOLS=$TOOLS_DIR
export CAKE_PATHS_ADDINS=$ADDINS_DIR
export CAKE_PATHS_MODULES=$MODULES_DIR

# Define md5sum or md5 depending on Linux/OSX
MD5_EXE=
if [[ "$(uname -s)" == "Darwin" ]]; then
Expand All @@ -27,7 +31,7 @@ else
fi

# Define default arguments.
SCRIPT="build.cake"
SCRIPT=$SCRIPT_DIR/build.cake
CAKE_ARGUMENTS=()

# Parse arguments.
Expand Down Expand Up @@ -115,3 +119,8 @@ fi

# Start Cake
exec mono "$CAKE_EXE" $SCRIPT "${CAKE_ARGUMENTS[@]}"

# Clean up environment variables that were created earlier in this bootstrapper
unset CAKE_PATHS_TOOLS
unset CAKE_PATHS_ADDINS
unset CAKE_PATHS_MODULES
3 changes: 2 additions & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"sdk": {
"version": "2.1.603"
"version": "5.0.200",
"rollForward": "latestFeature"
}
}
19 changes: 13 additions & 6 deletions src/Cake.Wget.Tests/Cake.Wget.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp5.0</TargetFramework>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Cake.Core" Version="0.33.0" />
<PackageReference Include="Cake.Testing" Version="0.33.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.1" />
<PackageReference Include="Cake.Core" Version="1.0.0" >
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Cake.Testing" Version="1.0.0" >
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="2.6.1" />
<PackageReference Include="coverlet.msbuild" Version="3.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 15eeb8a

Please sign in to comment.