Make --no-build imply --no-restore for pack command.
This commit makes the `--no-build` option for the pack command automatically imply `--no-restore`. Fixes issue #7472.
This commit is contained in:
parent
de10b22bcd
commit
40b0e0fcec
18 changed files with 57 additions and 29 deletions
|
@ -130,7 +130,7 @@
|
|||
<value>Directory in which to place built packages.</value>
|
||||
</data>
|
||||
<data name="CmdNoBuildOptionDescription" xml:space="preserve">
|
||||
<value>Skip building the project prior to packing. By default, the project will be built.</value>
|
||||
<value>Do not build project before packing. Implies --no-restore.</value>
|
||||
</data>
|
||||
<data name="CmdIncludeSymbolsDescription" xml:space="preserve">
|
||||
<value>Include packages with symbols in addition to regular packages in output directory.</value>
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace Microsoft.DotNet.Tools.Pack
|
|||
|
||||
msbuildArgs.AddRange(parsedPack.Arguments);
|
||||
|
||||
bool noRestore = parsedPack.HasOption("--no-restore");
|
||||
bool noRestore = parsedPack.HasOption("--no-restore") || parsedPack.HasOption("--no-build");
|
||||
|
||||
return new PackCommand(
|
||||
msbuildArgs,
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdNoBuildOptionDescription">
|
||||
<source>Skip building the project prior to packing. By default, the project will be built.</source>
|
||||
<target state="translated">Přeskočí sestavení projektu, dokud ho nezabalíte. Projekt se sestaví automaticky.</target>
|
||||
<source>Do not build project before packing. Implies --no-restore.</source>
|
||||
<target state="needs-review-translation">Přeskočí sestavení projektu, dokud ho nezabalíte. Projekt se sestaví automaticky.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdIncludeSymbolsDescription">
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdNoBuildOptionDescription">
|
||||
<source>Skip building the project prior to packing. By default, the project will be built.</source>
|
||||
<target state="translated">Hiermit wird das Projekt nicht vor dem Packen erstellt. Standardmäßig wird das Projekt erstellt.</target>
|
||||
<source>Do not build project before packing. Implies --no-restore.</source>
|
||||
<target state="needs-review-translation">Hiermit wird das Projekt nicht vor dem Packen erstellt. Standardmäßig wird das Projekt erstellt.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdIncludeSymbolsDescription">
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdNoBuildOptionDescription">
|
||||
<source>Skip building the project prior to packing. By default, the project will be built.</source>
|
||||
<target state="translated">Omita la compilación del proyecto antes de empaquetar. El proyecto se compilará de manera predeterminada.</target>
|
||||
<source>Do not build project before packing. Implies --no-restore.</source>
|
||||
<target state="needs-review-translation">Omita la compilación del proyecto antes de empaquetar. El proyecto se compilará de manera predeterminada.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdIncludeSymbolsDescription">
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdNoBuildOptionDescription">
|
||||
<source>Skip building the project prior to packing. By default, the project will be built.</source>
|
||||
<target state="translated">Ignorez la génération du projet avant la compression. Par défaut, le projet est généré.</target>
|
||||
<source>Do not build project before packing. Implies --no-restore.</source>
|
||||
<target state="needs-review-translation">Ignorez la génération du projet avant la compression. Par défaut, le projet est généré.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdIncludeSymbolsDescription">
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdNoBuildOptionDescription">
|
||||
<source>Skip building the project prior to packing. By default, the project will be built.</source>
|
||||
<target state="translated">Consente di ignorare la compilazione del progetto prima di creare il pacchetto. Per impostazione predefinita, il progetto verrà compilato.</target>
|
||||
<source>Do not build project before packing. Implies --no-restore.</source>
|
||||
<target state="needs-review-translation">Consente di ignorare la compilazione del progetto prima di creare il pacchetto. Per impostazione predefinita, il progetto verrà compilato.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdIncludeSymbolsDescription">
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdNoBuildOptionDescription">
|
||||
<source>Skip building the project prior to packing. By default, the project will be built.</source>
|
||||
<target state="translated">パッキングの前に、プロジェクトの構築をスキップします。既定では、プロジェクトは構築されます。</target>
|
||||
<source>Do not build project before packing. Implies --no-restore.</source>
|
||||
<target state="needs-review-translation">パッキングの前に、プロジェクトの構築をスキップします。既定では、プロジェクトは構築されます。</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdIncludeSymbolsDescription">
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdNoBuildOptionDescription">
|
||||
<source>Skip building the project prior to packing. By default, the project will be built.</source>
|
||||
<target state="translated">압축하기 전에 프로젝트를 빌드하지 않습니다. 기본적으로 프로젝트가 빌드됩니다.</target>
|
||||
<source>Do not build project before packing. Implies --no-restore.</source>
|
||||
<target state="needs-review-translation">압축하기 전에 프로젝트를 빌드하지 않습니다. 기본적으로 프로젝트가 빌드됩니다.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdIncludeSymbolsDescription">
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdNoBuildOptionDescription">
|
||||
<source>Skip building the project prior to packing. By default, the project will be built.</source>
|
||||
<target state="translated">Pomiń kompilację projektu przed pakowaniem. Domyślnie projekt zostanie skompilowany.</target>
|
||||
<source>Do not build project before packing. Implies --no-restore.</source>
|
||||
<target state="needs-review-translation">Pomiń kompilację projektu przed pakowaniem. Domyślnie projekt zostanie skompilowany.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdIncludeSymbolsDescription">
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdNoBuildOptionDescription">
|
||||
<source>Skip building the project prior to packing. By default, the project will be built.</source>
|
||||
<target state="translated">Ignorar a compilação do projeto antes do empacotamento. Por padrão, o projeto será compilado.</target>
|
||||
<source>Do not build project before packing. Implies --no-restore.</source>
|
||||
<target state="needs-review-translation">Ignorar a compilação do projeto antes do empacotamento. Por padrão, o projeto será compilado.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdIncludeSymbolsDescription">
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdNoBuildOptionDescription">
|
||||
<source>Skip building the project prior to packing. By default, the project will be built.</source>
|
||||
<target state="translated">Пропуск сборки проекта перед упаковкой. По умолчанию выполняется сборка проекта.</target>
|
||||
<source>Do not build project before packing. Implies --no-restore.</source>
|
||||
<target state="needs-review-translation">Пропуск сборки проекта перед упаковкой. По умолчанию выполняется сборка проекта.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdIncludeSymbolsDescription">
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdNoBuildOptionDescription">
|
||||
<source>Skip building the project prior to packing. By default, the project will be built.</source>
|
||||
<target state="translated">Projeyi paketlemeden önce derlemeyi atlayın. Varsayılan olarak, proje derlenir.</target>
|
||||
<source>Do not build project before packing. Implies --no-restore.</source>
|
||||
<target state="needs-review-translation">Projeyi paketlemeden önce derlemeyi atlayın. Varsayılan olarak, proje derlenir.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdIncludeSymbolsDescription">
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdNoBuildOptionDescription">
|
||||
<source>Skip building the project prior to packing. By default, the project will be built.</source>
|
||||
<target state="translated">在打包之前跳过生成项目。默认情况下,将生成项目。</target>
|
||||
<source>Do not build project before packing. Implies --no-restore.</source>
|
||||
<target state="needs-review-translation">在打包之前跳过生成项目。默认情况下,将生成项目。</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdIncludeSymbolsDescription">
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdNoBuildOptionDescription">
|
||||
<source>Skip building the project prior to packing. By default, the project will be built.</source>
|
||||
<target state="translated">在封裝前跳過建置專案。預設會建置專案。</target>
|
||||
<source>Do not build project before packing. Implies --no-restore.</source>
|
||||
<target state="needs-review-translation">在封裝前跳過建置專案。預設會建置專案。</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="CmdIncludeSymbolsDescription">
|
||||
|
|
|
@ -69,6 +69,13 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<CommandResultAssertions> NotHaveStdOutContaining(string pattern)
|
||||
{
|
||||
Execute.Assertion.ForCondition(!_commandResult.StdOut.Contains(pattern))
|
||||
.FailWith(AppendDiagnosticsTo($"The command output contained a result it should not have contained: {pattern}{Environment.NewLine}"));
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<CommandResultAssertions> HaveStdOutMatching(string pattern, RegexOptions options = RegexOptions.None)
|
||||
{
|
||||
Execute.Assertion.ForCondition(Regex.Match(_commandResult.StdOut, pattern, options).Success)
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
|
|||
public class GivenDotnetPackInvocation
|
||||
{
|
||||
const string ExpectedPrefix = "exec <msbuildpath> /m /v:m /restore /t:pack";
|
||||
const string ExpectedNoBuildPrefix = "exec <msbuildpath> /m /v:m /t:pack";
|
||||
|
||||
[Theory]
|
||||
[InlineData(new string[] { }, "")]
|
||||
|
@ -34,9 +35,10 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
|
|||
|
||||
var msbuildPath = "<msbuildpath>";
|
||||
var command = PackCommand.FromArgs(args, msbuildPath);
|
||||
var expectedPrefix = args.FirstOrDefault() == "--no-build" ? ExpectedNoBuildPrefix : ExpectedPrefix;
|
||||
|
||||
command.SeparateRestoreCommand.Should().BeNull();
|
||||
command.GetProcessStartInfo().Arguments.Should().Be($"{ExpectedPrefix}{expectedAdditionalArgs}");
|
||||
command.GetProcessStartInfo().Arguments.Should().Be($"{expectedPrefix}{expectedAdditionalArgs}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -186,6 +186,25 @@ namespace Microsoft.DotNet.Tools.Pack.Tests
|
|||
.Should().Pass();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItDoesNotImplicitlyBuildAProjectWhenPackagingWithTheNoBuildOption()
|
||||
{
|
||||
var testInstance = TestAssets.Get("TestAppSimple")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles();
|
||||
|
||||
var result = new PackCommand()
|
||||
.WithWorkingDirectory(testInstance.Root)
|
||||
.ExecuteWithCapturedOutput("--no-build");
|
||||
|
||||
result.Should().Fail();
|
||||
if (!DotnetUnderTest.IsLocalized())
|
||||
{
|
||||
result.Should().NotHaveStdOutContaining("Restore")
|
||||
.And.HaveStdOutContaining("project.assets.json");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItDoesNotImplicitlyRestoreAProjectWhenPackagingWithTheNoRestoreOption()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue