# Error while trying to generate vs project files for dedicated server

**URL:** <https://forums.unrealengine.com/t/error-while-trying-to-generate-vs-project-files-for-dedicated-server/413098>\
**Category:** Pipeline & Plugins\
**Tags:** dedicated-server, visual-c-platform-to, unreal-engine, Visual-Studio, CPP, question\
**Created:** [December 25, 2017, 3:08pm UTC](https://forums.unrealengine.com/t/error-while-trying-to-generate-vs-project-files-for-dedicated-server/413098 "2017-12-25T15:08:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_dc76a5361](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_dc76a5361](https://forums.unrealengine.com/u/anonymous_user_dc76a5361)\
**Post date:** [December 25, 2017, 3:08pm UTC](https://forums.unrealengine.com/t/error-while-trying-to-generate-vs-project-files-for-dedicated-server/413098/1 "2017-12-25T15:08:05Z")

</div>

Hello,

This is the error I am receiving:

**"Messages while compiling C:\Users\Documents\Unreal Projects\myproject\Intermediate\Build\BuildRules\myprojectModuleRules.dll:  
C:\Users\Documents\Unreal Projects\myproject\Source\myprojectServer.Target.cs(6,14) : error CS0101: The namespace ‘’ already contains a definition for ‘myprojectServerTarget’ "**

Windows 10 Pro  
  
Unreal 4.17.2  
  
Visual Studio Community 2017

These are the files I am working with…

myproject.Target.cs

```
using UnrealBuildTool;
using System.Collections.Generic;

[SupportedPlatforms(UnrealPlatformClass.Server)]
public class myprojectServerTarget : TargetRules  
{
       public myprojectServerTarget(TargetInfo Target) : base(Target) 
       {
        Type = TargetType.Server;
        ExtraModuleNames.Add("myproject");   
       }
}

```

myprojectServer.Target.cs

```
using UnrealBuildTool;
using System.Collections.Generic;

public class myprojectServerTarget : TargetRules
{
      public myprojectServerTarget(TargetInfo Target)
      {
         Type = myprojectServerTarget.Server;
         bUsesSteam = true;
      }

       //
       // TargetRules interface.
       //

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

       public override void SetupBinaries
       (
          TargetInfo Target, ref List<UEBuildBinaryConfiguration> OutBuildBinaryConfigurations,
          ref List<string> OutExtraModuleNames
       )
       {
         OutExtraModuleNames.Add("myproject");
       }
}

```

  
I am having been trying to figure this out for awhile. Scoured google and the forums and, while others seem to have similar problems, I don't think I've made the exact mistakes (who knows). Any help would be greatly appreciated.  

Thanks!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_49a519741](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_49a519741](https://forums.unrealengine.com/u/anonymous_user_49a519741)\
**Post date:** [December 25, 2017, 3:34pm UTC](https://forums.unrealengine.com/t/error-while-trying-to-generate-vs-project-files-for-dedicated-server/413098/2 "2017-12-25T15:34:12Z")

</div>

The \*.Target.cs file shouldn’t define the server target. That should just be in the \*Server.Target.cs file. The \*.Target.cs file is for the non-server target, aka the standard game target (for standalone and client games). The Editor.Target.cs file has its own too. The main difference is in the “Type =” statement. You need those to match the file names, TargetType.Server with \*Server.Target.cs and so on.

I think what’s happening is you have the server target defined in both cs files. If you can simply restore the \*.Target.cs file to what it was before you changed it, then that would be the quickest fix. Or copy the one generated for a template project.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_49a519741](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_49a519741](https://forums.unrealengine.com/u/anonymous_user_49a519741)\
**Post date:** [December 25, 2017, 3:36pm UTC](https://forums.unrealengine.com/t/error-while-trying-to-generate-vs-project-files-for-dedicated-server/413098/3 "2017-12-25T15:36:07Z")

</div>

So basically, you want myproject.Target.cs to declare myprojectTarget instead of myprojectServerTarget – and change “Type = TargetType.Server;” to “Type = TargetType.Game;”.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_dc76a5361](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_dc76a5361](https://forums.unrealengine.com/u/anonymous_user_dc76a5361)\
**Post date:** [December 25, 2017, 11:58pm UTC](https://forums.unrealengine.com/t/error-while-trying-to-generate-vs-project-files-for-dedicated-server/413098/4 "2017-12-25T23:58:27Z")

</div>

(I had to post this an an answer because the site would not let me respond to the previous answer or post as a regular comment)

Thank you for responding!

I made the changes that you described above. Your explanation made a lot of sense. Now I am getting a different error. Progress! 🙂

**warning CS0618: ‘UnrealBuildTool.TargetRules.TargetRules()’ is obsolete: ‘Please pass the TargetInfo parameter to the base class constructor (eg. “MyTargetRules(TargetInfo Target) : base(Target)”).’**  
  
**error CS0122: ‘UnrealBuildTool.UnrealBuildTool’ is inaccessible due to its protection level**  
  
**error CS0117: ‘UnrealBuildTool.UnrealBuildTool’ does not contain a definition for ‘GetAllServerPlatforms’  
UnrealBuildTool Exception:**

ERROR: UnrealBuildTool encountered an error while compiling source files\*\*

myprojectTarget.cs

```
    using UnrealBuildTool;
    using System.Collections.Generic;
    
    [SupportedPlatforms(UnrealPlatformClass.Server)]
    public class myprojectTarget : TargetRules // Change this line as shown previously
    {
           public myprojectTarget(TargetInfo Target) : base(Target) // Change this line as shown previously
           {
            Type = TargetType.Game;
            ExtraModuleNames.Add("myproject"); // Change this line as shown previously
           }
    }

```

  

myprojectServerTarget.cs

```
    using UnrealBuildTool;
        using System.Collections.Generic;
        
        public class myprojectServerTarget : TargetRules
        {
              public myprojectServerTarget(TargetInfo Target)
              {
                 Type = TargetType.Server;
                 bUsesSteam = true;
              }
        
               //
               // TargetRules interface.
               //
        
               public override bool GetSupportedPlatforms(ref List<UnrealTargetPlatform> OutPlatforms)
               {
                    // It is valid for only server platforms
                    return UnrealBuildTool.UnrealBuildTool.GetAllServerPlatforms(ref OutPlatforms, false);
               }
        
               public override void SetupBinaries
               (
                  TargetInfo Target, ref List<UEBuildBinaryConfiguration> OutBuildBinaryConfigurations,
                  ref List<string> OutExtraModuleNames
               )
               {
                 OutExtraModuleNames.Add("myproject");
               }
        }

```

  

Is this maybe because the code in the Server.Target.cs does not work for my version of Unreal?

Thanks again!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_dc76a5361](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_dc76a5361](https://forums.unrealengine.com/u/anonymous_user_dc76a5361)\
**Post date:** [December 26, 2017, 1:14am UTC](https://forums.unrealengine.com/t/error-while-trying-to-generate-vs-project-files-for-dedicated-server/413098/5 "2017-12-26T01:14:12Z")

</div>

I fixed it!

If anyone else is having this problem here is what I did. The target.cs file remained the same but I changed the servertarget.cs file so it basically mirrored the syntax and structure of the target.cs file. The code I was trying to use is obsolete for 4.17.2

Thanks for the help.
