Skip to content

Commit dd2e4ee

Browse files
authored
fix: Fix VS workload detection logic for iOS and Android workloads on modern VS (#3022)
* Updates the Visual Studio workload logic for Android and iOS to properly detect the modern post-Xamarin workloads. Also fixes a logical error in IsVSComponentAvailableAnyVersion when multiple versions of Visual Studio are installed, regardless of what order the components are defined in the dictionary: previously, if the first version check fails, it would return false, even if later checks would succeed. Now it checks all entries and returns true if any check succeeds.
1 parent 33eba55 commit dd2e4ee

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

sources/engine/Stride.Assets/StrideConfig.cs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ public sealed class StrideConfig
2828
private static readonly Version VS2015Version = new Version(14, 0);
2929
private static readonly Version VSAnyVersion = new Version(int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue);
3030

31-
internal static readonly Dictionary<Version, string> XamariniOSComponents = new Dictionary<Version, string>
31+
internal static readonly Dictionary<Version, string> DotNetForiOSComponents = new Dictionary<Version, string>
3232
{
33-
{ VSAnyVersion, @"Component.Xamarin" },
33+
{ VSAnyVersion, @"Microsoft.VisualStudio.Workload.NetCrossPlat" },
3434
{ VS2015Version, @"MSBuild\Xamarin\iOS\Xamarin.iOS.CSharp.targets" }
3535
};
3636

37-
internal static readonly Dictionary<Version, string> XamarinAndroidComponents = new Dictionary<Version, string>
37+
internal static readonly Dictionary<Version, string> DotNetForAndroidComponents = new Dictionary<Version, string>
3838
{
39-
{ VSAnyVersion, @"Component.Xamarin" },
39+
{ VSAnyVersion, @"Microsoft.VisualStudio.Workload.NetCrossPlat" },
4040
{ VS2015Version, @"MSBuild\Xamarin\Android\Xamarin.Android.CSharp.targets" }
4141
};
4242

@@ -148,7 +148,7 @@ internal static void RegisterSolutionPlatforms()
148148
Name = PlatformType.Android.ToString(),
149149
Type = PlatformType.Android,
150150
TargetFramework = "net10.0-android",
151-
IsAvailable = IsVSComponentAvailableAnyVersion(XamarinAndroidComponents)
151+
IsAvailable = IsVSComponentAvailableAnyVersion(DotNetForAndroidComponents)
152152
};
153153
androidPlatform.DefineConstants.Add("STRIDE_PLATFORM_MONO_MOBILE");
154154
androidPlatform.DefineConstants.Add("STRIDE_PLATFORM_ANDROID");
@@ -175,7 +175,7 @@ internal static void RegisterSolutionPlatforms()
175175
SolutionName = "iPhone", // For iOS, we need to use iPhone as a solution name
176176
Type = PlatformType.iOS,
177177
TargetFramework = "net10.0-ios",
178-
IsAvailable = IsVSComponentAvailableAnyVersion(XamariniOSComponents)
178+
IsAvailable = IsVSComponentAvailableAnyVersion(DotNetForiOSComponents)
179179
};
180180
iphonePlatform.PlatformsPart.Add(new SolutionPlatformPart("iPhoneSimulator"));
181181
iphonePlatform.DefineConstants.Add("STRIDE_PLATFORM_MONO_MOBILE");
@@ -245,12 +245,19 @@ internal static bool IsVSComponentAvailableAnyVersion(IDictionary<Version, strin
245245
{
246246
if (pair.Key == VS2015Version)
247247
{
248-
return IsFileInProgramFilesx86Exist(pair.Value);
248+
if (IsFileInProgramFilesx86Exist(pair.Value))
249+
{
250+
return true;
251+
}
252+
continue;
249253
}
250254

251-
return VisualStudioVersions.AvailableInstances.Any(
255+
if (VisualStudioVersions.AvailableInstances.Any(
252256
ideInfo => ideInfo.PackageVersions.ContainsKey(pair.Value)
253-
);
257+
))
258+
{
259+
return true;
260+
}
254261
}
255262
return false;
256263
}

0 commit comments

Comments
 (0)