Compiler and packaging error

Hello I took a thirdperson c++ template and began making the project to use a dedicated server . Everything compiles and builds fine inside visual studio. The project opens and plays fine all game logic works as expected but when I try to compile or package the game to actually test the server it always fails both with a similar error which I think is linked

The compiler error is compiler error screenshot

And then the package error the automation tool fails with code (5)
And I noticed in the logs it has the same error

" (Windows (64-bit)): UnrealBuildTool: ERROR: Couldn’t find target rules file for target ‘-Project=D:\Unreal\Projects\test\test.uproject’ in rules assembly ‘UE4Rules, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’.

I’ve googled and googled this but none of the fixes work. I’ve uninstalled unreal and visual studio and reinstalled and always the same errors

the fixes mentioned say it is because my project directory is outside the engine root folder and to edit the games.uprojectdirs file.

but if this is whats supposedly causing the errors then how come other projects work fine that are in the same folder directory?

i tried doing the fix but wasnt sure if i done it right

Thanks

Further edit

So I took a new project and this time just opened it and tried to package it before I do anything in visual studio and it works fine

So the problem seems to be after I have added the Server.Target.cs file and then I build the development editor and development server in visual studio .

Like I said I don’t get any errors and the builds succeed in visual studio but then after upon opening the project it won’t package and produces those errors

Here is the code for my server.target file which I got from the wiki . I don’t think this is the problem because it’s exactly the same as the one on my other computer and that had no problems at all

//Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;
using System.Collections.Generic;

public class testServerTarget : TargetRules
{
   public testServerTarget(TargetInfo Target)
   {
       Type = TargetType.Server;
   }

   //
   // TargetRules interface.
   //
   public override void SetupBinaries(
       TargetInfo Target,
       ref List<UEBuildBinaryConfiguration> OutBuildBinaryConfigurations,
       ref List<string> OutExtraModuleNames
       )
   {
       base.SetupBinaries(Target, ref OutBuildBinaryConfigurations, ref OutExtraModuleNames);
       OutExtraModuleNames.Add("test");
   }

   public override bool GetSupportedPlatforms(ref List OutPlatforms)
   {
       // It is valid for only server platforms
       return UnrealBuildTool.UnrealBuildTool.GetAllServerPlatforms(ref OutPlatforms, false);
   }

}

ok issue has now been resolved i have absolutly no clue how but it has fixed now . i just started another new project followed all the exact same steps the only thing i did is change project name. perhaps you cant have a project just named “test” maybe it causes conflicts with something