Skip to content

Commit

Permalink
Merge pull request #247 from Insire/migrate_cakefrosting_to_latest
Browse files Browse the repository at this point in the history
migrate Cake.Frosting from 1.3.0 to 2.2.0
  • Loading branch information
Insire authored Sep 11, 2022
2 parents 160e824 + f62748c commit 3a1083e
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 101 deletions.
68 changes: 0 additions & 68 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,70 +1,2 @@
#!/usr/bin/env pwsh
$DotNetInstallerUri = 'https://dot.net/v1/dotnet-install.ps1';
$DotNetUnixInstallerUri = 'https://dot.net/v1/dotnet-install.sh'
$DotNetChannel = 'LTS'
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent

[string] $DotNetVersion= ''
foreach($line in Get-Content (Join-Path $PSScriptRoot 'build.config'))
{
if ($line -like 'DOTNET_VERSION=*') {
$DotNetVersion =$line.SubString(15)
}
}


if ([string]::IsNullOrEmpty($DotNetVersion)) {
'Failed to parse .NET Core SDK Version'
exit 1
}

$DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1";

# Make sure tools folder exists
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
$ToolPath = Join-Path $PSScriptRoot "tools"
if (!(Test-Path $ToolPath)) {
Write-Verbose "Creating tools directory..."
New-Item -Path $ToolPath -Type directory | out-null
}

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

Function Remove-PathVariable([string]$VariableToRemove)
{
$path = [Environment]::GetEnvironmentVariable("PATH", "User")
$newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove }
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User")
$path = [Environment]::GetEnvironmentVariable("PATH", "Process")
$newItems = $path.Split(';') | Where-Object { $_.ToString() -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;
}

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 -Version $DotNetVersion -InstallDir $InstallPath;

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

###########################################################################
# RUN BUILD SCRIPT
###########################################################################

dotnet run --project cake/Build.csproj -- $args
exit $LASTEXITCODE;
16 changes: 8 additions & 8 deletions cake/Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@

