Adding the shim of dotnet-cache
Adds filter profile option to publish
This commit is contained in:
parent
a101c703a1
commit
badab4680d
8 changed files with 233 additions and 1 deletions
|
@ -4,7 +4,7 @@
|
|||
<CLI_SharedFrameworkVersion>2.0.0-beta-001509-00</CLI_SharedFrameworkVersion>
|
||||
<CLI_MSBuild_Version>15.2.0-preview-000002-01</CLI_MSBuild_Version>
|
||||
<CLI_Roslyn_Version>2.0.0-rc4-61325-08</CLI_Roslyn_Version>
|
||||
<CLI_NETSDK_Version>1.0.0-alpha-20170125-1</CLI_NETSDK_Version>
|
||||
<CLI_NETSDK_Version>1.1.0-alpha-20170209-1</CLI_NETSDK_Version>
|
||||
<!-- non-official NuGet build taken from https://github.com/nuget/nuget.client/tree/release-4.0.0-rc3-netstandard2.0 to contain "2.0" TFMs -->
|
||||
<CLI_NuGet_Version>4.0.0-rc3-2193</CLI_NuGet_Version>
|
||||
<CLI_WEBSDK_Version>1.0.0-alpha-20170130-3-281</CLI_WEBSDK_Version>
|
||||
|
|
|
@ -27,6 +27,7 @@ using Microsoft.DotNet.Tools.Run;
|
|||
using Microsoft.DotNet.Tools.Sln;
|
||||
using Microsoft.DotNet.Tools.Test;
|
||||
using Microsoft.DotNet.Tools.VSTest;
|
||||
using Microsoft.DotNet.Tools.Cache;
|
||||
using NuGet.Frameworks;
|
||||
|
||||
namespace Microsoft.DotNet.Cli
|
||||
|
@ -37,6 +38,7 @@ namespace Microsoft.DotNet.Cli
|
|||
{
|
||||
["add"] = AddCommand.Run,
|
||||
["build"] = BuildCommand.Run,
|
||||
["cache"] = CacheCommand.Run,
|
||||
["clean"] = CleanCommand.Run,
|
||||
["help"] = HelpCommand.Run,
|
||||
["list"] = ListCommand.Run,
|
||||
|
|
92
src/dotnet/commands/dotnet-cache/CacheCommand.cs
Normal file
92
src/dotnet/commands/dotnet-cache/CacheCommand.cs
Normal file
|
@ -0,0 +1,92 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.Tools.MSBuild;
|
||||
using Microsoft.DotNet.Tools.Restore;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Cache
|
||||
{
|
||||
public partial class CacheCommand
|
||||
{
|
||||
public string ProjectArgument { get; set; }
|
||||
public string Framework { get; set; }
|
||||
public string Runtime { get; set; }
|
||||
public string OutputPath { get; set; }
|
||||
public string FrameworkVersion { get; set; }
|
||||
public string IntermediateDir { get; set; }
|
||||
public string Verbosity { get; set; }
|
||||
private bool SkipOptimization { get; set; }
|
||||
private bool PreserveIntermediateDir { get; set; }
|
||||
|
||||
public List<string> ExtraMSBuildArguments { get; set; }
|
||||
|
||||
private CacheCommand()
|
||||
{
|
||||
}
|
||||
|
||||
public int Execute()
|
||||
{
|
||||
var msbuildArgs = new List<string>();
|
||||
|
||||
if (string.IsNullOrEmpty(ProjectArgument))
|
||||
{
|
||||
throw new InvalidOperationException(LocalizableStrings.SpecifyEntries);
|
||||
}
|
||||
|
||||
msbuildArgs.Add("/t:ComposeCache");
|
||||
msbuildArgs.Add(ProjectArgument);
|
||||
|
||||
if (!string.IsNullOrEmpty(Framework))
|
||||
{
|
||||
msbuildArgs.Add($"/p:TargetFramework={Framework}");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Runtime))
|
||||
{
|
||||
msbuildArgs.Add($"/p:RuntimeIdentifier={Runtime}");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(OutputPath))
|
||||
{
|
||||
OutputPath = Path.GetFullPath(OutputPath);
|
||||
msbuildArgs.Add($"/p:ComposeDir={OutputPath}");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(FrameworkVersion))
|
||||
{
|
||||
msbuildArgs.Add($"/p:FX_Version={FrameworkVersion}");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(IntermediateDir))
|
||||
{
|
||||
msbuildArgs.Add($"/p:ComposeWorkingDir={IntermediateDir}");
|
||||
}
|
||||
|
||||
if (SkipOptimization)
|
||||
{
|
||||
msbuildArgs.Add($"/p:SkipOptimization={SkipOptimization}");
|
||||
}
|
||||
|
||||
if (PreserveIntermediateDir)
|
||||
{
|
||||
msbuildArgs.Add($"/p:PreserveComposeWorkingDir={PreserveIntermediateDir}");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Verbosity))
|
||||
{
|
||||
msbuildArgs.Add($"/verbosity:{Verbosity}");
|
||||
}
|
||||
|
||||
msbuildArgs.AddRange(ExtraMSBuildArguments);
|
||||
|
||||
return new MSBuildForwardingApp(msbuildArgs).Execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
41
src/dotnet/commands/dotnet-cache/LocalizableStrings.cs
Normal file
41
src/dotnet/commands/dotnet-cache/LocalizableStrings.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
namespace Microsoft.DotNet.Tools.Cache
|
||||
{
|
||||
internal class LocalizableStrings
|
||||
{
|
||||
public const string AppFullName = ".NET Cache";
|
||||
|
||||
public const string AppDescription = "Caches the specified assemblies for the .NET Platform. By default, these will be optimized for the target runtime and framework.";
|
||||
|
||||
public const string ProjectEntries = "ProjectEntries";
|
||||
|
||||
public const string ProjectEntryDescription = "The XML file that contains the list of packages to be cached.";
|
||||
|
||||
public const string FrameworkOption = "FRAMEWORK";
|
||||
|
||||
public const string FrameworkOptionDescription = "Target framework for which to cache for.";
|
||||
|
||||
public const string RuntimeOption = "RUNTIME_IDENTIFIER";
|
||||
|
||||
public const string RuntimeOptionDescription = "Target runtime to cache for.";
|
||||
|
||||
public const string OutputOption = "OUTPUT_DIR";
|
||||
|
||||
public const string OutputOptionDescription = "Output directory in which to cache the given assemblies.";
|
||||
|
||||
public const string FrameworkVersionOption = "FrameworkVersion";
|
||||
|
||||
public const string FrameworkVersionOptionDescription = "The Microsoft.NETCore.App package version that will be used to run the assemblies.";
|
||||
|
||||
public const string SkipOptimizationOptionDescription = "Skips the optimization phase.";
|
||||
|
||||
public const string IntermediateWorkingDirOption = "IntermediateWorkingDir";
|
||||
|
||||
public const string IntermediateWorkingDirOptionDescription = "The directory used by the command to execute.";
|
||||
|
||||
public const string PreserveIntermediateWorkingDirOptionDescription = "Preserves the intermediate working directory.";
|
||||
|
||||
public const string SpecifyEntries = "Specify at least one entry with --entries.";
|
||||
|
||||
public const string IntermediateDirExists = "Intermediate working directory {0} already exists. Remove {0} or specify another directory with -w.";
|
||||
}
|
||||
}
|
80
src/dotnet/commands/dotnet-cache/Program.cs
Normal file
80
src/dotnet/commands/dotnet-cache/Program.cs
Normal file
|
@ -0,0 +1,80 @@
|
|||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.Tools.MSBuild;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Cache
|
||||
{
|
||||
public partial class CacheCommand
|
||||
{
|
||||
public static int Run(string[] args)
|
||||
{
|
||||
DebugHelper.HandleDebugSwitch(ref args);
|
||||
|
||||
var app = new CommandLineApplication(throwOnUnexpectedArg: false);
|
||||
app.Name = "dotnet cache";
|
||||
app.FullName = LocalizableStrings.AppFullName;
|
||||
app.Description = LocalizableStrings.AppDescription;
|
||||
app.AllowArgumentSeparator = true;
|
||||
app.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText;
|
||||
app.HelpOption("-h|--help");
|
||||
|
||||
CommandOption projectArgument = app.Option(
|
||||
$"-e|--entries <{LocalizableStrings.ProjectEntries}>", LocalizableStrings.ProjectEntryDescription,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
CommandOption frameworkOption = app.Option(
|
||||
$"-f|--framework <{LocalizableStrings.FrameworkOption}>", LocalizableStrings.FrameworkOptionDescription,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
CommandOption runtimeOption = app.Option(
|
||||
$"-r|--runtime <{LocalizableStrings.RuntimeOption}>", LocalizableStrings.RuntimeOptionDescription,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
CommandOption outputOption = app.Option(
|
||||
$"-o|--output <{LocalizableStrings.OutputOption}>", LocalizableStrings.OutputOptionDescription,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
CommandOption fxOption = app.Option(
|
||||
$"--framework-version <{LocalizableStrings.FrameworkVersionOption}>", LocalizableStrings.FrameworkVersionOptionDescription,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
CommandOption skipOptimizationOption = app.Option(
|
||||
$"--skip-optimization", LocalizableStrings.SkipOptimizationOptionDescription,
|
||||
CommandOptionType.NoValue);
|
||||
|
||||
CommandOption workingDir = app.Option(
|
||||
$"-w |--working-dir <{LocalizableStrings.IntermediateWorkingDirOption}>", LocalizableStrings.IntermediateWorkingDirOptionDescription,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
CommandOption preserveWorkingDir = app.Option(
|
||||
$"--preserve-working-dir", LocalizableStrings.PreserveIntermediateWorkingDirOptionDescription,
|
||||
CommandOptionType.NoValue);
|
||||
|
||||
CommandOption verbosityOption = MSBuildForwardingApp.AddVerbosityOption(app);
|
||||
|
||||
app.OnExecute(() =>
|
||||
{
|
||||
var cache = new CacheCommand();
|
||||
|
||||
cache.Framework = frameworkOption.Value();
|
||||
cache.Runtime = runtimeOption.Value();
|
||||
cache.OutputPath = outputOption.Value();
|
||||
cache.FrameworkVersion = fxOption.Value();
|
||||
cache.Verbosity = verbosityOption.Value();
|
||||
cache.SkipOptimization = skipOptimizationOption.HasValue();
|
||||
cache.IntermediateDir = workingDir.Value();
|
||||
cache.PreserveIntermediateDir = preserveWorkingDir.HasValue();
|
||||
cache.ExtraMSBuildArguments = app.RemainingArguments;
|
||||
cache.ProjectArgument = projectArgument.Value();
|
||||
|
||||
return cache.Execute();
|
||||
});
|
||||
|
||||
return app.Execute(args);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,5 +29,9 @@
|
|||
public const string VersionSuffixOption = "VERSION_SUFFIX";
|
||||
|
||||
public const string VersionSuffixOptionDescription = "Defines the value for the $(VersionSuffix) property in the project.";
|
||||
|
||||
public const string FilterProjOption = "profile.xml";
|
||||
|
||||
public const string FilterProjOptionDescription = "The XML file that contains the list of packages to be excluded from publish step.";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,11 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
CommandOption versionSuffixOption = app.Option(
|
||||
$"--version-suffix <{LocalizableStrings.VersionSuffixOption}>", LocalizableStrings.VersionSuffixOptionDescription,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
CommandOption filterProjOption = app.Option(
|
||||
$"--filter <{LocalizableStrings.FilterProjOption}>", LocalizableStrings.FilterProjOptionDescription,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
CommandOption verbosityOption = MSBuildForwardingApp.AddVerbosityOption(app);
|
||||
|
||||
app.OnExecute(() =>
|
||||
|
@ -55,6 +60,7 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
publish.OutputPath = outputOption.Value();
|
||||
publish.Configuration = configurationOption.Value();
|
||||
publish.VersionSuffix = versionSuffixOption.Value();
|
||||
publish.FilterProject = filterProjOption.Value();
|
||||
publish.Verbosity = verbosityOption.Value();
|
||||
publish.ExtraMSBuildArguments = app.RemainingArguments;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// 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.
|
||||
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.Tools.MSBuild;
|
||||
|
@ -16,6 +17,7 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
public string OutputPath { get; set; }
|
||||
public string Configuration { get; set; }
|
||||
public string VersionSuffix { get; set; }
|
||||
public string FilterProject { get; set; }
|
||||
public string Verbosity { get; set; }
|
||||
|
||||
public List<string> ExtraMSBuildArguments { get; set; }
|
||||
|
@ -60,6 +62,11 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
msbuildArgs.Add($"/p:VersionSuffix={VersionSuffix}");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(FilterProject))
|
||||
{
|
||||
msbuildArgs.Add($"/p:FilterProjFile={FilterProject}");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Verbosity))
|
||||
{
|
||||
msbuildArgs.Add($"/verbosity:{Verbosity}");
|
||||
|
|
Loading…
Add table
Reference in a new issue