2016-11-22 13:56:13 -08:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using Microsoft.DotNet.Tools.Common;
|
|
|
|
using NuGet.Packaging;
|
|
|
|
using NuGet.ProjectModel;
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Cli.Utils
|
|
|
|
{
|
|
|
|
public class PackagedCommandSpecFactoryWithCliRuntime : PackagedCommandSpecFactory
|
|
|
|
{
|
|
|
|
public PackagedCommandSpecFactoryWithCliRuntime() : base(AddAditionalParameters)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void AddAditionalParameters(string commandPath, IList<string> arguments)
|
|
|
|
{
|
|
|
|
if(PrefersCliRuntime(commandPath))
|
|
|
|
{
|
|
|
|
arguments.Add("--fx-version");
|
|
|
|
arguments.Add(new Muxer().SharedFxVersion);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static bool PrefersCliRuntime(string commandPath)
|
|
|
|
{
|
|
|
|
var libTFMPackageDirectory = Path.GetDirectoryName(commandPath);
|
|
|
|
var packageDirectory = Path.Combine(libTFMPackageDirectory, "..", "..");
|
|
|
|
var preferCliRuntimePath = Path.Combine(packageDirectory, "prefercliruntime");
|
|
|
|
|
|
|
|
Reporter.Verbose.WriteLine(
|
2016-12-16 22:41:06 -08:00
|
|
|
string.Format(
|
|
|
|
LocalizableStrings.LookingForPreferCliRuntimeFile,
|
|
|
|
"packagedcommandspecfactory",
|
|
|
|
preferCliRuntimePath));
|
2016-11-22 13:56:13 -08:00
|
|
|
|
|
|
|
return File.Exists(preferCliRuntimePath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|