简书链接:ExpectingtofindatypetobedeclaredinatargetrulesnamedCesiu
文章字数:161,阅读全文大约需要1分钟
今天项目彻底报废打不开了,而且发现了一些奇怪的问题,经过rider开发工具 找到历史版本进行还原备份, 文本比对终于找出问题。
在当前项目下找到CesiumForUnrealSamplesTarget .cs
CesiumForUnrealSamplesEditorTarget .cs
发现内容空白,加进去即可。
找到

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

public class CesiumForUnrealSamplesTarget : TargetRules
{
public CesiumForUnrealSamplesTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.V2;

ExtraModuleNames.AddRange( new string[] { "CesiumForUnrealSamples" } );
}
}



// Copyright 2020-2021 CesiumGS, Inc. and Contributors

using UnrealBuildTool;
using System.Collections.Generic;

public class CesiumForUnrealSamplesEditorTarget : TargetRules
{
public CesiumForUnrealSamplesEditorTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V2;

ExtraModuleNames.AddRange( new string[] { "CesiumForUnrealSamples" } );
}
}


出现这个问题的原因是想改名,但是后果很严重。
加入进去后删除.vs Intermediate Saved Binaries
重新generate visual studio file成功了

1
2
3
4
5
Running UnrealBuildTool: dotnet "..\..\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll" Development Win64 -Project="C:/ueproject/CesiumForUnrealSamples/CesiumForUnrealSamples.uproject" -TargetType=Editor -Progress -NoEngineChanges -NoHotReloadFromIDE
Log file: C:\Users\Administrator\AppData\Local\UnrealBuildTool\Log.txt
Creating makefile for CesiumForUnrealSamplesEditor (no existing makefile)
Expecting to find a type to be declared in a module rules named 'CesiumForUnrealSamples' in CesiumForUnrealSamplesModuleRules, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null. This type must derive from the 'ModuleRules' type defined by Unreal Build Tool.

同样的,在类似结构
CesiumForUnrealSamples\Source\CesiumForUnrealSamples\CesiumForUnrealSamples.Build.cs中发现内容空白

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

using UnrealBuildTool;

public class CesiumForUnrealSamples : ModuleRules
{
public CesiumForUnrealSamples(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });

//PrivateDependencyModuleNames.AddRange(new string[] { });


// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });

// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");

// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}