Allow resolution of SDKs without minimum msbuild version file
This commit is contained in:
parent
88a8826925
commit
7c8bf26eaf
2 changed files with 22 additions and 5 deletions
|
@ -5,6 +5,7 @@ using Microsoft.Build.Framework;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.MSBuildSdkResolver
|
namespace Microsoft.DotNet.MSBuildSdkResolver
|
||||||
{
|
{
|
||||||
|
@ -63,9 +64,7 @@ namespace Microsoft.DotNet.MSBuildSdkResolver
|
||||||
+ " the version specified in global.json."
|
+ " the version specified in global.json."
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
string minimumMSBuildVersionString = GetMinimumMSBuildVersion(netcoreSdkDir);
|
||||||
var minimumMSBuildVersionString =
|
|
||||||
File.ReadAllLines(Path.Combine(netcoreSdkDir, "minimumMSBuildVersion"))[0];
|
|
||||||
var minimumMSBuildVersion = Version.Parse(minimumMSBuildVersionString);
|
var minimumMSBuildVersion = Version.Parse(minimumMSBuildVersionString);
|
||||||
if (context.MSBuildVersion < minimumMSBuildVersion)
|
if (context.MSBuildVersion < minimumMSBuildVersion)
|
||||||
{
|
{
|
||||||
|
@ -94,6 +93,20 @@ namespace Microsoft.DotNet.MSBuildSdkResolver
|
||||||
return factory.IndicateSuccess(msbuildSdkDir, netcoreSdkVersion);
|
return factory.IndicateSuccess(msbuildSdkDir, netcoreSdkVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetMinimumMSBuildVersion(string netcoreSdkDir)
|
||||||
|
{
|
||||||
|
string minimumVersionFilePath = Path.Combine(netcoreSdkDir, "minimumMSBuildVersion");
|
||||||
|
if (!File.Exists(minimumVersionFilePath))
|
||||||
|
{
|
||||||
|
// smallest version that had resolver support and also
|
||||||
|
// greater than or equal to the version required by any
|
||||||
|
// .NET Core SDK that did not have this file.
|
||||||
|
return "15.3.0";
|
||||||
|
}
|
||||||
|
|
||||||
|
return File.ReadLines(minimumVersionFilePath).First().Trim();
|
||||||
|
}
|
||||||
|
|
||||||
private bool IsNetCoreSDKSmallerThanTheMinimumVersion(string netcoreSdkVersion, string minimumVersion)
|
private bool IsNetCoreSDKSmallerThanTheMinimumVersion(string netcoreSdkVersion, string minimumVersion)
|
||||||
{
|
{
|
||||||
FXVersion netCoreSdkFXVersion;
|
FXVersion netCoreSdkFXVersion;
|
||||||
|
|
|
@ -91,6 +91,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
new SdkReference("Some.Test.Sdk", null, "99.99.99"),
|
new SdkReference("Some.Test.Sdk", null, "99.99.99"),
|
||||||
new MockContext
|
new MockContext
|
||||||
{
|
{
|
||||||
|
MSBuildVersion = new Version(1, 0),
|
||||||
ProjectFilePath = environment.TestDirectory.FullName
|
ProjectFilePath = environment.TestDirectory.FullName
|
||||||
},
|
},
|
||||||
new MockFactory());
|
new MockFactory());
|
||||||
|
@ -194,7 +195,10 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
var dir = GetSdkDirectory(programFiles, sdkName, sdkVersion);
|
var dir = GetSdkDirectory(programFiles, sdkName, sdkVersion);
|
||||||
dir.Create();
|
dir.Create();
|
||||||
|
|
||||||
CreateMSBuildRequiredVersionFile(programFiles, sdkVersion, minimumMSBuildVersion);
|
if (minimumMSBuildVersion != null)
|
||||||
|
{
|
||||||
|
CreateMSBuildRequiredVersionFile(programFiles, sdkVersion, minimumMSBuildVersion);
|
||||||
|
}
|
||||||
|
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
@ -254,7 +258,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
|
|
||||||
public MockContext()
|
public MockContext()
|
||||||
{
|
{
|
||||||
MSBuildVersion = new Version(1, 0);
|
MSBuildVersion = new Version(15, 3, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue