Add support for Visual Studio 2022 in Flax.Build
This commit is contained in:
@@ -158,6 +158,8 @@ namespace Flax.Build
|
||||
// Pick the project format
|
||||
List<ProjectFormat> projectFormats = new List<ProjectFormat>();
|
||||
|
||||
if (Configuration.ProjectFormatVS2022)
|
||||
projectFormats.Add(ProjectFormat.VisualStudio2022);
|
||||
if (Configuration.ProjectFormatVS2019)
|
||||
projectFormats.Add(ProjectFormat.VisualStudio2019);
|
||||
if (Configuration.ProjectFormatVS2017)
|
||||
|
||||
@@ -189,6 +189,12 @@ namespace Flax.Build
|
||||
[CommandLine("vs2019", "Generates Visual Studio 2019 project format files. Valid only with -genproject option.")]
|
||||
public static bool ProjectFormatVS2019 = false;
|
||||
|
||||
/// <summary>
|
||||
/// Generates Visual Studio 2022 project format files. Valid only with -genproject option.
|
||||
/// </summary>
|
||||
[CommandLine("vs2022", "Generates Visual Studio 2022 project format files. Valid only with -genproject option.")]
|
||||
public static bool ProjectFormatVS2022 = false;
|
||||
|
||||
/// <summary>
|
||||
/// Generates Visual Studio Code project format files. Valid only with -genproject option.
|
||||
/// </summary>
|
||||
|
||||
@@ -30,7 +30,8 @@ namespace Flax.Build.Platforms
|
||||
// v141 toolset or newer required
|
||||
var toolsets = GetToolsets();
|
||||
if (!toolsets.ContainsKey(WindowsPlatformToolset.v141) &&
|
||||
!toolsets.ContainsKey(WindowsPlatformToolset.v142))
|
||||
!toolsets.ContainsKey(WindowsPlatformToolset.v142) &&
|
||||
!toolsets.ContainsKey(WindowsPlatformToolset.v143))
|
||||
_hasRequiredSDKsInstalled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,10 @@ namespace Flax.Build.Platforms
|
||||
_hasRequiredSDKsInstalled = false;
|
||||
|
||||
// Need v141+ toolset
|
||||
if (!GetToolsets().ContainsKey(WindowsPlatformToolset.v141) &&
|
||||
!GetToolsets().ContainsKey(WindowsPlatformToolset.v142))
|
||||
var toolsets = GetToolsets();
|
||||
if (!toolsets.ContainsKey(WindowsPlatformToolset.v141) &&
|
||||
!toolsets.ContainsKey(WindowsPlatformToolset.v142) &&
|
||||
!toolsets.ContainsKey(WindowsPlatformToolset.v143))
|
||||
{
|
||||
_hasRequiredSDKsInstalled = false;
|
||||
}
|
||||
|
||||
@@ -35,9 +35,11 @@ namespace Flax.Build.Platforms
|
||||
}
|
||||
|
||||
// Need v140+ toolset
|
||||
if (!GetToolsets().ContainsKey(WindowsPlatformToolset.v140) &&
|
||||
!GetToolsets().ContainsKey(WindowsPlatformToolset.v141) &&
|
||||
!GetToolsets().ContainsKey(WindowsPlatformToolset.v142))
|
||||
var toolsets = GetToolsets();
|
||||
if (!toolsets.ContainsKey(WindowsPlatformToolset.v140) &&
|
||||
!toolsets.ContainsKey(WindowsPlatformToolset.v141) &&
|
||||
!toolsets.ContainsKey(WindowsPlatformToolset.v142) &&
|
||||
!toolsets.ContainsKey(WindowsPlatformToolset.v143))
|
||||
{
|
||||
Log.Warning("Missing MSVC toolset v140 or later (VS 2015 or later C++ build tools). Cannot build for Windows platform.");
|
||||
_hasRequiredSDKsInstalled = false;
|
||||
|
||||
@@ -42,6 +42,11 @@ namespace Flax.Build.Platforms
|
||||
/// Visual Studio 2019
|
||||
/// </summary>
|
||||
v142 = 142,
|
||||
|
||||
/// <summary>
|
||||
/// Visual Studio 2022
|
||||
/// </summary>
|
||||
v143 = 143,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -103,6 +108,16 @@ namespace Flax.Build.Platforms
|
||||
/// Windows 10 SDK (10.0.19041.0)
|
||||
/// </summary>
|
||||
v10_0_19041_0,
|
||||
|
||||
/// <summary>
|
||||
/// Windows 10 SDK (10.0.20348.0) 21H1
|
||||
/// </summary>
|
||||
v10_0_20348_0,
|
||||
|
||||
/// <summary>
|
||||
/// Windows 11 SDK (10.0.22000.0)
|
||||
/// </summary>
|
||||
v10_0_22000_0,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -124,7 +139,7 @@ namespace Flax.Build.Platforms
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool HasSharedLibrarySupport => true;
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool HasExecutableFileReferenceSupport => true;
|
||||
|
||||
@@ -231,6 +246,8 @@ namespace Flax.Build.Platforms
|
||||
_toolsets[WindowsPlatformToolset.v141] = toolset;
|
||||
else if (version.Major == 14 && version.Minor / 10 == 2)
|
||||
_toolsets[WindowsPlatformToolset.v142] = toolset;
|
||||
else if (version.Major == 14 && version.Minor / 10 == 3)
|
||||
_toolsets[WindowsPlatformToolset.v143] = toolset;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -250,7 +267,7 @@ namespace Flax.Build.Platforms
|
||||
return _toolsets;
|
||||
|
||||
var vsInstances = VisualStudioInstance.GetInstances();
|
||||
|
||||
|
||||
// Visual Studio 2015 - single instance
|
||||
var vs2015 = vsInstances.FirstOrDefault(x => x.Version == VisualStudioVersion.VisualStudio2015);
|
||||
if (vs2015 != null)
|
||||
@@ -266,23 +283,18 @@ namespace Flax.Build.Platforms
|
||||
}
|
||||
}
|
||||
|
||||
// Visual Studio 2017 - multiple instances
|
||||
foreach (var vs2017 in vsInstances.Where(x => x.Version == VisualStudioVersion.VisualStudio2017))
|
||||
// Visual Studio 2017-2022 - multiple instances
|
||||
foreach (var vs in vsInstances.Where(x =>
|
||||
x.Version == VisualStudioVersion.VisualStudio2017 ||
|
||||
x.Version == VisualStudioVersion.VisualStudio2019 ||
|
||||
x.Version == VisualStudioVersion.VisualStudio2022
|
||||
))
|
||||
{
|
||||
FindMsvcToolsets(Path.Combine(vs2017.Path, "VC", "Tools", "MSVC"));
|
||||
}
|
||||
|
||||
// Visual Studio 2019 - multiple instances
|
||||
foreach (var vs2019 in vsInstances.Where(x => x.Version == VisualStudioVersion.VisualStudio2019))
|
||||
{
|
||||
FindMsvcToolsets(Path.Combine(vs2019.Path, "VC", "Tools", "MSVC"));
|
||||
FindMsvcToolsets(Path.Combine(vs.Path, "VC", "Tools", "MSVC"));
|
||||
}
|
||||
|
||||
foreach (var e in _toolsets)
|
||||
{
|
||||
Log.Verbose(string.Format("Found Windows toolset {0} at {1}", e.Key, e.Value));
|
||||
}
|
||||
|
||||
return _toolsets;
|
||||
}
|
||||
|
||||
@@ -305,6 +317,8 @@ namespace Flax.Build.Platforms
|
||||
case WindowsPlatformSDK.v10_0_17763_0: return new Version(10, 0, 17763, 0);
|
||||
case WindowsPlatformSDK.v10_0_18362_0: return new Version(10, 0, 18362, 0);
|
||||
case WindowsPlatformSDK.v10_0_19041_0: return new Version(10, 0, 19041, 0);
|
||||
case WindowsPlatformSDK.v10_0_20348_0: return new Version(10, 0, 20348, 0);
|
||||
case WindowsPlatformSDK.v10_0_22000_0: return new Version(10, 0, 22000, 0);
|
||||
default: throw new ArgumentOutOfRangeException(nameof(sdk), sdk, null);
|
||||
}
|
||||
}
|
||||
@@ -346,6 +360,20 @@ namespace Flax.Build.Platforms
|
||||
sdk10Roots.Add(rootDir);
|
||||
}
|
||||
}
|
||||
var win10Sdks = new[]
|
||||
{
|
||||
WindowsPlatformSDK.v10_0_10240_0,
|
||||
WindowsPlatformSDK.v10_0_10586_0,
|
||||
WindowsPlatformSDK.v10_0_14393_0,
|
||||
WindowsPlatformSDK.v10_0_15063_0,
|
||||
WindowsPlatformSDK.v10_0_16299_0,
|
||||
WindowsPlatformSDK.v10_0_17134_0,
|
||||
WindowsPlatformSDK.v10_0_17763_0,
|
||||
WindowsPlatformSDK.v10_0_18362_0,
|
||||
WindowsPlatformSDK.v10_0_19041_0,
|
||||
WindowsPlatformSDK.v10_0_20348_0,
|
||||
WindowsPlatformSDK.v10_0_22000_0,
|
||||
};
|
||||
foreach (var sdk10 in sdk10Roots)
|
||||
{
|
||||
var includeRootDir = Path.Combine(sdk10, "Include");
|
||||
@@ -355,25 +383,17 @@ namespace Flax.Build.Platforms
|
||||
{
|
||||
if (Version.TryParse(Path.GetFileName(includeDir), out var version) && File.Exists(Path.Combine(includeDir, "um", "windows.h")))
|
||||
{
|
||||
if (version == GetSDKVersion(WindowsPlatformSDK.v10_0_10240_0))
|
||||
_sdks.Add(WindowsPlatformSDK.v10_0_10240_0, sdk10);
|
||||
else if (version == GetSDKVersion(WindowsPlatformSDK.v10_0_10586_0))
|
||||
_sdks.Add(WindowsPlatformSDK.v10_0_10586_0, sdk10);
|
||||
else if (version == GetSDKVersion(WindowsPlatformSDK.v10_0_14393_0))
|
||||
_sdks.Add(WindowsPlatformSDK.v10_0_14393_0, sdk10);
|
||||
else if (version == GetSDKVersion(WindowsPlatformSDK.v10_0_15063_0))
|
||||
_sdks.Add(WindowsPlatformSDK.v10_0_15063_0, sdk10);
|
||||
else if (version == GetSDKVersion(WindowsPlatformSDK.v10_0_16299_0))
|
||||
_sdks.Add(WindowsPlatformSDK.v10_0_16299_0, sdk10);
|
||||
else if (version == GetSDKVersion(WindowsPlatformSDK.v10_0_17134_0))
|
||||
_sdks.Add(WindowsPlatformSDK.v10_0_17134_0, sdk10);
|
||||
else if (version == GetSDKVersion(WindowsPlatformSDK.v10_0_17763_0))
|
||||
_sdks.Add(WindowsPlatformSDK.v10_0_17763_0, sdk10);
|
||||
else if (version == GetSDKVersion(WindowsPlatformSDK.v10_0_18362_0))
|
||||
_sdks.Add(WindowsPlatformSDK.v10_0_18362_0, sdk10);
|
||||
else if (version == GetSDKVersion(WindowsPlatformSDK.v10_0_19041_0))
|
||||
_sdks.Add(WindowsPlatformSDK.v10_0_19041_0, sdk10);
|
||||
else
|
||||
bool unknown = true;
|
||||
foreach (var win10Sdk in win10Sdks)
|
||||
{
|
||||
if (version == GetSDKVersion(win10Sdk))
|
||||
{
|
||||
_sdks.Add(win10Sdk, sdk10);
|
||||
unknown = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (unknown)
|
||||
Log.Warning(string.Format("Unknown Windows 10 SDK version {0} at {1}", version, sdk10));
|
||||
}
|
||||
}
|
||||
@@ -410,9 +430,9 @@ namespace Flax.Build.Platforms
|
||||
|
||||
throw new Exception(string.Format("No 32-bit compiler toolchain found in {0}", compilerPath));
|
||||
}
|
||||
|
||||
case WindowsPlatformToolset.v141:
|
||||
case WindowsPlatformToolset.v142:
|
||||
case WindowsPlatformToolset.v143:
|
||||
{
|
||||
/*
|
||||
string crossCompilerPath = Path.Combine(vcToolChainDir, "bin", "HostX64", "x86", "cl.exe");
|
||||
@@ -431,7 +451,6 @@ namespace Flax.Build.Platforms
|
||||
//throw new Exception(string.Format("No 32-bit compiler toolchain found in {0} or {1}", crossCompilerPath, nativeCompilerPath));
|
||||
throw new Exception(string.Format("No 32-bit compiler toolchain found in {0}", nativeCompilerPath));
|
||||
}
|
||||
|
||||
default: throw new ArgumentOutOfRangeException(nameof(toolset), toolset, null);
|
||||
}
|
||||
}
|
||||
@@ -464,9 +483,9 @@ namespace Flax.Build.Platforms
|
||||
|
||||
throw new Exception(string.Format("No 64-bit compiler toolchain found in {0} or {1}", nativeCompilerPath, crossCompilerPath));
|
||||
}
|
||||
|
||||
case WindowsPlatformToolset.v141:
|
||||
case WindowsPlatformToolset.v142:
|
||||
case WindowsPlatformToolset.v143:
|
||||
{
|
||||
string nativeCompilerPath = Path.Combine(vcToolChainDir, "bin", "HostX64", "x64", "cl.exe");
|
||||
if (File.Exists(nativeCompilerPath))
|
||||
@@ -482,7 +501,6 @@ namespace Flax.Build.Platforms
|
||||
|
||||
throw new Exception(string.Format("No 64-bit compiler toolchain found in {0} or {1}", nativeCompilerPath, crossCompilerPath));
|
||||
}
|
||||
|
||||
default: throw new ArgumentOutOfRangeException(nameof(toolset), toolset, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,11 @@ namespace Flax.Build.Platforms
|
||||
// Pick the newest installed Visual Studio version if using the default toolset
|
||||
if (toolsetVer == WindowsPlatformToolset.Default)
|
||||
{
|
||||
if (VisualStudioInstance.HasIDE(VisualStudioVersion.VisualStudio2019))
|
||||
if (VisualStudioInstance.HasIDE(VisualStudioVersion.VisualStudio2022))
|
||||
{
|
||||
toolsetVer = WindowsPlatformToolset.v143;
|
||||
}
|
||||
else if (VisualStudioInstance.HasIDE(VisualStudioVersion.VisualStudio2019))
|
||||
{
|
||||
toolsetVer = WindowsPlatformToolset.v142;
|
||||
}
|
||||
@@ -194,6 +198,7 @@ namespace Flax.Build.Platforms
|
||||
}
|
||||
case WindowsPlatformToolset.v141:
|
||||
case WindowsPlatformToolset.v142:
|
||||
case WindowsPlatformToolset.v143:
|
||||
{
|
||||
switch (Architecture)
|
||||
{
|
||||
@@ -274,6 +279,8 @@ namespace Flax.Build.Platforms
|
||||
case WindowsPlatformSDK.v10_0_17763_0:
|
||||
case WindowsPlatformSDK.v10_0_18362_0:
|
||||
case WindowsPlatformSDK.v10_0_19041_0:
|
||||
case WindowsPlatformSDK.v10_0_20348_0:
|
||||
case WindowsPlatformSDK.v10_0_22000_0:
|
||||
{
|
||||
var sdkVersionName = WindowsPlatformBase.GetSDKVersion(SDK).ToString();
|
||||
string includeRootDir = Path.Combine(windowsSdkDir, "include", sdkVersionName);
|
||||
@@ -367,6 +374,7 @@ namespace Flax.Build.Platforms
|
||||
var vcToolChainDir = toolsets[Toolset];
|
||||
switch (Toolset)
|
||||
{
|
||||
case WindowsPlatformToolset.v143:
|
||||
case WindowsPlatformToolset.v142:
|
||||
case WindowsPlatformToolset.v141:
|
||||
return Path.Combine(vcToolChainDir, "lib", "x86", "store", "references");
|
||||
|
||||
@@ -32,6 +32,11 @@ namespace Flax.Build.Projects
|
||||
/// </summary>
|
||||
VisualStudio2019,
|
||||
|
||||
/// <summary>
|
||||
/// Visual Studio 2022.
|
||||
/// </summary>
|
||||
VisualStudio2022,
|
||||
|
||||
/// <summary>
|
||||
/// Visual Studio Code.
|
||||
/// </summary>
|
||||
|
||||
@@ -84,7 +84,11 @@ namespace Flax.Build.Projects
|
||||
// Pick the newest installed Visual Studio version
|
||||
if (format == ProjectFormat.VisualStudio)
|
||||
{
|
||||
if (VisualStudioInstance.HasIDE(VisualStudioVersion.VisualStudio2019))
|
||||
if (VisualStudioInstance.HasIDE(VisualStudioVersion.VisualStudio2022))
|
||||
{
|
||||
format = ProjectFormat.VisualStudio2022;
|
||||
}
|
||||
else if (VisualStudioInstance.HasIDE(VisualStudioVersion.VisualStudio2019))
|
||||
{
|
||||
format = ProjectFormat.VisualStudio2019;
|
||||
}
|
||||
@@ -106,26 +110,34 @@ namespace Flax.Build.Projects
|
||||
switch (format)
|
||||
{
|
||||
case ProjectFormat.VisualStudio2015:
|
||||
switch (type)
|
||||
{
|
||||
case TargetType.NativeCpp: return new VCProjectGenerator(VisualStudioVersion.VisualStudio2015);
|
||||
case TargetType.DotNet: return new CSProjectGenerator(VisualStudioVersion.VisualStudio2015);
|
||||
default: throw new ArgumentOutOfRangeException(nameof(type), type, null);
|
||||
}
|
||||
case ProjectFormat.VisualStudio2017:
|
||||
switch (type)
|
||||
{
|
||||
case TargetType.NativeCpp: return new VCProjectGenerator(VisualStudioVersion.VisualStudio2017);
|
||||
case TargetType.DotNet: return new CSProjectGenerator(VisualStudioVersion.VisualStudio2017);
|
||||
default: throw new ArgumentOutOfRangeException(nameof(type), type, null);
|
||||
}
|
||||
case ProjectFormat.VisualStudio2019:
|
||||
case ProjectFormat.VisualStudio2022:
|
||||
{
|
||||
VisualStudioVersion vsVersion;
|
||||
switch (format)
|
||||
{
|
||||
case ProjectFormat.VisualStudio2015:
|
||||
vsVersion = VisualStudioVersion.VisualStudio2015;
|
||||
break;
|
||||
case ProjectFormat.VisualStudio2017:
|
||||
vsVersion = VisualStudioVersion.VisualStudio2017;
|
||||
break;
|
||||
case ProjectFormat.VisualStudio2019:
|
||||
vsVersion = VisualStudioVersion.VisualStudio2019;
|
||||
break;
|
||||
case ProjectFormat.VisualStudio2022:
|
||||
vsVersion = VisualStudioVersion.VisualStudio2022;
|
||||
break;
|
||||
default: throw new ArgumentOutOfRangeException(nameof(format), format, null);
|
||||
}
|
||||
switch (type)
|
||||
{
|
||||
case TargetType.NativeCpp: return new VCProjectGenerator(VisualStudioVersion.VisualStudio2019);
|
||||
case TargetType.DotNet: return new CSProjectGenerator(VisualStudioVersion.VisualStudio2019);
|
||||
case TargetType.NativeCpp: return new VCProjectGenerator(vsVersion);
|
||||
case TargetType.DotNet: return new CSProjectGenerator(vsVersion);
|
||||
default: throw new ArgumentOutOfRangeException(nameof(type), type, null);
|
||||
}
|
||||
}
|
||||
case ProjectFormat.VisualStudioCode: return new VisualStudioCodeProjectGenerator();
|
||||
case ProjectFormat.Custom:
|
||||
if (CustomProjectTypes.TryGetValue(Configuration.ProjectFormatCustom, out var factory))
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Flax.Build.Projects.VisualStudio
|
||||
case VisualStudioVersion.VisualStudio2015: return "v140";
|
||||
case VisualStudioVersion.VisualStudio2017: return "v141";
|
||||
case VisualStudioVersion.VisualStudio2019: return "v142";
|
||||
case VisualStudioVersion.VisualStudio2022: return "v143";
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
@@ -93,87 +93,88 @@ namespace Flax.Build.Projects.VisualStudio
|
||||
/// <returns>The install locations.</returns>
|
||||
public static IReadOnlyList<VisualStudioInstance> GetInstances()
|
||||
{
|
||||
if (_installDirs == null)
|
||||
if (_installDirs != null)
|
||||
return _installDirs;
|
||||
_installDirs = new List<VisualStudioInstance>();
|
||||
|
||||
// Skip if running on non-Windows system
|
||||
if (Platform.BuildTargetPlatform != TargetPlatform.Windows)
|
||||
return _installDirs;
|
||||
|
||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||
{
|
||||
_installDirs = new List<VisualStudioInstance>();
|
||||
|
||||
// Skip if running on non-Windows system
|
||||
if (Platform.BuildTargetPlatform != TargetPlatform.Windows)
|
||||
return _installDirs;
|
||||
|
||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||
// Visual Studio 2017-2022
|
||||
List<VisualStudioInstance> preReleaseInstallDirs = null;
|
||||
try
|
||||
{
|
||||
// Visual Studio 2017-2019
|
||||
List<VisualStudioInstance> preReleaseInstallDirs = null;
|
||||
try
|
||||
SetupConfiguration setup = new SetupConfiguration();
|
||||
IEnumSetupInstances enumerator = setup.EnumAllInstances();
|
||||
|
||||
ISetupInstance[] instances = new ISetupInstance[1];
|
||||
while (true)
|
||||
{
|
||||
SetupConfiguration setup = new SetupConfiguration();
|
||||
IEnumSetupInstances enumerator = setup.EnumAllInstances();
|
||||
enumerator.Next(1, instances, out int fetchedCount);
|
||||
if (fetchedCount == 0)
|
||||
break;
|
||||
|
||||
ISetupInstance[] instances = new ISetupInstance[1];
|
||||
while (true)
|
||||
ISetupInstance2 instance = (ISetupInstance2)instances[0];
|
||||
if ((instance.GetState() & InstanceState.Local) == InstanceState.Local)
|
||||
{
|
||||
enumerator.Next(1, instances, out int fetchedCount);
|
||||
if (fetchedCount == 0)
|
||||
break;
|
||||
|
||||
ISetupInstance2 instance = (ISetupInstance2)instances[0];
|
||||
if ((instance.GetState() & InstanceState.Local) == InstanceState.Local)
|
||||
VisualStudioVersion version;
|
||||
string displayName = instance.GetDisplayName();
|
||||
if (displayName.Contains("2017"))
|
||||
version = VisualStudioVersion.VisualStudio2017;
|
||||
else if (displayName.Contains("2019"))
|
||||
version = VisualStudioVersion.VisualStudio2019;
|
||||
else if (displayName.Contains("2022"))
|
||||
version = VisualStudioVersion.VisualStudio2022;
|
||||
else
|
||||
{
|
||||
VisualStudioVersion version;
|
||||
string displayName = instance.GetDisplayName();
|
||||
if (displayName.Contains("2019"))
|
||||
version = VisualStudioVersion.VisualStudio2019;
|
||||
else if (displayName.Contains("2017"))
|
||||
version = VisualStudioVersion.VisualStudio2017;
|
||||
else
|
||||
throw new Exception(string.Format("Unknown Visual Studio installation. Display name: {0}", displayName));
|
||||
Log.Warning(string.Format("Unknown Visual Studio installation. Display name: {0}", displayName));
|
||||
continue;
|
||||
}
|
||||
|
||||
var vsInstance = new VisualStudioInstance
|
||||
{
|
||||
Version = version,
|
||||
Path = instance.GetInstallationPath(),
|
||||
};
|
||||
var vsInstance = new VisualStudioInstance
|
||||
{
|
||||
Version = version,
|
||||
Path = instance.GetInstallationPath(),
|
||||
};
|
||||
|
||||
if (instance is ISetupInstanceCatalog catalog && catalog.IsPrerelease())
|
||||
{
|
||||
if (preReleaseInstallDirs == null)
|
||||
preReleaseInstallDirs = new List<VisualStudioInstance>();
|
||||
preReleaseInstallDirs.Add(vsInstance);
|
||||
}
|
||||
else
|
||||
{
|
||||
_installDirs.Add(vsInstance);
|
||||
}
|
||||
if (instance is ISetupInstanceCatalog catalog && catalog.IsPrerelease())
|
||||
{
|
||||
if (preReleaseInstallDirs == null)
|
||||
preReleaseInstallDirs = new List<VisualStudioInstance>();
|
||||
preReleaseInstallDirs.Add(vsInstance);
|
||||
}
|
||||
else
|
||||
{
|
||||
_installDirs.Add(vsInstance);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore errors
|
||||
}
|
||||
|
||||
// Add pre-release locations after the normal installations
|
||||
if (preReleaseInstallDirs != null)
|
||||
_installDirs.AddRange(preReleaseInstallDirs);
|
||||
|
||||
// Visual Studio 2015
|
||||
if (WindowsPlatform.TryReadInstallDirRegistryKey32("Microsoft\\VisualStudio\\SxS\\VS7", "14.0", out var dir))
|
||||
{
|
||||
_installDirs.Add(new VisualStudioInstance
|
||||
{
|
||||
Version = VisualStudioVersion.VisualStudio2015,
|
||||
Path = dir,
|
||||
});
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore errors
|
||||
}
|
||||
|
||||
foreach (var e in _installDirs)
|
||||
// Add pre-release locations after the normal installations
|
||||
if (preReleaseInstallDirs != null)
|
||||
_installDirs.AddRange(preReleaseInstallDirs);
|
||||
|
||||
// Visual Studio 2015
|
||||
if (WindowsPlatform.TryReadInstallDirRegistryKey32("Microsoft\\VisualStudio\\SxS\\VS7", "14.0", out var dir))
|
||||
{
|
||||
Log.Verbose($"Found {e.Version} at {e.Path}");
|
||||
_installDirs.Add(new VisualStudioInstance
|
||||
{
|
||||
Version = VisualStudioVersion.VisualStudio2015,
|
||||
Path = dir,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var e in _installDirs)
|
||||
Log.Verbose($"Found {e.Version} at {e.Path}");
|
||||
return _installDirs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +120,7 @@ namespace Flax.Build.Projects.VisualStudio
|
||||
case VisualStudioVersion.VisualStudio2015: return "14.0";
|
||||
case VisualStudioVersion.VisualStudio2017: return "15.0";
|
||||
case VisualStudioVersion.VisualStudio2019: return "16.0";
|
||||
case VisualStudioVersion.VisualStudio2022: return "17.0";
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
@@ -275,9 +276,15 @@ namespace Flax.Build.Projects.VisualStudio
|
||||
var projects = solution.Projects.Cast<VisualStudioProject>().ToArray();
|
||||
|
||||
// Header
|
||||
if (Version == VisualStudioVersion.VisualStudio2019)
|
||||
if (Version == VisualStudioVersion.VisualStudio2022)
|
||||
{
|
||||
vcSolutionFileContent.AppendLine("Microsoft Visual Studio Solution File, Format Version 12.00");
|
||||
vcSolutionFileContent.AppendLine("# Visual Studio Version 17");
|
||||
vcSolutionFileContent.AppendLine("VisualStudioVersion = 17.0.31314.256");
|
||||
vcSolutionFileContent.AppendLine("MinimumVisualStudioVersion = 10.0.40219.1");
|
||||
}
|
||||
else if (Version == VisualStudioVersion.VisualStudio2019)
|
||||
{
|
||||
//vcSolutionFileContent.AppendLine();
|
||||
vcSolutionFileContent.AppendLine("Microsoft Visual Studio Solution File, Format Version 12.00");
|
||||
vcSolutionFileContent.AppendLine("# Visual Studio Version 16");
|
||||
vcSolutionFileContent.AppendLine("VisualStudioVersion = 16.0.28315.86");
|
||||
@@ -285,7 +292,6 @@ namespace Flax.Build.Projects.VisualStudio
|
||||
}
|
||||
else if (Version == VisualStudioVersion.VisualStudio2017)
|
||||
{
|
||||
//vcSolutionFileContent.AppendLine();
|
||||
vcSolutionFileContent.AppendLine("Microsoft Visual Studio Solution File, Format Version 12.00");
|
||||
vcSolutionFileContent.AppendLine("# Visual Studio 15");
|
||||
vcSolutionFileContent.AppendLine("VisualStudioVersion = 15.0.25807.0");
|
||||
@@ -293,7 +299,6 @@ namespace Flax.Build.Projects.VisualStudio
|
||||
}
|
||||
else if (Version == VisualStudioVersion.VisualStudio2015)
|
||||
{
|
||||
//vcSolutionFileContent.AppendLine();
|
||||
vcSolutionFileContent.AppendLine("Microsoft Visual Studio Solution File, Format Version 12.00");
|
||||
vcSolutionFileContent.AppendLine("# Visual Studio 14");
|
||||
vcSolutionFileContent.AppendLine("VisualStudioVersion = 14.0.22310.1");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2012-2020 Flax Engine. All rights reserved.
|
||||
// Copyright (c) 2012-2020 Flax Engine. All rights reserved.
|
||||
|
||||
namespace Flax.Build.Projects.VisualStudio
|
||||
{
|
||||
@@ -21,5 +21,10 @@ namespace Flax.Build.Projects.VisualStudio
|
||||
/// The Visual Studio 2019.
|
||||
/// </summary>
|
||||
VisualStudio2019,
|
||||
|
||||
/// <summary>
|
||||
/// The Visual Studio 2022.
|
||||
/// </summary>
|
||||
VisualStudio2022,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user