add unit tests. It's about time!

This commit is contained in:
Timothy Baldridge 2019-09-23 22:20:24 -06:00
parent c471a817d2
commit a21edfd2f1
13 changed files with 496 additions and 35 deletions

View File

@ -28,10 +28,18 @@ namespace VFS
static VirtualFileSystem()
{
VFS = new VirtualFileSystem();
RootFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
var entry = Assembly.GetEntryAssembly();
if (entry != null && !string.IsNullOrEmpty(entry.Location))
{
RootFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
_stagedRoot = Path.Combine(RootFolder, "vfs_staged_files");
}
}
public static void Reconfigure(string root)
{
RootFolder = root;
_stagedRoot = Path.Combine(RootFolder, "vfs_staged_files");
}
public static void Clean()
@ -51,7 +59,7 @@ namespace VFS
LoadFromDisk();
}
public static string RootFolder { get; }
public static string RootFolder { get; private set; }
public Dictionary<string, IEnumerable<VirtualFile>> HashIndex { get; private set; }
public VirtualFile this[string path] => Lookup(path);

View File

@ -17,6 +17,7 @@ namespace Wabbajack.Common
public static int MaxQueueSize;
public static int CurrentQueueSize;
private static bool _inited;
public static Action<int, string, int> ReportFunction { get; private set; }
public static Action<int, int> ReportQueueSize { get; private set; }
@ -28,7 +29,10 @@ namespace Wabbajack.Common
ReportFunction = report_function;
ReportQueueSize = report_queue_size;
ThreadCount = Environment.ProcessorCount;
if (_inited) return;
StartThreads();
_inited = true;
}
private static void StartThreads()

View File

@ -0,0 +1,20 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Wabbajack.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Wabbajack.Test")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("a47fff32-782b-4d9f-8704-c98fb32fa8cc")]
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using Alphaleonis.Win32.Filesystem;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
using VFS;
using Wabbajack.Common;
namespace Wabbajack.Test
{
[TestClass]
public class SanityTests
{
public TestContext TestContext { get; set; }
[TestMethod]
public void TestDirectMatch()
{
var utils = new TestUtils();
utils.GameName = "Skyrim Special Edition";
var profile = utils.AddProfile();
var mod = utils.AddMod();
var test_pex = utils.AddModFile(mod, @"Data\scripts\test.pex", 10);
utils.Configure();
utils.AddManualDownload(
new Dictionary<string, byte[]>() {{"/baz/biz.pex", File.ReadAllBytes(test_pex)}});
Utils.SetStatusFn((f, idx) => { });
Utils.SetLoggerFn(f => TestContext.WriteLine(f));
WorkQueue.Init((x, y, z) => { }, (min, max) => { });
VirtualFileSystem.Reconfigure(utils.TestFolder);
var compiler = new Compiler(utils.MO2Folder, msg => TestContext.WriteLine(msg));
compiler.ShowReportWhenFinished = false;
compiler.MO2Profile = profile;
Assert.IsTrue(compiler.Compile());
var installer = new Installer(compiler.ModList, utils.InstallFolder, TestContext.WriteLine);
installer.DownloadFolder = utils.DownloadsFolder;
installer.GameFolder = utils.GameFolder;
installer.Install();
utils.VerifyInstalledFile(mod, @"Data\scripts\test.pex");
utils.Dispose();
}
}
}

175
Wabbajack.Test/TestUtils.cs Normal file
View File

@ -0,0 +1,175 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Wabbajack.Common;
using Directory = Alphaleonis.Win32.Filesystem.Directory;
using File = Alphaleonis.Win32.Filesystem.File;
using Path = Alphaleonis.Win32.Filesystem.Path;
namespace Wabbajack.Test
{
public class TestUtils : IDisposable
{
public TestUtils()
{
RNG = new Random();
ID = RandomName();
WorkingDirectory = Path.Combine(Directory.GetCurrentDirectory(), "tmp_data");
}
public string WorkingDirectory { get;}
public string ID { get; }
public Random RNG { get; }
public string GameName { get; set; }
public string TestFolder => Path.Combine(WorkingDirectory, ID);
public string GameFolder => Path.Combine(WorkingDirectory, ID, "game_folder");
public string MO2Folder => Path.Combine(WorkingDirectory, ID, "mo2_folder");
public string ModsFolder => Path.Combine(MO2Folder, "mods");
public string DownloadsFolder => Path.Combine(MO2Folder, "downloads");
public string InstallFolder => Path.Combine(TestFolder, "installed");
public void Configure()
{
File.WriteAllLines(Path.Combine(MO2Folder, "ModOrganizer.ini"), new []
{
"[General]",
$"gameName={GameName}",
$"gamePath={GameFolder.Replace("\\", "\\\\")}",
});
Directory.CreateDirectory(DownloadsFolder);
Directory.CreateDirectory(GameFolder);
Profiles.Do(profile =>
{
File.WriteAllLines(Path.Combine(MO2Folder, "profiles", profile, "modlist.txt"),
Mods.Select(s => $"+{s}").ToArray());
});
}
public string AddProfile()
{
string profile_name = RandomName();
Directory.CreateDirectory(Path.Combine(MO2Folder, "profiles", profile_name));
Profiles.Add(profile_name);
return profile_name;
}
public HashSet<string> Profiles = new HashSet<string>();
public string AddMod()
{
string mod_name = RandomName();
Directory.CreateDirectory(Path.Combine(MO2Folder, "mods", mod_name));
Mods.Add(mod_name);
return mod_name;
}
public List<string> Mods = new List<string>();
/// <summary>
/// Adds a file to the given mod with a given path in the mod. Fills it with random data unless
/// random_fill == 0;
/// </summary>
/// <param name="mod_name"></param>
/// <param name="path"></param>
/// <param name="random_fill"></param>
/// <returns></returns>
public string AddModFile(string mod_name, string path, int random_fill=128)
{
byte[] bytes = new byte[0];
if (random_fill != 0)
{
bytes = new byte[random_fill];
RNG.NextBytes(bytes);
}
var full_path = Path.Combine(ModsFolder, mod_name, path);
Directory.CreateDirectory(Path.GetDirectoryName(full_path));
File.WriteAllBytes(full_path, bytes);
return full_path;
}
public void Dispose()
{
var exts = new [] {".md", ".exe"};
Directory.Delete(Path.Combine(WorkingDirectory, ID), true);
Profiles.Do(p =>
{
foreach (var ext in exts) {
var path = Path.Combine(Directory.GetCurrentDirectory(), p + ext);
if (File.Exists(path))
File.Delete(path);
}
});
}
/// <summary>
/// Returns a random string name (with spaces)
/// </summary>
private char[] _nameChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'+=-_ ".ToCharArray();
public string RandomName()
{
return Guid.NewGuid().ToString();
}
public string AddManualDownload(Dictionary<string, byte[]> contents)
{
var name = RandomName() + ".zip";
using(FileStream fs = new FileStream(Path.Combine(DownloadsFolder, name), FileMode.Create))
using (ZipArchive archive = new ZipArchive(fs, ZipArchiveMode.Create))
{
contents.Do(kv =>
{
var entry = archive.CreateEntry(kv.Key);
using (var os = entry.Open())
os.Write(kv.Value, 0, kv.Value.Length);
});
}
File.WriteAllLines(Path.Combine(DownloadsFolder, name+".meta"),
new string[]
{
"[General]",
"manualURL=<TESTING>"
});
return name;
}
public void VerifyInstalledFile(string mod, string file)
{
var src = Path.Combine(MO2Folder, "mods", mod, file);
Assert.IsTrue(File.Exists(src), src);
var dest = Path.Combine(InstallFolder, "mods", mod, file);
Assert.IsTrue(File.Exists(dest), dest);
var src_data = File.ReadAllBytes(src);
var dest_data = File.ReadAllBytes(dest);
Assert.AreEqual(src_data.Length, dest_data.Length);
for(int x = 0; x < src_data.Length; x++)
{
if (src_data[x] != dest_data[x])
Assert.Fail($"Index {x} of {mod}\\{file} are not the same");
}
}
}
}

View File

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Wabbajack.Test</RootNamespace>
<AssemblyName>Wabbajack.Test</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="AlphaFS, Version=2.2.0.0, Culture=neutral, PublicKeyToken=4d31a58f7d7ad5c9, processorArchitecture=MSIL">
<HintPath>..\packages\AlphaFS.2.2.6\lib\net452\AlphaFS.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Transactions" />
</ItemGroup>
<ItemGroup>
<Compile Include="TestUtils.cs" />
<Compile Include="SanityTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VirtualFileSystem\VirtualFileSystem.csproj">
<Project>{5128b489-bc28-4f66-9f0b-b4565af36cbc}</Project>
<Name>VirtualFileSystem</Name>
</ProjectReference>
<ProjectReference Include="..\Wabbajack.Common\Wabbajack.Common.csproj">
<Project>{b3f3fb6e-b9eb-4f49-9875-d78578bc7ae5}</Project>
<Name>Wabbajack.Common</Name>
</ProjectReference>
<ProjectReference Include="..\Wabbajack\Wabbajack.csproj">
<Project>{33602679-8484-40c7-a10c-774dff5d8314}</Project>
<Name>Wabbajack</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets'))" />
</Target>
<Import Project="..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" />
</Project>

11
Wabbajack.Test/app.config Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AlphaFS" version="2.2.6" targetFramework="net472" />
<package id="MSTest.TestAdapter" version="1.3.2" targetFramework="net472" />
<package id="MSTest.TestFramework" version="1.3.2" targetFramework="net472" />
</packages>

View File

@ -27,61 +27,126 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wabbajack.WebAutomation", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wabbajack.WebAutomation.Test", "Wabbajack.WebAutomation.Test\Wabbajack.WebAutomation.Test.csproj", "{73D0B663-A6FB-4A67-B945-EBB4A234C996}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wabbajack.Test", "Wabbajack.Test\Wabbajack.Test.csproj", "{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug (no commandargs)|Any CPU = Debug (no commandargs)|Any CPU
Debug (no commandargs)|x64 = Debug (no commandargs)|x64
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|Any CPU
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug (no commandargs)|Any CPU.Build.0 = Debug|Any CPU
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug (no commandargs)|x64.ActiveCfg = Debug|x64
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug (no commandargs)|x64.Build.0 = Debug|x64
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug|x64.ActiveCfg = Debug|x64
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug|x64.Build.0 = Debug|x64
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Release|Any CPU.Build.0 = Release|Any CPU
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Release|x64.ActiveCfg = Release|x64
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Release|x64.Build.0 = Release|x64
{33602679-8484-40C7-A10C-774DFF5D8314}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug (no commandargs)|Any CPU
{33602679-8484-40C7-A10C-774DFF5D8314}.Debug (no commandargs)|Any CPU.Build.0 = Debug (no commandargs)|Any CPU
{33602679-8484-40C7-A10C-774DFF5D8314}.Debug (no commandargs)|x64.ActiveCfg = Debug (no commandargs)|x64
{33602679-8484-40C7-A10C-774DFF5D8314}.Debug (no commandargs)|x64.Build.0 = Debug (no commandargs)|x64
{33602679-8484-40C7-A10C-774DFF5D8314}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33602679-8484-40C7-A10C-774DFF5D8314}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33602679-8484-40C7-A10C-774DFF5D8314}.Debug|x64.ActiveCfg = Debug|x64
{33602679-8484-40C7-A10C-774DFF5D8314}.Debug|x64.Build.0 = Debug|x64
{33602679-8484-40C7-A10C-774DFF5D8314}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33602679-8484-40C7-A10C-774DFF5D8314}.Release|Any CPU.Build.0 = Release|Any CPU
{33602679-8484-40C7-A10C-774DFF5D8314}.Release|x64.ActiveCfg = Release|x64
{33602679-8484-40C7-A10C-774DFF5D8314}.Release|x64.Build.0 = Release|x64
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|Any CPU
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug (no commandargs)|Any CPU.Build.0 = Debug|Any CPU
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug (no commandargs)|x64.ActiveCfg = Debug|x64
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug (no commandargs)|x64.Build.0 = Debug|x64
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug|x64.ActiveCfg = Debug|x64
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug|x64.Build.0 = Debug|x64
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Release|Any CPU.Build.0 = Release|Any CPU
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Release|x64.ActiveCfg = Release|x64
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Release|x64.Build.0 = Release|x64
{BA2CFEA1-072B-42D6-822A-8C6D0E3AE5D9}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|Any CPU
{BA2CFEA1-072B-42D6-822A-8C6D0E3AE5D9}.Debug (no commandargs)|Any CPU.Build.0 = Debug|Any CPU
{BA2CFEA1-072B-42D6-822A-8C6D0E3AE5D9}.Debug (no commandargs)|x64.ActiveCfg = Debug|x64
{BA2CFEA1-072B-42D6-822A-8C6D0E3AE5D9}.Debug (no commandargs)|x64.Build.0 = Debug|x64
{BA2CFEA1-072B-42D6-822A-8C6D0E3AE5D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BA2CFEA1-072B-42D6-822A-8C6D0E3AE5D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BA2CFEA1-072B-42D6-822A-8C6D0E3AE5D9}.Debug|x64.ActiveCfg = Debug|x64
{BA2CFEA1-072B-42D6-822A-8C6D0E3AE5D9}.Debug|x64.Build.0 = Debug|x64
{BA2CFEA1-072B-42D6-822A-8C6D0E3AE5D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BA2CFEA1-072B-42D6-822A-8C6D0E3AE5D9}.Release|Any CPU.Build.0 = Release|Any CPU
{BA2CFEA1-072B-42D6-822A-8C6D0E3AE5D9}.Release|x64.ActiveCfg = Release|x64
{BA2CFEA1-072B-42D6-822A-8C6D0E3AE5D9}.Release|x64.Build.0 = Release|x64
{5128B489-BC28-4F66-9F0B-B4565AF36CBC}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|Any CPU
{5128B489-BC28-4F66-9F0B-B4565AF36CBC}.Debug (no commandargs)|Any CPU.Build.0 = Debug|Any CPU
{5128B489-BC28-4F66-9F0B-B4565AF36CBC}.Debug (no commandargs)|x64.ActiveCfg = Debug|Any CPU
{5128B489-BC28-4F66-9F0B-B4565AF36CBC}.Debug (no commandargs)|x64.Build.0 = Debug|Any CPU
{5128B489-BC28-4F66-9F0B-B4565AF36CBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5128B489-BC28-4F66-9F0B-B4565AF36CBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5128B489-BC28-4F66-9F0B-B4565AF36CBC}.Debug|x64.ActiveCfg = Debug|Any CPU
{5128B489-BC28-4F66-9F0B-B4565AF36CBC}.Debug|x64.Build.0 = Debug|Any CPU
{5128B489-BC28-4F66-9F0B-B4565AF36CBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5128B489-BC28-4F66-9F0B-B4565AF36CBC}.Release|Any CPU.Build.0 = Release|Any CPU
{5128B489-BC28-4F66-9F0B-B4565AF36CBC}.Release|x64.ActiveCfg = Release|Any CPU
{5128B489-BC28-4F66-9F0B-B4565AF36CBC}.Release|x64.Build.0 = Release|Any CPU
{A2913DFE-18FF-468B-A6C1-55F7C0CC0CE8}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|Any CPU
{A2913DFE-18FF-468B-A6C1-55F7C0CC0CE8}.Debug (no commandargs)|Any CPU.Build.0 = Debug|Any CPU
{A2913DFE-18FF-468B-A6C1-55F7C0CC0CE8}.Debug (no commandargs)|x64.ActiveCfg = Debug|Any CPU
{A2913DFE-18FF-468B-A6C1-55F7C0CC0CE8}.Debug (no commandargs)|x64.Build.0 = Debug|Any CPU
{A2913DFE-18FF-468B-A6C1-55F7C0CC0CE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A2913DFE-18FF-468B-A6C1-55F7C0CC0CE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A2913DFE-18FF-468B-A6C1-55F7C0CC0CE8}.Debug|x64.ActiveCfg = Debug|Any CPU
{A2913DFE-18FF-468B-A6C1-55F7C0CC0CE8}.Debug|x64.Build.0 = Debug|Any CPU
{A2913DFE-18FF-468B-A6C1-55F7C0CC0CE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2913DFE-18FF-468B-A6C1-55F7C0CC0CE8}.Release|Any CPU.Build.0 = Release|Any CPU
{A2913DFE-18FF-468B-A6C1-55F7C0CC0CE8}.Release|x64.ActiveCfg = Release|Any CPU
{A2913DFE-18FF-468B-A6C1-55F7C0CC0CE8}.Release|x64.Build.0 = Release|Any CPU
{E5A6F0E6-F79E-460D-82E2-E6330ACE06BA}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|Any CPU
{E5A6F0E6-F79E-460D-82E2-E6330ACE06BA}.Debug (no commandargs)|Any CPU.Build.0 = Debug|Any CPU
{E5A6F0E6-F79E-460D-82E2-E6330ACE06BA}.Debug (no commandargs)|x64.ActiveCfg = Debug|x64
{E5A6F0E6-F79E-460D-82E2-E6330ACE06BA}.Debug (no commandargs)|x64.Build.0 = Debug|x64
{E5A6F0E6-F79E-460D-82E2-E6330ACE06BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E5A6F0E6-F79E-460D-82E2-E6330ACE06BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E5A6F0E6-F79E-460D-82E2-E6330ACE06BA}.Debug|x64.ActiveCfg = Debug|Any CPU
{E5A6F0E6-F79E-460D-82E2-E6330ACE06BA}.Debug|x64.Build.0 = Debug|Any CPU
{E5A6F0E6-F79E-460D-82E2-E6330ACE06BA}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{E5A6F0E6-F79E-460D-82E2-E6330ACE06BA}.Release|Any CPU.Build.0 = Debug|Any CPU
{E5A6F0E6-F79E-460D-82E2-E6330ACE06BA}.Release|x64.ActiveCfg = Debug|Any CPU
{E5A6F0E6-F79E-460D-82E2-E6330ACE06BA}.Release|x64.Build.0 = Debug|Any CPU
{73D0B663-A6FB-4A67-B945-EBB4A234C996}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|Any CPU
{73D0B663-A6FB-4A67-B945-EBB4A234C996}.Debug (no commandargs)|Any CPU.Build.0 = Debug|Any CPU
{73D0B663-A6FB-4A67-B945-EBB4A234C996}.Debug (no commandargs)|x64.ActiveCfg = Debug|x64
{73D0B663-A6FB-4A67-B945-EBB4A234C996}.Debug (no commandargs)|x64.Build.0 = Debug|x64
{73D0B663-A6FB-4A67-B945-EBB4A234C996}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73D0B663-A6FB-4A67-B945-EBB4A234C996}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73D0B663-A6FB-4A67-B945-EBB4A234C996}.Debug|x64.ActiveCfg = Debug|Any CPU
{73D0B663-A6FB-4A67-B945-EBB4A234C996}.Debug|x64.Build.0 = Debug|Any CPU
{73D0B663-A6FB-4A67-B945-EBB4A234C996}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73D0B663-A6FB-4A67-B945-EBB4A234C996}.Release|Any CPU.Build.0 = Release|Any CPU
{73D0B663-A6FB-4A67-B945-EBB4A234C996}.Release|x64.ActiveCfg = Release|Any CPU
{73D0B663-A6FB-4A67-B945-EBB4A234C996}.Release|x64.Build.0 = Release|Any CPU
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|Any CPU
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Debug (no commandargs)|Any CPU.Build.0 = Debug|Any CPU
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Debug (no commandargs)|x64.ActiveCfg = Debug|x64
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Debug (no commandargs)|x64.Build.0 = Debug|x64
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Debug|x64.ActiveCfg = Debug|Any CPU
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Debug|x64.Build.0 = Debug|Any CPU
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Release|Any CPU.Build.0 = Release|Any CPU
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Release|x64.ActiveCfg = Release|Any CPU
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -47,6 +47,8 @@ namespace Wabbajack
public dynamic MO2Ini { get; }
public string GamePath { get; }
public bool ShowReportWhenFinished { get; set; } = true;
public bool IgnoreMissingFiles { get; set; }
public string MO2DownloadsFolder
@ -105,7 +107,7 @@ namespace Wabbajack
throw new Exception(msg);
}
public void Compile()
public bool Compile()
{
VirtualFileSystem.Clean();
Info("Looking for other profiles");
@ -217,7 +219,7 @@ namespace Wabbajack
else
{
Info("Exiting due to no way to compile these files");
return;
return false;
}
}
@ -225,10 +227,13 @@ namespace Wabbajack
Info("Getting nexus api_key please click authorize if a browser window appears");
NexusKey = GetNexusAPIKey();
User = GetUserStatus(NexusKey);
if (IndexedArchives.OfType<NexusMod>().Any())
{
NexusKey = GetNexusAPIKey();
User = GetUserStatus(NexusKey);
if (!User.is_premium) Info($"User {User.name} is not a premium Nexus user, cannot continue");
if (!User.is_premium) Info($"User {User.name} is not a premium Nexus user, cannot continue");
}
zEditIntegration.VerifyMerges(this);
@ -250,10 +255,13 @@ namespace Wabbajack
ShowReport();
Info("Done Building Modpack");
return true;
}
private void ShowReport()
{
if (!ShowReportWhenFinished) return;
var file = Path.GetTempFileName() + ".html";
File.WriteAllText(file, ModList.ReportHTML);
Process.Start(file);
@ -445,13 +453,6 @@ namespace Wabbajack
result = tmp;
}
else if (general.manualURL != null)
{
result = new ManualURLArchive
{
URL = general.manualURL.ToString()
};
}
else if (general.modID != null && general.fileID != null && general.gameName != null)
{
var nm = new NexusMod
@ -467,6 +468,14 @@ namespace Wabbajack
nm.UploaderProfile = info.uploaded_users_profile_url;
result = nm;
}
else if (general.manualURL != null)
{
result = new ManualArchive
{
URL = general.manualURL,
Notes = general.manualNotes,
};
}
else
{
Error("No way to handle archive {0} but it's required by the modlist", found.Name);
@ -478,6 +487,8 @@ namespace Wabbajack
result.Meta = found.Meta;
result.Size = found.File.Size;
if (result is ManualArchive) return result;
Info($"Checking link for {found.Name}");
var installer = new Installer(null, "", Utils.Log);

View File

@ -194,6 +194,13 @@ namespace Wabbajack
public string Version;
}
[Serializable]
public class ManualArchive : Archive
{
public string URL;
public string Notes;
}
[Serializable]
public class GoogleDriveMod : Archive
{
@ -212,15 +219,6 @@ namespace Wabbajack
public string URL;
}
/// <summary>
/// A URL that cannot be downloaded automatically and has to be downloaded by hand
/// </summary>
[Serializable]
public class ManualURLArchive : Archive
{
public string URL;
}
/// <summary>
/// An archive that requires additional HTTP headers.
/// </summary>

View File

@ -48,7 +48,7 @@ namespace Wabbajack
public string NexusAPIKey { get; set; }
public bool IgnoreMissingFiles { get; internal set; }
public string GameFolder { get; private set; }
public string GameFolder { get; set; }
public void Info(string msg, params object[] args)
{
@ -99,8 +99,7 @@ namespace Wabbajack
}
}
if (ModList.Directives.OfType<RemappedInlineFile>().FirstOrDefault() != null ||
ModList.Directives.OfType<CleanedESM>().FirstOrDefault() != null)
if (GameFolder == null)
{
MessageBox.Show(
"In order to do a proper install Wabbajack needs to know where your game folder resides. This is most likely " +
@ -408,15 +407,18 @@ namespace Wabbajack
Info("Missing {0} archives", missing.Count);
Info("Getting Nexus API Key, if a browser appears, please accept");
NexusAPIKey = NexusAPI.GetNexusAPIKey();
var user_status = NexusAPI.GetUserStatus(NexusAPIKey);
if (!user_status.is_premium)
if (ModList.Archives.OfType<NexusMod>().Any())
{
Info(
$"Automated installs with Wabbajack requires a premium nexus account. {user_status.name} is not a premium account");
return;
NexusAPIKey = NexusAPI.GetNexusAPIKey();
var user_status = NexusAPI.GetUserStatus(NexusAPIKey);
if (!user_status.is_premium)
{
Info(
$"Automated installs with Wabbajack requires a premium nexus account. {user_status.name} is not a premium account");
return;
}
}
DownloadMissingArchives(missing);

View File

@ -19,6 +19,7 @@ namespace Wabbajack
public static string FindzEditPath(Compiler compiler)
{
var executables = compiler.MO2Ini.customExecutables;
if (executables.size == null) return null;
foreach (var idx in Enumerable.Range(1, int.Parse(executables.size)))
{