<ItemGroup>
<PackageReference Include="Cake.Codecov" Version="1.0.1" />
<PackageReference Include="Cake.Frosting" Version="1.3.0" />
<PackageReference Include="Cake.GitVersioning" Version="3.4.244" />
<PackageReference Include="Cake.Incubator" Version="6.0.0" />
<PackageReference Include="Codecov" Version="1.13.0" />
<PackageReference Include="GitVersion.CommandLine" Version="5.8.1">
<PackageReference Include="Cake.Frosting" Version="2.2.0" />
<PackageReference Include="Cake.GitVersioning" Version="3.5.109" />
<PackageReference Include="Cake.Incubator" Version="7.0.0" />
<PackageReference Include="CodecovUploader" Version="0.2.4" />
<PackageReference Include="GitVersion.CommandLine" Version="5.10.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeCoverage" Version="17.0.0" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.12.0" />
<PackageReference Include="ReportGenerator" Version="5.0.0" />
<PackageReference Include="Microsoft.CodeCoverage" Version="17.3.1" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.15.2" />
<PackageReference Include="ReportGenerator" Version="5.1.10" />
</ItemGroup>
</Project>
12 changes: 6 additions & 6 deletions cake/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ public static class Program
public static int Main(string[] args)
{
return new CakeHost()
.InstallTool(new Uri("nuget:?package=Codecov&version=1.13.0"))
.InstallTool(new Uri("nuget:?package=NUnit.ConsoleRunner&version=3.12.0"))
.InstallTool(new Uri("nuget:?package=ReportGenerator&version=4.8.13"))
.InstallTool(new Uri("nuget:?package=GitVersion.CommandLine&version=5.7.0"))
.InstallTool(new Uri("nuget:?package=Microsoft.CodeCoverage&version=16.11.0"))
.InstallTool(new Uri("nuget:?package=nuget.commandline&version=5.11.0"))
.InstallTool(new Uri("nuget:?package=CodecovUploader&version=0.2.4"))
.InstallTool(new Uri("nuget:?package=NUnit.ConsoleRunner&version=3.15.2"))
.InstallTool(new Uri("nuget:?package=ReportGenerator&version=5.1.10"))
.InstallTool(new Uri("nuget:?package=GitVersion.CommandLine&version=5.10.3"))
.InstallTool(new Uri("nuget:?package=Microsoft.CodeCoverage&version=17.3.1"))
.InstallTool(new Uri("nuget:?package=nuget.commandline&version=6.2.1"))
.UseContext<BuildContext>()
.UseLifetime<BuildLifetime>()
.UseWorkingDirectory("..")
Expand Down
2 changes: 1 addition & 1 deletion cake/Tasks/CoberturaReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Build
{
[Dependency(typeof(ConvertCoverage))]
[IsDependentOn(typeof(ConvertCoverage))]
public sealed class CoberturaReport : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
Expand Down
2 changes: 1 addition & 1 deletion cake/Tasks/ConvertCoverage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Build
{
[Dependency(typeof(Test))]
[IsDependentOn(typeof(Test))]
public sealed class ConvertCoverage : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
Expand Down
16 changes: 8 additions & 8 deletions cake/Tasks/Default.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Build
{
[Dependency(typeof(CleanSolution))]
[Dependency(typeof(UpdateAssemblyInfo))]
[Dependency(typeof(TestAndUploadReport))]
[Dependency(typeof(CleanSolutionAgain))]
[Dependency(typeof(BuildAndPack))]
[Dependency(typeof(PushNuget))]
[Dependency(typeof(PushGithub))]
[Dependency(typeof(PushLocally))]
[IsDependentOn(typeof(CleanSolution))]
[IsDependentOn(typeof(UpdateAssemblyInfo))]
[IsDependentOn(typeof(TestAndUploadReport))]
[IsDependentOn(typeof(CleanSolutionAgain))]
[IsDependentOn(typeof(BuildAndPack))]
[IsDependentOn(typeof(PushNuget))]
[IsDependentOn(typeof(PushGithub))]
[IsDependentOn(typeof(PushLocally))]
public sealed class Default : FrostingTask<BuildContext>
{
}
Expand Down
2 changes: 1 addition & 1 deletion cake/Tasks/HtmlReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Build
{
[Dependency(typeof(ConvertCoverage))]
[IsDependentOn(typeof(ConvertCoverage))]
public sealed class HtmlReport : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
Expand Down
2 changes: 1 addition & 1 deletion cake/Tasks/PushGithub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override void Run(BuildContext context)
public override bool ShouldRun(BuildContext context)
{
return base.ShouldRun(context)
&& (context.BuildSystem().IsRunningOnAzurePipelines || context.BuildSystem().IsRunningOnAzurePipelinesHosted)
&& context.BuildSystem().IsRunningOnAzurePipelines
&& !string.IsNullOrEmpty(context.EnvironmentVariable("GITHUB_APIKEY"))
&& !context.IsPublicRelease;
}
Expand Down
2 changes: 1 addition & 1 deletion cake/Tasks/PushNuget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override void Run(BuildContext context)
public override bool ShouldRun(BuildContext context)
{
return base.ShouldRun(context)
&& (context.BuildSystem().IsRunningOnAzurePipelines || context.BuildSystem().IsRunningOnAzurePipelinesHosted)
&& context.BuildSystem().IsRunningOnAzurePipelines
&& !string.IsNullOrEmpty(context.EnvironmentVariable("NUGETORG_APIKEY"))
&& context.IsPublicRelease;
}
Expand Down
4 changes: 2 additions & 2 deletions cake/Tasks/Test.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Cake.Common.Tools.DotNetCore;
using Cake.Common.Tools.DotNet;
using Cake.Common.Tools.DotNetCore.Test;
using Cake.Core;
using Cake.Frosting;
Expand Down Expand Up @@ -27,7 +27,7 @@ public override void Run(BuildContext context)
.Append($"--logger:trx;"),
};

context.DotNetCoreTest(projectFile, testSettings);
context.DotNetTest(projectFile, testSettings);
}

private static bool HandleExitCode(int code)
Expand Down
4 changes: 2 additions & 2 deletions cake/Tasks/TestAndUploadReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Build
{
[Dependency(typeof(HtmlReport))]
[Dependency(typeof(UploadCodecovReport))]
[IsDependentOn(typeof(HtmlReport))]
[IsDependentOn(typeof(UploadCodecovReport))]
public sealed class TestAndUploadReport : FrostingTask<BuildContext>
{
}
Expand Down
2 changes: 1 addition & 1 deletion cake/Tasks/UploadCodecovReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Build
{
[Dependency(typeof(CoberturaReport))]
[IsDependentOn(typeof(CoberturaReport))]
public sealed class UploadCodecovReport : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
Expand Down
4 changes: 3 additions & 1 deletion src/SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@

[assembly: AssemblyCompany("SoftThorn")]
[assembly: AssemblyProduct("MvvmScarletToolkit")]
[assembly: AssemblyCopyright("© 2021 Insire")]
[assembly: AssemblyCopyright("© 2022 Insire")]
[assembly: AssemblyTrademark("")]
// Metadata Attributes
[assembly: AssemblyMetadata("Platform", "AnyCPU")]

0 comments on commit 3a1083e

Please sign in to comment.