Implicit restore for build, pack, publish, run and test.
This commit is contained in:
parent
a3d6c2a551
commit
dd76fec564
13 changed files with 91 additions and 21 deletions
40
src/dotnet/commands/RestoringCommand.cs
Normal file
40
src/dotnet/commands/RestoringCommand.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// 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 System.Linq;
|
||||
using Microsoft.DotNet.Tools.MSBuild;
|
||||
using Microsoft.DotNet.Tools.Restore;
|
||||
|
||||
namespace Microsoft.DotNet.Tools
|
||||
{
|
||||
public class RestoringCommand : MSBuildForwardingApp
|
||||
{
|
||||
private bool NoRestore { get; }
|
||||
|
||||
private IEnumerable<string> ArgsToForward { get; }
|
||||
|
||||
public RestoringCommand(IEnumerable<string> msbuildArgs, bool noRestore, string msbuildPath = null)
|
||||
: base(msbuildArgs, msbuildPath)
|
||||
{
|
||||
NoRestore = noRestore;
|
||||
ArgsToForward = msbuildArgs;
|
||||
}
|
||||
|
||||
public override int Execute()
|
||||
{
|
||||
if (ShouldRunImplicitRestore)
|
||||
{
|
||||
int exitCode = RestoreCommand.Run(ArgsToForward.ToArray());
|
||||
if (exitCode != 0)
|
||||
{
|
||||
return exitCode;
|
||||
}
|
||||
}
|
||||
|
||||
return base.Execute();
|
||||
}
|
||||
|
||||
private bool ShouldRunImplicitRestore => !NoRestore;
|
||||
}
|
||||
}
|
||||
Reference in a new issue