Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ jobs:
- name: Create Net Core Release
# use publish for .NET Core
run: dotnet publish ${{ env.TOOL_PROJ_PATH }} --configuration Release -f net10.0 --output ./releases/net10.0 /p:DebugType=None /p:DebugSymbols=false
- name: Create Linux Release
run: dotnet publish ${{ env.TOOL_PROJ_PATH }} --configuration Release -f net10.0 --runtime linux-x64 --self-contained true --output ./releases/linux-x64 /p:DebugType=None /p:DebugSymbols=false
- name: Upload a Build Artifact
uses: actions/upload-artifact@v7
with:
Expand Down Expand Up @@ -109,12 +111,13 @@ jobs:
# Create a GitHub release on push to main only
if: |
github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: softprops/action-gh-release@v2
uses: softprops/action-gh-release@v3
with:
name: v${{ steps.nbgv.outputs.SemVer2 }}
tag_name: v${{ steps.nbgv.outputs.SemVer2 }}
token: ${{ secrets.GITHUB_TOKEN }}
generate_release_notes: true
files: |
./releases/net481/ModVerify.exe
./releases/ModVerify-Net10.zip
./releases/ModVerify-Net10.zip
./releases/linux-x64/ModVerify
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<ItemGroup>
<PackageReference Update="SauceControl.InheritDoc" Version="2.0.2" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.201" PrivateAssets="All"/>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.203" PrivateAssets="All"/>
<PackageReference Include="Nerdbank.GitVersioning" Condition="!Exists('packages.config')">
<PrivateAssets>all</PrivateAssets>
<Version>3.9.50</Version>
Expand Down
2 changes: 2 additions & 0 deletions ModVerify.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<Project Path="modules/ModdingToolBase/src/Updater/ExternalUpdater.Core/ExternalUpdater.Core.csproj" />
</Folder>
<Folder Name="/PetroglyphTools/">
<Project Path="src/PetroglyphTools/PG.StarWarsGame.Engine.FileSystem.Test/PG.StarWarsGame.Engine.FileSystem.Test.csproj" />
<Project Path="src/PetroglyphTools/PG.StarWarsGame.Engine.FileSystem/PG.StarWarsGame.Engine.FileSystem.csproj" />
<Project Path="src/PetroglyphTools/PG.StarWarsGame.Engine/PG.StarWarsGame.Engine.csproj" />
<Project Path="src/PetroglyphTools/PG.StarWarsGame.Files.ALO/PG.StarWarsGame.Files.ALO.csproj" />
<Project Path="src/PetroglyphTools/PG.StarWarsGame.Files.ChunkFiles/PG.StarWarsGame.Files.ChunkFiles.csproj" />
Expand Down
43 changes: 40 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,42 @@ In general ModVerify has two operation mods.
1. `verify` Verifying a game or mod
2. `createBaseline` Creating a baseline for a game or mod, that can be used for further verifications in order to verify you did not add more errors to your mods.

### Example
This is an example run configuration that analyzes a specific mod, uses a the FoC basline and writes the output into a dedicated directory:
### Examples

```bash
#### Example 1: Auto-detection with a custom baseline
Analyzes a specific mod, uses the FoC baseline and writes the output into a dedicated directory:

**Windows:**
```bat
.\ModVerify.exe verify --path "C:\My Games\FoC\Mods\MyMod" --outDir "C:\My Games\FoC\Mods\MyMod\verifyResults" --baseline ./focBaseline.json
```

**Linux:**
```bash
./ModVerify verify \
--path "/home/user/games/FoC/Mods/MyMod" \
--outDir "/home/user/games/FoC/Mods/MyMod/verifyResults" \
--baseline ./focBaseline.json
```

#### Example 2: Manual mod setup with sub-mods, EaW fallback and default baseline
Uses manual mod setup, including sub-mods and the EaW fallback game, and uses the default embedded baseline:

**Windows:**
```bat
.\ModVerify.exe verify --mods "C:\My Games\FoC\Mods\MySubMod;C:\My Games\FoC\Mods\MyMod" --game "C:\My Games\FoC" --fallbackGame "C:\My Games\EaW" --engine FOC --useDefaultBaseline
```

**Linux:**
```bash
./ModVerify verify \
--mods "/home/user/games/FoC/Mods/MySubMod:/home/user/games/FoC/Mods/MyMod" \
--game "/home/user/games/FoC" \
--fallbackGame "/home/user/games/EaW" \
--engine FOC \
--useDefaultBaseline
```

---

## Available Checks
Expand Down Expand Up @@ -116,6 +145,14 @@ The following verifiers are currently implemented:
If you want to create your own baseline use the `createBaseline` option.

### Example

**Windows**
```bash
ModVerify.exe createBaseline --outFile myBaseline.json --path "C:\My Games\FoC\Mods\MyMod"
```
**Linux**
```bash
./ModVerify createBaseline \
--outFile myBaseline.json \
--path "C:\My Games\FoC\Mods\MyMod"
```
31 changes: 31 additions & 0 deletions src/ModVerify.CliApp/App/ModVerifyApplicationAction.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO.Abstractions;
using System.Linq;
using System.Threading.Tasks;
using AET.ModVerify.App.GameFinder;
using AET.ModVerify.App.Reporting;
Expand All @@ -9,6 +10,7 @@
using AET.ModVerify.Reporting.Baseline;
using AET.ModVerify.Reporting.Suppressions;
using AnakinRaW.ApplicationBase;
using AnakinRaW.CommonUtilities.SimplePipeline;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

Expand Down Expand Up @@ -74,9 +76,34 @@ public async Task<int> ExecuteAsync()
var verificationResult = await VerifyTargetAsync(verificationTarget)
.ConfigureAwait(false);

Console.WriteLine();

switch (verificationResult.Status)
{
case VerificationCompletionStatus.Cancelled:
return ModVerifyConstants.VerifyCancelled;
case VerificationCompletionStatus.Failed:
return ReportVerificationFailure(verificationResult.Exception!);
}

return await ProcessResult(verificationResult);
}

private int ReportVerificationFailure(Exception verificationException)
{
var exceptionToReport = verificationException switch
{
AggregateException aggregate => aggregate.InnerExceptions.FirstOrDefault() ?? aggregate,
StepFailureException stepFailure => stepFailure.FailedSteps.First().Error!,
_ => verificationException
};

ConsoleUtilities.WriteApplicationFatalError(_appEnvironment.ApplicationName, exceptionToReport);
Logger?.LogError(exceptionToReport, exceptionToReport.Message);

return exceptionToReport.HResult;
}

protected abstract Task<int> ProcessResult(VerificationResult result);

protected abstract VerificationBaseline GetBaseline(VerificationTarget verificationTarget);
Expand Down Expand Up @@ -112,6 +139,10 @@ private async Task<VerificationResult> VerifyTargetAsync(VerificationTarget veri
case VerificationCompletionStatus.Cancelled:
Logger?.LogWarning(ModVerifyConstants.ConsoleEventId, "Verification was cancelled.");
break;
case VerificationCompletionStatus.Failed:
progressReporter.ReportError("Verification failed!",
$"An unexpected error occurred while verifying '{verificationTarget.Name}'.");
break;
case VerificationCompletionStatus.Completed:
default:
Logger?.LogInformation(ModVerifyConstants.ConsoleEventId, "Verification completed successfully.");
Expand Down
3 changes: 2 additions & 1 deletion src/ModVerify.CliApp/App/VerifyAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ protected override VerificationBaseline GetBaseline(VerificationTarget verificat
{
Console.WriteLine();
ModVerifyConsoleUtilities.WriteBaselineInfo(baseline, baselinePath);
Logger?.LogDebug("Using baseline {Baseline} from location '{Path}'", baseline.ToString(), baselinePath);
Logger?.LogDebug("Using baseline {Baseline} from location '{Path}'",
baseline.ToString(), baselinePath ?? "Embedded");
Console.WriteLine();
}
return baseline;
Expand Down
18 changes: 9 additions & 9 deletions src/ModVerify.CliApp/ModVerify.CliApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
<PackageReference Include="Serilog.Extensions.Logging" Version="10.0.0" />
<PackageReference Include="AlamoEngineTools.SteamAbstraction" Version="5.0.7" />
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.5" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.5" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.5" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.5" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="10.0.5" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.7" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.7" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.7" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.7" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="10.0.7" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="3.0.0" />
Expand All @@ -51,7 +51,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Costura.Fody" Version="6.0.0">
<PackageReference Include="Costura.Fody" Version="6.1.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="PolySharp" Version="1.15.0">
Expand All @@ -62,15 +62,15 @@

<!-- Exclude System.Index from all dependencies, excluding Microsoft.Bcl.Memory -->
<ItemGroup>
<PackageReference Include="Vanara.Core" Version="5.0.1" Condition="'$(TargetFramework)' == 'net481'">
<PackageReference Include="Vanara.Core" Version="5.0.4" Condition="'$(TargetFramework)' == 'net481'">
<ExcludeAssets>compile</ExcludeAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="IndexRange" Version="1.1.0" Condition="'$(TargetFramework)' == 'net481'">
<PackageReference Include="IndexRange" Version="1.1.1" Condition="'$(TargetFramework)' == 'net481'">
<ExcludeAssets>compile</ExcludeAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Bcl.Memory" Version="10.0.5" Condition="'$(TargetFramework)' == 'net481'" />
<PackageReference Include="Microsoft.Bcl.Memory" Version="10.0.7" Condition="'$(TargetFramework)' == 'net481'" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/ModVerify.CliApp/ModVerifyConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal static class ModVerifyConstants
public const int Success = 0;
public const int CompletedWithFindings = 1;
public const int ErrorBadArguments = 0xA0;
public const int VerifyCancelled = -1;

public static readonly EventId ConsoleEventId = new(ConsoleEventIdValue, "LogToConsole");
}
18 changes: 16 additions & 2 deletions src/ModVerify.CliApp/Reporting/BaselineSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public VerificationBaseline SelectBaseline(VerificationTarget verificationTarget
}
}

if (!settings.ReportSettings.SearchBaselineLocally)
if (settings.ReportSettings is { SearchBaselineLocally: false, UseDefaultBaseline: false })
{
_logger?.LogDebug(ModVerifyConstants.ConsoleEventId,
"No baseline path specified and local search is not enabled. Using empty baseline.");
Expand Down Expand Up @@ -134,7 +134,7 @@ internal static VerificationBaseline LoadEmbeddedBaseline(GameEngineType engineT
private VerificationBaseline FindBaselineNonInteractive(VerificationTarget target, out string? usedPath)
{
if (_baselineFactory.TryFindBaselineInDirectory(
target.Location.TargetPath,
target.Location.TargetPath,
b => IsBaselineCompatible(b, target),
out var baseline,
out usedPath))
Expand All @@ -144,6 +144,20 @@ private VerificationBaseline FindBaselineNonInteractive(VerificationTarget targe
}
_logger?.LogTrace("No baseline file found in taget path '{TargetPath}'.", target.Location.TargetPath);
usedPath = null;
if (settings.ReportSettings.UseDefaultBaseline)
{
try
{
var defaultBaseline = LoadEmbeddedBaseline(target.Engine);
_logger?.LogInformation(ModVerifyConstants.ConsoleEventId, "Automatically applying default embedded baseline for engine '{Engine}'.", target.Engine);
return defaultBaseline;
}
catch (InvalidBaselineException)
{
throw new InvalidOperationException(
"Invalid baseline packed along ModVerify App. Please reach out to the creators. Thanks!");
}
}
return VerificationBaseline.Empty;
}

Expand Down
Loading
Loading