DaedalicEntertainment / ue4-test-automation

Facilitates setting up integration test suits with Unreal Engine 4 Gauntlet.
https://www.daedalic.com
MIT License
215 stars 61 forks source link

Not able to compile with target framework != .NET Core 3.1 #34

Open CorsiRiccardo opened 2 years ago

CorsiRiccardo commented 2 years ago

I downloaded the UE5 branch of your project,imported all,but I have problems with your .Automation Class Library.

I can see it in VS2019,but when I add the references to Gauntlet.Automation, it wont compile (says that Gauntlet.Automation tagets .NET core 3.1 framework)

When I imported your Library,it automatically imported it targeting 4.6.2 .NET framework (the newest installed on my machine). Am I missing something?

PanPandzik commented 2 years ago

You should create a new project in Visual Studio and choose Class Library C# (.NET, not .NET Framework). Create a new solution and add the existing DaedalicTestAutomationPlugin.Automation.csproj. Right-click on project DaedalicTestAutomationPlugin.Automation in VS and open Properties, go to the Build/Output path, and set Base output path to $(UNREAL_ENGINE_5_PATH)\Engine\Binaries\DotNET\AutomationScripts. Next, to Dependencies of VS project add the reference to the project Gauntlet.Automation in your UE engine. Delete Properties folder from Build\Scripts\DaedalicTestAutomationPlugin.Automation in your UE4 project directory.

Also, instead of all these above, you can just edit DaedalicTestAutomationPlugin.Automation.csproj in Visual Studio or any text editor and replace the content with that

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <Configurations>Debug;Development</Configurations>
    <BaseOutputPath>$(UNREAL_ENGINE_5_PATH)\Engine\Binaries\DotNET\AutomationScripts\</BaseOutputPath>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="$(UNREAL_ENGINE_5_PATH)\Engine\Source\Programs\AutomationTool\Gauntlet\Gauntlet.Automation.csproj" />
  </ItemGroup>

</Project>

Next, generate UE4 project files, open your project solution and rebuild DaedalicTestAutomationPlugin.Automation (probably you should rebuild UE AutomationTool too).

Also, probably after that, you will occur the next issue if you try to run your tests via command line (Gauntlet), something like that:

ERROR: System.ArgumentException: An item with the same key has already been added. Key: D:\Workspaces\MyProjectWorkspace\MyProject\Build\Scripts\DaedalicTestAutomationPlugin.Automation\DaedalicTestAutomationPlugin.Automation.csproj
          at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
          at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
          at AutomationToolDriver.Program.LoadExistingBuildRecords(List`1 BaseDirectories) in D:\Workspaces\MyProjectWorkspace\Engine\Source\Programs\AutomationTool\CompileScriptModules.cs:line 206
          at AutomationToolDriver.Program.InitializeScriptModules(String ScriptsForProjectFileName, List`1 AdditionalScriptsFolders, Boolean bForceCompile, Boolean bNoCompile, Boolean bUseBuildRecords, Boolean& bBuildSuccess) in D:\Workspaces\MyProjectWorkspace\Engine\Source\Programs\AutomationTool\CompileScriptModules.cs:line 97
          at AutomationToolDriver.Program.MainProc() in D:\Workspaces\MyProjectWorkspace\Engine\Source\Programs\AutomationTool\Program.cs:line 423
          at UnrealBuildBase.ProcessSingleton.RunSingleInstance(Func`1 Main, Boolean bWaitForUATMutex) in D:\Workspaces\MyProjectWorkspace\Engine\Source\Programs\Shared\EpicGames.Build\Automation\ProcessSingleton.cs:line 61
          at AutomationToolDriver.Program.Main(String[] Arguments) in D:\Workspaces\MyProjectWorkspace\Engine\Source\Programs\AutomationTool\Program.cs:line 394

So, if you have a command-line script like the one from Daedalic documentation

"C:\Projects\UnrealEngine\Engine\Build\BatchFiles\RunUAT.bat"
RunUnreal
-project="C:\Projects\UnrealGame\UnrealGame.uproject"
-scriptdir="C:\Projects\UnrealGame"
-platform=Win64
-configuration=Development
-build=editor
-test="DaedalicTestAutomationPlugin.Automation.DaeGauntletTest"

Then you should remove scriptdir parameter. In my case that helped, but I'm still not sure it won't affect how a plugin will work in my project. At the moment it works fine, but maybe it's only my first impression until I implement more complicated tests like in the UE4 version. :c