2016-07-15 15:31:50 +00: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-13 00:10:48 +00:00
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Cli.Build
|
|
|
|
|
{
|
2017-01-28 01:13:04 +00:00
|
|
|
|
public class DotNetRestore : DotNetMSBuildTool
|
2016-07-13 00:10:48 +00:00
|
|
|
|
{
|
|
|
|
|
protected override string Command
|
|
|
|
|
{
|
|
|
|
|
get { return "restore"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override string Args
|
|
|
|
|
{
|
2017-08-28 19:39:12 +00:00
|
|
|
|
get { return $"{base.Args} {GetProjectPath()} {GetConfigFile()} {GetSource()} {GetPackages()} {GetSkipInvalidConfigurations()} {GetRuntime()} {AdditionalParameters}"; }
|
2016-07-13 00:10:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-10 18:43:05 +00:00
|
|
|
|
public string ConfigFile { get; set; }
|
|
|
|
|
|
2016-11-12 07:46:29 +00:00
|
|
|
|
public string ProjectPath { get; set; }
|
2016-11-03 06:01:57 +00:00
|
|
|
|
|
2016-10-28 01:46:43 +00:00
|
|
|
|
public string Source { get; set; }
|
2016-07-13 00:10:48 +00:00
|
|
|
|
|
2016-07-26 04:29:59 +00:00
|
|
|
|
public string Packages { get; set; }
|
|
|
|
|
|
2016-10-28 01:46:43 +00:00
|
|
|
|
public bool SkipInvalidConfigurations { get; set; }
|
2016-11-14 22:26:03 +00:00
|
|
|
|
|
|
|
|
|
public string Runtime { get; set; }
|
2016-07-13 00:10:48 +00:00
|
|
|
|
|
2017-01-10 18:43:05 +00:00
|
|
|
|
private string GetConfigFile()
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(ConfigFile))
|
|
|
|
|
{
|
|
|
|
|
return $"--configfile {ConfigFile}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-28 01:46:43 +00:00
|
|
|
|
private string GetSource()
|
2016-07-13 00:10:48 +00:00
|
|
|
|
{
|
2016-10-28 01:46:43 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(Source))
|
2016-07-13 00:10:48 +00:00
|
|
|
|
{
|
2016-10-28 01:46:43 +00:00
|
|
|
|
return $"--source {Source}";
|
2016-07-13 00:10:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-26 04:29:59 +00:00
|
|
|
|
private string GetPackages()
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(Packages))
|
|
|
|
|
{
|
|
|
|
|
return $"--packages {Packages}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-12 07:46:29 +00:00
|
|
|
|
private string GetProjectPath()
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(ProjectPath))
|
|
|
|
|
{
|
|
|
|
|
return $"{ProjectPath}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-28 01:46:43 +00:00
|
|
|
|
private string GetSkipInvalidConfigurations()
|
2016-07-13 00:10:48 +00:00
|
|
|
|
{
|
2016-10-28 01:46:43 +00:00
|
|
|
|
if (SkipInvalidConfigurations)
|
2016-07-13 00:10:48 +00:00
|
|
|
|
{
|
2016-10-28 01:46:43 +00:00
|
|
|
|
return "/p:SkipInvalidConfigurations=true";
|
2016-07-13 00:10:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2016-11-14 22:26:03 +00:00
|
|
|
|
|
|
|
|
|
private string GetRuntime()
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(Runtime))
|
|
|
|
|
{
|
|
|
|
|
return $"/p:RuntimeIdentifier={Runtime}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2016-07-13 00:10:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|