@@ -32,6 +32,7 @@ public enum Configurations
3232 VirtualRealitySupported ,
3333 SinglePassInstancing ,
3434 SpatialAwarenessLayer ,
35+ EnableMSBuildForUnity ,
3536
3637 // WSA Capabilities
3738 SpatialPerceptionCapability = 1000 ,
@@ -60,6 +61,7 @@ public enum Configurations
6061 { Configurations . VirtualRealitySupported , ( ) => { return PlayerSettings . virtualRealitySupported ; } } ,
6162 { Configurations . SinglePassInstancing , ( ) => { return MixedRealityOptimizeUtils . IsSinglePassInstanced ( ) ; } } ,
6263 { Configurations . SpatialAwarenessLayer , ( ) => { return HasSpatialAwarenessLayer ( ) ; } } ,
64+ { Configurations . EnableMSBuildForUnity , ( ) => { return IsMSBuildForUnityEnabled ( ) ; } } ,
6365
6466 // UWP Capabilities
6567 { Configurations . SpatialPerceptionCapability , ( ) => { return PlayerSettings . WSA . GetCapability ( PlayerSettings . WSACapability . SpatialPerception ) ; } } ,
@@ -91,6 +93,7 @@ public enum Configurations
9193 { Configurations . VirtualRealitySupported , ( ) => { PlayerSettings . virtualRealitySupported = true ; } } ,
9294 { Configurations . SinglePassInstancing , ( ) => { MixedRealityOptimizeUtils . SetSinglePassInstanced ( ) ; } } ,
9395 { Configurations . SpatialAwarenessLayer , ( ) => { SetSpatialAwarenessLayer ( ) ; } } ,
96+ { Configurations . EnableMSBuildForUnity , ( ) => { PackageManifestUpdater . EnsureMSBuildForUnity ( ) ; } } ,
9497
9598 // UWP Capabilities
9699 { Configurations . SpatialPerceptionCapability , ( ) => { PlayerSettings . WSA . SetCapability ( PlayerSettings . WSACapability . SpatialPerception , true ) ; } } ,
@@ -105,7 +108,7 @@ public enum Configurations
105108 { Configurations . AndroidMinSdkVersion , ( ) => { PlayerSettings . Android . minSdkVersion = MinAndroidSdk ; } } ,
106109
107110 // iOS Settings
108- { Configurations . IOSMinOSVersion , ( ) => { PlayerSettings . iOS . targetOSVersionString = iOSMinOsVersion . ToString ( ) ; } } ,
111+ { Configurations . IOSMinOSVersion , ( ) => { PlayerSettings . iOS . targetOSVersionString = iOSMinOsVersion . ToString ( "n1" ) ; } } ,
109112 { Configurations . IOSArchitecture , ( ) => { PlayerSettings . SetArchitecture ( BuildTargetGroup . iOS , RequirediOSArchitecture ) ; } } ,
110113 { Configurations . IOSCameraUsageDescription , ( ) => { PlayerSettings . iOS . cameraUsageDescription = iOSCameraUsageDescription ; } } ,
111114 } ;
@@ -213,6 +216,36 @@ public static bool IsForceTextSerialization()
213216 return EditorSettings . serializationMode == SerializationMode . ForceText ;
214217 }
215218
219+ /// <summary>
220+ /// Checks package manifest to see if MSBuild for Unity is included in the dependencies.
221+ /// </summary>
222+ public static bool IsMSBuildForUnityEnabled ( )
223+ {
224+ // Locate the full path to the package manifest.
225+ DirectoryInfo projectRoot = new DirectoryInfo ( Application . dataPath ) . Parent ;
226+ string [ ] paths = { projectRoot . FullName , "Packages" , "manifest.json" } ;
227+ string manifestPath = Path . Combine ( paths ) ;
228+
229+ // Verify that the package manifest file exists.
230+ if ( ! File . Exists ( manifestPath ) )
231+ {
232+ Debug . LogError ( $ "Package manifest file ({ manifestPath } ) could not be found.") ;
233+ return false ;
234+ }
235+
236+ // Load the manfiest file.
237+ string manifestFileContents = File . ReadAllText ( manifestPath ) ;
238+ if ( string . IsNullOrWhiteSpace ( manifestFileContents ) )
239+ {
240+ Debug . LogError ( $ "Failed to read the package manifest file ({ manifestPath } )") ;
241+ return false ;
242+ }
243+
244+ // Attempt to find the MSBuild for Unity package name.
245+ const string msBuildPackageName = "com.microsoft.msbuildforunity" ;
246+ return manifestFileContents . Contains ( msBuildPackageName ) ;
247+ }
248+
216249 /// <summary>
217250 /// Configures current Unity project to force text serialization
218251 /// </summary>
0 commit comments