@@ -103,7 +103,6 @@ private static bool IsAppropriateMBuildVersion(string packageVersion)
103103
104104 if ( ! TryGetVersionComponents ( MSBuildPackageVersion , out minVersion , out minPrerelease ) )
105105 {
106- // todo
107106 return false ;
108107 }
109108
@@ -112,39 +111,14 @@ private static bool IsAppropriateMBuildVersion(string packageVersion)
112111 float currentPrerelease ;
113112 if ( ! TryGetVersionComponents ( packageVersion , out currentVersion , out currentPrerelease ) )
114113 {
115- // todo
116114 return false ;
117115 }
118116
119- // Compare the version
120- // todo
121-
122- // Compare the prerelease indicator
123- // todo
124-
125- //string[] versionComponents = packageVersion.Split(new char[] { ':' });
126- //if (splitLine.Length == 2)
127- //{
128- // // Ensure correct formatting of the version string, before we attempt to parse it.
129- // string versionString = splitLine[1].Trim(new char[] { ' ', '\"', ',' });
130- // bool replaceOnEquals = false;
131- // if (versionString.Contains("-"))
132- // {
133- // // The string references a preview version. Truncate at the '-'.
134- // versionString = versionString.Substring(0, versionString.IndexOf('-'));
135-
136- // // We want to update preview versions to the final.
137- // replaceOnEquals = true;
138- // }
139-
140- // Version version;
141- // if (Version.TryParse(versionString, out version))
142- // {
143- // isAppropriateVersion = replaceOnEquals ? (version > minVersion) : (version >= minVersion);
144- // }
145- //}
117+ // Compare the version and prerelease values
118+ bool isAppropriateVersion = currentVersion >= minVersion ;
119+ bool isAppropriatePrerelease = currentPrerelease >= minPrerelease ;
146120
147- return false ;
121+ return ( isAppropriateVersion && isAppropriatePrerelease ) ;
148122 }
149123
150124 /// <summary>
@@ -169,9 +143,6 @@ internal static bool IsMSBuildForUnityEnabled()
169143 }
170144
171145 // Read the package manifest a line at a time.
172- //bool msBuildFound = false;
173- //bool isAppropriateVersion = false;
174- //Version minVersion = Version.Parse(MSBuildPackageVersion);
175146 using ( FileStream manifestStream = new FileStream ( manifestPath , FileMode . Open , FileAccess . Read ) )
176147 {
177148 using ( StreamReader reader = new StreamReader ( manifestStream ) )
@@ -186,26 +157,6 @@ internal static bool IsMSBuildForUnityEnabled()
186157 string [ ] lineComponents = line . Split ( new char [ ] { ':' } , 2 ) ;
187158
188159 return IsAppropriateMBuildVersion ( lineComponents [ 1 ] ) ;
189- //if (splitLine.Length == 2)
190- //{
191- // // Ensure correct formatting of the version string, before we attempt to parse it.
192- // string versionString = splitLine[1].Trim(new char[] { ' ', '\"', ',' });
193- // bool replaceOnEquals = false;
194- // if (versionString.Contains("-"))
195- // {
196- // // The string references a preview version. Truncate at the '-'.
197- // versionString = versionString.Substring(0, versionString.IndexOf('-'));
198-
199- // // We want to update preview versions to the final.
200- // replaceOnEquals = true;
201- // }
202-
203- // Version version;
204- // if (Version.TryParse(versionString, out version))
205- // {
206- // isAppropriateVersion = replaceOnEquals ? (version > minVersion) : (version >= minVersion);
207- // }
208- //}
209160 }
210161 }
211162 }
@@ -291,10 +242,14 @@ internal static void EnsureMSBuildForUnity()
291242 int scopedRegistriesEndIndex = - 1 ;
292243 int packageLine = - 1 ;
293244
245+ // Presume that we need to add the MSBuild for Unity package. If this value is false,
246+ // we will check to see if the currently configured version meets or exceeds the
247+ // minimum requirements.
248+ bool needToAddPackage = true ;
249+
294250 // Attempt to find the MSBuild for Unity package entry in the dependencies collection
295251 // This loop also identifies the dependecies collection line and the start / end of a
296252 // pre-existing scoped registries collections
297- bool addPackage = true ;
298253 for ( int i = 0 ; i < manifestFileLines . Count ; i ++ )
299254 {
300255 if ( manifestFileLines [ i ] . Contains ( "\" scopedRegistries\" :" ) )
@@ -312,12 +267,12 @@ internal static void EnsureMSBuildForUnity()
312267 if ( manifestFileLines [ i ] . Contains ( MSBuildPackageName ) )
313268 {
314269 packageLine = i ;
315- addPackage = false ;
270+ needToAddPackage = false ;
316271 }
317272 }
318273
319274 // If no package was found add it to the dependencies collection.
320- if ( addPackage )
275+ if ( needToAddPackage )
321276 {
322277 // Add the package to the collection (pad the entry with four spaces)
323278 manifestFileLines . Insert ( dependenciesStartIndex + 1 , $ " \" { MSBuildPackageName } \" : \" { MSBuildPackageVersion } \" ,") ;
0 commit comments