diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index e1a2c6025e..6ba6ae82c8 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -13,12 +13,6 @@ "commands": [ "dotnet-format" ] - }, - "codefilesanity": { - "version": "0.0.33", - "commands": [ - "CodeFileSanity" - ] } } } \ No newline at end of file diff --git a/InspectCode.ps1 b/InspectCode.ps1 new file mode 100644 index 0000000000..6ed935fdbb --- /dev/null +++ b/InspectCode.ps1 @@ -0,0 +1,27 @@ +[CmdletBinding()] +Param( + [string]$Target, + [string]$Configuration, + [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] + [string]$Verbosity, + [switch]$ShowDescription, + [Alias("WhatIf", "Noop")] + [switch]$DryRun, + [Parameter(Position = 0, Mandatory = $false, ValueFromRemainingArguments = $true)] + [string[]]$ScriptArgs +) + +# Build Cake arguments +$cakeArguments = ""; +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" } +$cakeArguments += $ScriptArgs + +dotnet tool restore +dotnet cake ./build/InspectCode.cake --bootstrap +dotnet cake ./build/InspectCode.cake $cakeArguments +exit $LASTEXITCODE \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 6c8f073419..20cf85f44b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,8 +10,8 @@ build: verbosity: minimal after_build: - ps: dotnet tool restore - - ps: dotnet CodeFileSanity - ps: dotnet format --dry-run --check + - ps: .\InspectCode.ps1 test: assemblies: except: diff --git a/build/InspectCode.cake b/build/InspectCode.cake new file mode 100644 index 0000000000..bd3fdf5f93 --- /dev/null +++ b/build/InspectCode.cake @@ -0,0 +1,52 @@ +#addin "nuget:?package=CodeFileSanity&version=0.0.33" +#addin "nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2019.2.1" +#tool "nuget:?package=NVika.MSBuild&version=1.0.1" +var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First(); + +/////////////////////////////////////////////////////////////////////////////// +// ARGUMENTS +/////////////////////////////////////////////////////////////////////////////// + +var target = Argument("target", "CodeAnalysis"); +var configuration = Argument("configuration", "Release"); + +var rootDirectory = new DirectoryPath(".."); +var sln = rootDirectory.CombineWithFilePath("osu.sln"); +var desktopSlnf = rootDirectory.CombineWithFilePath("osu.Desktop.slnf"); + +/////////////////////////////////////////////////////////////////////////////// +// TASKS +/////////////////////////////////////////////////////////////////////////////// + +// windows only because both inspectcode and nvika depend on net45 +Task("InspectCode") + .WithCriteria(IsRunningOnWindows()) + .Does(() => { + InspectCode(desktopSlnf, new InspectCodeSettings { + CachesHome = "inspectcode", + OutputFile = "inspectcodereport.xml", + ArgumentCustomization = arg => { + if (AppVeyor.IsRunningOnAppVeyor) // Don't flood CI output + arg.Append("--verbosity:WARN"); + return arg; + }, + }); + + int returnCode = StartProcess(nVikaToolPath, $@"parsereport ""inspectcodereport.xml"" --treatwarningsaserrors"); + if (returnCode != 0) + throw new Exception($"inspectcode failed with return code {returnCode}"); + }); + +Task("CodeFileSanity") + .Does(() => { + ValidateCodeSanity(new ValidateCodeSanitySettings { + RootDirectory = rootDirectory.FullPath, + IsAppveyorBuild = AppVeyor.IsRunningOnAppVeyor + }); + }); + +Task("CodeAnalysis") + .IsDependentOn("CodeFileSanity") + .IsDependentOn("InspectCode"); + +RunTarget(target); \ No newline at end of file