修复报错:BuildFailedException: Build path contains a project previously built without the "Create Visual Studio Solution"

main
Alan Liu 2023-12-12 23:23:01 +08:00 committed by walon
parent 372fa9e06e
commit c9ad6880cb
1 changed files with 7 additions and 1 deletions

View File

@ -84,6 +84,10 @@ namespace HybridCLR.Editor.Commands
bool oldBuildScriptsOnly = EditorUserBuildSettings.buildScriptsOnly; bool oldBuildScriptsOnly = EditorUserBuildSettings.buildScriptsOnly;
EditorUserBuildSettings.buildScriptsOnly = true; EditorUserBuildSettings.buildScriptsOnly = true;
string location = GetLocationPathName(outputPath, target);
string oldBuildLocation = EditorUserBuildSettings.GetBuildLocation(target);
EditorUserBuildSettings.SetBuildLocation(target, location);
switch (target) switch (target)
{ {
case BuildTarget.StandaloneWindows: case BuildTarget.StandaloneWindows:
@ -113,7 +117,7 @@ namespace HybridCLR.Editor.Commands
BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions() BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions()
{ {
scenes = EditorBuildSettings.scenes.Where(s => s.enabled).Select(s => s.path).ToArray(), scenes = EditorBuildSettings.scenes.Where(s => s.enabled).Select(s => s.path).ToArray(),
locationPathName = GetLocationPathName(outputPath, target), locationPathName = location,
options = buildOptions, options = buildOptions,
target = target, target = target,
targetGroup = BuildPipeline.GetBuildTargetGroup(target), targetGroup = BuildPipeline.GetBuildTargetGroup(target),
@ -122,6 +126,8 @@ namespace HybridCLR.Editor.Commands
var report = BuildPipeline.BuildPlayer(buildPlayerOptions); var report = BuildPipeline.BuildPlayer(buildPlayerOptions);
EditorUserBuildSettings.buildScriptsOnly = oldBuildScriptsOnly; EditorUserBuildSettings.buildScriptsOnly = oldBuildScriptsOnly;
EditorUserBuildSettings.SetBuildLocation(target, oldBuildLocation);
switch (target) switch (target)
{ {
case BuildTarget.StandaloneWindows: case BuildTarget.StandaloneWindows: