Implement dotnet publish --no-build
This commit is contained in:
parent
1e2e8138b9
commit
b6174af511
19 changed files with 152 additions and 6 deletions
|
@ -14,7 +14,7 @@
|
|||
<MicrosoftNETCoreCompilersPackageVersion>$(MicrosoftCodeAnalysisCSharpPackageVersion)</MicrosoftNETCoreCompilersPackageVersion>
|
||||
<MicrosoftCodeAnalysisBuildTasksPackageVersion>$(MicrosoftCodeAnalysisCSharpPackageVersion)</MicrosoftCodeAnalysisBuildTasksPackageVersion>
|
||||
<MicrosoftNetCompilersNetcorePackageVersion>$(MicrosoftCodeAnalysisCSharpPackageVersion)</MicrosoftNetCompilersNetcorePackageVersion>
|
||||
<MicrosoftNETSdkPackageVersion>2.1.300-preview2-62716-01</MicrosoftNETSdkPackageVersion>
|
||||
<MicrosoftNETSdkPackageVersion>2.1.300-preview3-62804-06</MicrosoftNETSdkPackageVersion>
|
||||
<MicrosoftNETBuildExtensionsPackageVersion>$(MicrosoftNETSdkPackageVersion)</MicrosoftNETBuildExtensionsPackageVersion>
|
||||
<MicrosoftNETSdkRazorPackageVersion>$(MicrosoftAspNetCoreAppPackageVersion)</MicrosoftNETSdkRazorPackageVersion>
|
||||
<MicrosoftNETSdkWebPackageVersion>2.1.300-preview2-20180306-1448279</MicrosoftNETSdkWebPackageVersion>
|
||||
|
|
|
@ -141,4 +141,7 @@
|
|||
<data name="SelfContainedOptionDescription" xml:space="preserve">
|
||||
<value>Publish the .NET Core runtime with your application so the runtime doesn't need to be installed on the target machine. Defaults to 'true' if a runtime identifier is specified.</value>
|
||||
</data>
|
||||
<data name="NoBuildOptionDescription" xml:space="preserve">
|
||||
<value>Do not build project before publishing. Implies --no-restore.</value>
|
||||
</data>
|
||||
</root>
|
|
@ -43,7 +43,8 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
|
||||
msbuildArgs.AddRange(appliedPublishOption.Arguments);
|
||||
|
||||
bool noRestore = appliedPublishOption.HasOption("--no-restore");
|
||||
bool noRestore = appliedPublishOption.HasOption("--no-restore")
|
||||
|| appliedPublishOption.HasOption("--no-build");
|
||||
|
||||
return new PublishCommand(
|
||||
msbuildArgs,
|
||||
|
@ -70,4 +71,4 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
return cmd.Execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// 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.Cli.CommandLine;
|
||||
using Microsoft.DotNet.Tools;
|
||||
|
@ -33,6 +32,10 @@ namespace Microsoft.DotNet.Cli
|
|||
Accept.OneOrMoreArguments()
|
||||
.With(name: LocalizableStrings.ManifestOption)
|
||||
.ForwardAsSingle(o => $"-property:TargetManifestFiles={string.Join("%3B", o.Arguments)}")),
|
||||
Create.Option(
|
||||
"--no-build",
|
||||
LocalizableStrings.NoBuildOptionDescription,
|
||||
Accept.NoArguments().ForwardAs("-property:NoBuild=true")),
|
||||
Create.Option(
|
||||
"--self-contained",
|
||||
LocalizableStrings.SelfContainedOptionDescription,
|
||||
|
@ -46,4 +49,4 @@ namespace Microsoft.DotNet.Cli
|
|||
CommonOptions.NoRestoreOption(),
|
||||
CommonOptions.VerbosityOption());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,11 @@
|
|||
<target state="translated">Publikuje spolu s aplikací modul runtime .NET Core, aby se tento modul nemusel instalovat na cílový počítač. Standardně se nastaví na True, pokud je zadaný identifikátor modulu runtime.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="NoBuildOptionDescription">
|
||||
<source>Do not build project before publishing. Implies --no-restore.</source>
|
||||
<target state="new">Do not build project before publishing. Implies --no-restore.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -42,6 +42,11 @@
|
|||
<target state="translated">Veröffentlichen Sie die .NET Core-Runtime mit Ihrer Anwendung, damit die Runtime auf dem Zielcomputer nicht installiert werden muss. Der Standardwert ist "true", wenn ein Runtimebezeichner angegeben ist.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="NoBuildOptionDescription">
|
||||
<source>Do not build project before publishing. Implies --no-restore.</source>
|
||||
<target state="new">Do not build project before publishing. Implies --no-restore.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -42,6 +42,11 @@
|
|||
<target state="translated">Publica el tiempo de ejecución de .NET Core con su aplicación para que no sea necesario instalarlo en la máquina de destino. Si se especifica un identificador de tiempo de ejecución, se toma como predeterminado el valor "true".</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="NoBuildOptionDescription">
|
||||
<source>Do not build project before publishing. Implies --no-restore.</source>
|
||||
<target state="new">Do not build project before publishing. Implies --no-restore.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -42,6 +42,11 @@
|
|||
<target state="translated">Publiez le runtime .NET Core avec votre application pour éviter à l'utilisateur de l'installer sur la machine cible. La valeur par défaut est 'true' si un identificateur de runtime est spécifié.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="NoBuildOptionDescription">
|
||||
<source>Do not build project before publishing. Implies --no-restore.</source>
|
||||
<target state="new">Do not build project before publishing. Implies --no-restore.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -42,6 +42,11 @@
|
|||
<target state="translated">Pubblica il runtime di .NET Core con l'applicazione in modo che non sia necessario installarlo nel computer di destinazione. Se si specifica un identificatore di runtime, l'impostazione predefinita è 'true'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="NoBuildOptionDescription">
|
||||
<source>Do not build project before publishing. Implies --no-restore.</source>
|
||||
<target state="new">Do not build project before publishing. Implies --no-restore.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -42,6 +42,11 @@
|
|||
<target state="translated">ランタイムをターゲット マシンにインストールしなくてもよいよう、.NET Core ランタイムをアプリケーションと一緒に発行します。ランタイム ID が指定される場合、既定の 'true' になります。</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="NoBuildOptionDescription">
|
||||
<source>Do not build project before publishing. Implies --no-restore.</source>
|
||||
<target state="new">Do not build project before publishing. Implies --no-restore.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -42,6 +42,11 @@
|
|||
<target state="translated">런타임은 대상 컴퓨터에 설치할 필요가 없으므로 응용 프로그램과 함께 .NET Core 런타임을 게시합니다. 런타임 식별자가 지정된 경우 기본값은 'true'입니다.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="NoBuildOptionDescription">
|
||||
<source>Do not build project before publishing. Implies --no-restore.</source>
|
||||
<target state="new">Do not build project before publishing. Implies --no-restore.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -42,6 +42,11 @@
|
|||
<target state="translated">Opublikuj środowisko uruchomieniowe programu .NET Core z aplikacją, aby nie trzeba było go instalować na maszynie docelowej. Domyślnie jest ustawiona wartość „true” w przypadku określenia identyfikatora środowiska uruchomieniowego.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="NoBuildOptionDescription">
|
||||
<source>Do not build project before publishing. Implies --no-restore.</source>
|
||||
<target state="new">Do not build project before publishing. Implies --no-restore.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -42,6 +42,11 @@
|
|||
<target state="translated">Publique o tempo de execução .NET Core com seu aplicativo para que o tempo de execução não precise ser instalado no computador de destino. Assumirá 'true' como padrão se um identificador de tempo de execução for especificado.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="NoBuildOptionDescription">
|
||||
<source>Do not build project before publishing. Implies --no-restore.</source>
|
||||
<target state="new">Do not build project before publishing. Implies --no-restore.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -42,6 +42,11 @@
|
|||
<target state="translated">Опубликуйте среду выполнения .NET Core вместе с приложением, чтобы ее не нужно было устанавливать на целевом компьютере. Если идентификатор среды выполнения указан, значение по умолчанию — true.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="NoBuildOptionDescription">
|
||||
<source>Do not build project before publishing. Implies --no-restore.</source>
|
||||
<target state="new">Do not build project before publishing. Implies --no-restore.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -42,6 +42,11 @@
|
|||
<target state="translated">Çalışma zamanının hedef makineye yüklenmesine gerek kalmaması için, .NET Core çalışma zamanını uygulamanızla birlikte yayımlayın. Bir çalışma zamanı tanımlayıcısı belirtilmişse, varsayılan olarak 'true' değerine ayarlanır.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="NoBuildOptionDescription">
|
||||
<source>Do not build project before publishing. Implies --no-restore.</source>
|
||||
<target state="new">Do not build project before publishing. Implies --no-restore.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -42,6 +42,11 @@
|
|||
<target state="translated">随附应用程序发布 .NET Core 运行时,免除在目标计算机上安装运行时的需求。如果指定了运行时标识符,则默认为 “true”。</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="NoBuildOptionDescription">
|
||||
<source>Do not build project before publishing. Implies --no-restore.</source>
|
||||
<target state="new">Do not build project before publishing. Implies --no-restore.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -42,6 +42,11 @@
|
|||
<target state="translated">隨著應用程式一併發行 .NET Core 執行階段,因此不需要在目標電腦上安裝此執行階段。若指定了執行階段識別碼,則預設為 'true'。</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="NoBuildOptionDescription">
|
||||
<source>Do not build project before publishing. Implies --no-restore.</source>
|
||||
<target state="new">Do not build project before publishing. Implies --no-restore.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -72,6 +72,23 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
|
|||
.Be($"{ExpectedPrefix} -nologo -target:Publish{expectedAdditionalArgs}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MsbuildInvocationIsCorrectForNoBuild()
|
||||
{
|
||||
var msbuildPath = "<msbuildpath>";
|
||||
var command = PublishCommand.FromArgs(new[] { "--no-build" }, msbuildPath);
|
||||
|
||||
command.SeparateRestoreCommand
|
||||
.Should()
|
||||
.BeNull();
|
||||
|
||||
// NOTE --no-build implies no-restore hence no -restore argument to msbuild below.
|
||||
command.GetProcessStartInfo()
|
||||
.Arguments
|
||||
.Should()
|
||||
.Be($"{ExpectedPrefix} -target:Publish -property:NoBuild=true");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(new string[] { }, "")]
|
||||
[InlineData(new string[] { "-f", "<tfm>" }, "-property:TargetFramework=<tfm>")]
|
||||
|
@ -86,6 +103,7 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
|
|||
[InlineData(new string[] { "--manifest", "<manifestfiles>" }, "-property:TargetManifestFiles=<manifestfiles>")]
|
||||
[InlineData(new string[] { "-v", "minimal" }, "-verbosity:minimal")]
|
||||
[InlineData(new string[] { "--verbosity", "minimal" }, "-verbosity:minimal")]
|
||||
[InlineData(new string[] { "--no-build" }, "-property:NoBuild=true")]
|
||||
public void OptionForwardingIsCorrect(string[] args, string expectedAdditionalArgs)
|
||||
{
|
||||
var expectedArgs = expectedAdditionalArgs.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||
|
@ -100,4 +118,4 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
|
|||
.BeEquivalentTo(expectedArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -235,5 +235,61 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
|
|||
.Should().Pass()
|
||||
.And.HaveStdOutContaining("Hello World");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItFailsToPublishWithNoBuildIfNotPreviouslyBuilt()
|
||||
{
|
||||
var rootPath = TestAssets.CreateTestDirectory().FullName;
|
||||
|
||||
string newArgs = $"console -o \"{rootPath}\"";
|
||||
new NewCommandShim()
|
||||
.WithWorkingDirectory(rootPath)
|
||||
.Execute(newArgs)
|
||||
.Should().Pass();
|
||||
|
||||
new PublishCommand()
|
||||
.WithWorkingDirectory(rootPath)
|
||||
.ExecuteWithCapturedOutput("--no-build")
|
||||
.Should().Fail()
|
||||
.And.HaveStdOutContaining("MSB3030"); // "Could not copy ___ because it was not found.
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItPublishesSuccessfullyWithNoBuildIfPreviouslyBuilt()
|
||||
{
|
||||
var rootPath = TestAssets.CreateTestDirectory().FullName;
|
||||
var rootDir = new DirectoryInfo(rootPath);
|
||||
|
||||
string newArgs = $"console -o \"{rootPath}\" --no-restore";
|
||||
new NewCommandShim()
|
||||
.WithWorkingDirectory(rootPath)
|
||||
.Execute(newArgs)
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
new BuildCommand()
|
||||
.WithWorkingDirectory(rootPath)
|
||||
.ExecuteWithCapturedOutput()
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
new PublishCommand()
|
||||
.WithWorkingDirectory(rootPath)
|
||||
.ExecuteWithCapturedOutput("--no-build")
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
|
||||
|
||||
var outputProgram = rootDir
|
||||
.GetDirectory("bin", configuration, "netcoreapp2.1", "publish", $"{rootDir.Name}.dll")
|
||||
.FullName;
|
||||
|
||||
new TestCommand(outputProgram)
|
||||
.ExecuteWithCapturedOutput()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And.HaveStdOutContaining("Hello World");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue