2016-07-15 08:31:50 -07:00
|
|
|
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
2016-07-12 17:10:48 -07:00
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Cli.Build
|
|
|
|
|
{
|
2017-01-27 17:13:04 -08:00
|
|
|
|
public class DotNetRestore : DotNetMSBuildTool
|
2016-07-12 17:10:48 -07:00
|
|
|
|
{
|
|
|
|
|
protected override string Command
|
|
|
|
|
{
|
|
|
|
|
get { return "restore"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override string Args
|
|
|
|
|
{
|
2017-08-28 12:39:12 -07:00
|
|
|
|
get { return $"{base.Args} {GetProjectPath()} {GetConfigFile()} {GetSource()} {GetPackages()} {GetSkipInvalidConfigurations()} {GetRuntime()} {AdditionalParameters}"; }
|
2016-07-12 17:10:48 -07:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-10 10:43:05 -08:00
|
|
|
|
public string ConfigFile { get; set; }
|
|
|
|
|
|
2016-11-11 21:46:29 -10:00
|
|
|
|
public string ProjectPath { get; set; }
|
2016-11-02 23:01:57 -07:00
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
public string Source { get; set; }
|
2016-07-12 17:10:48 -07:00
|
|
|
|
|
2016-07-26 00:29:59 -04:00
|
|
|
|
public string Packages { get; set; }
|
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
public bool SkipInvalidConfigurations { get; set; }
|
2016-11-14 14:26:03 -08:00
|
|
|
|
|
|
|
|
|
public string Runtime { get; set; }
|
2016-07-12 17:10:48 -07:00
|
|
|
|
|
2017-01-10 10:43:05 -08:00
|
|
|
|
private string GetConfigFile()
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(ConfigFile))
|
|
|
|
|
{
|
|
|
|
|
return $"--configfile {ConfigFile}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
private string GetSource()
|
2016-07-12 17:10:48 -07:00
|
|
|
|
{
|
2016-10-27 18:46:43 -07:00
|
|
|
|
if (!string.IsNullOrEmpty(Source))
|
2016-07-12 17:10:48 -07:00
|
|
|
|
{
|
2016-10-27 18:46:43 -07:00
|
|
|
|
return $"--source {Source}";
|
2016-07-12 17:10:48 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-26 00:29:59 -04:00
|
|
|
|
private string GetPackages()
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(Packages))
|
|
|
|
|
{
|
|
|
|
|
return $"--packages {Packages}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-11 21:46:29 -10:00
|
|
|
|
private string GetProjectPath()
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(ProjectPath))
|
|
|
|
|
{
|
|
|
|
|
return $"{ProjectPath}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
private string GetSkipInvalidConfigurations()
|
2016-07-12 17:10:48 -07:00
|
|
|
|
{
|
2016-10-27 18:46:43 -07:00
|
|
|
|
if (SkipInvalidConfigurations)
|
2016-07-12 17:10:48 -07:00
|
|
|
|
{
|
2018-04-02 15:14:32 -07:00
|
|
|
|
return "-property:SkipInvalidConfigurations=true";
|
2016-07-12 17:10:48 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2016-11-14 14:26:03 -08:00
|
|
|
|
|
|
|
|
|
private string GetRuntime()
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(Runtime))
|
|
|
|
|
{
|
2018-04-02 15:14:32 -07:00
|
|
|
|
return $"-property:RuntimeIdentifier={Runtime}";
|
2016-11-14 14:26:03 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2016-07-12 17:10:48 -07:00
|
|
|
|
}
|
|
|
|
|
}
|