Skip to content

Commit

Permalink
Bundles: Flow configuration from project
Browse files Browse the repository at this point in the history
Resolves #25906
  • Loading branch information
bricelam committed Sep 15, 2021
1 parent 5d7ca16 commit 302b246
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 31 deletions.
10 changes: 1 addition & 9 deletions src/EFCore.Tools/tools/EntityFrameworkCore.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ Register-TabExpansion Bundle-Migration @{
.PARAMETER TargetRuntime
The target runtime to bundle for.
.PARAMETER Configuration
The configuration to use for the bundle.
.PARAMETER Framework
The target framework. Defaults to the first one in the project.
Expand Down Expand Up @@ -153,7 +150,6 @@ function Bundle-Migration
[switch] $Force,
[switch] $SelfContained,
[string] $TargetRuntime,
[string] $Configuration,
[string] $Framework,
[string] $Context,
[string] $Project,
Expand Down Expand Up @@ -190,11 +186,6 @@ function Bundle-Migration
$params += '--target-runtime', $TargetRuntime
}

if ($Configuration)
{
$params += '--target-configuration', $Configuration
}

$params += GetParams $Context

EF $dteProject $dteStartupProject $params $Args
Expand Down Expand Up @@ -1308,6 +1299,7 @@ function EF($project, $startupProject, $params, $applicationArgs, [switch] $skip
'--startup-project', $startupProject.FullName,
'--project-dir', $projectDir,
'--language', $language,
'--configuration', $activeConfiguration.ConfigurationName,
'--working-dir', $PWD.Path

if (IsWeb $startupProject)
Expand Down
8 changes: 2 additions & 6 deletions src/dotnet-ef/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/dotnet-ef/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,6 @@
<data name="MigrationsAddDescription" xml:space="preserve">
<value>Adds a new migration.</value>
</data>
<data name="MigrationsBundleConfigurationDescription" xml:space="preserve">
<value>The configuration to use for the bundle.</value>
</data>
<data name="MigrationsBundleDescription" xml:space="preserve">
<value>Creates an executable to update the database.</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions src/dotnet-ef/RootCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ protected override int Execute(string[] _)
args.Add("--framework");
args.Add(startupProject.TargetFramework!);

if (_configuration.HasValue())
{
args.Add("--configuration");
args.Add(_configuration.Value()!);
}

if (string.Equals(project.Nullable, "enable", StringComparison.OrdinalIgnoreCase)
|| string.Equals(project.Nullable, "annotations", StringComparison.OrdinalIgnoreCase))
{
Expand Down
2 changes: 0 additions & 2 deletions src/ef/Commands/MigrationsBundleCommand.Configure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ internal partial class MigrationsBundleCommand : ContextCommandBase
private CommandOption? _force;
private CommandOption? _selfContained;
private CommandOption? _runtime;
private CommandOption? _configuration;

public override void Configure(CommandLineApplication command)
{
Expand All @@ -22,7 +21,6 @@ public override void Configure(CommandLineApplication command)
_force = command.Option("-f|--force", Resources.DbContextScaffoldForceDescription);
_selfContained = command.Option("--self-contained", Resources.SelfContainedDescription);
_runtime = command.Option("-r|--target-runtime <RUNTIME_IDENTIFIER>", Resources.MigrationsBundleRuntimeDescription);
_configuration = command.Option("--target-configuration <CONFIGURATION>", Resources.MigrationsBundleConfigurationDescription);

base.Configure(command);
}
Expand Down
6 changes: 4 additions & 2 deletions src/ef/Commands/MigrationsBundleCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,12 @@ protected override int Execute(string[] args)
? "--self-contained"
: "--no-self-contained");

if (_configuration!.HasValue())
var configuration = Configuration!.Value();
if (string.Equals(configuration, "Debug", StringComparison.OrdinalIgnoreCase)
|| string.Equals(configuration, "Release", StringComparison.OrdinalIgnoreCase))
{
publishArgs.Add("--configuration");
publishArgs.Add(_configuration!.Value()!);
publishArgs.Add(configuration!);
}

var exitCode = Exe.Run("dotnet", publishArgs, directory, interceptOutput: true);
Expand Down
2 changes: 2 additions & 0 deletions src/ef/Commands/ProjectCommandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ internal abstract class ProjectCommandBase : EFCommandBase
protected CommandOption? StartupProject { get; private set; }
protected CommandOption? WorkingDir { get; private set; }
protected CommandOption? Framework { get; private set; }
protected CommandOption? Configuration { get; private set; }

protected string? EFCoreVersion
=> _efcoreVersion ??= System.Reflection.Assembly.Load("Microsoft.EntityFrameworkCore.Design")
Expand All @@ -49,6 +50,7 @@ public override void Configure(CommandLineApplication command)
_nullable = command.Option("--nullable", Resources.NullableDescription);
WorkingDir = command.Option("--working-dir <PATH>", Resources.WorkingDirDescription);
Framework = command.Option("--framework <FRAMEWORK>", Resources.FrameworkDescription);
Configuration = command.Option("--configuration <CONFIGURATION>", Resources.ConfigurationDescription);

base.Configure(command);
}
Expand Down
14 changes: 8 additions & 6 deletions src/ef/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/ef/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@
<data name="BuildBundleSucceeded" xml:space="preserve">
<value>Done. Migrations Bundle: {path}</value>
</data>
<data name="ConfigurationDescription" xml:space="preserve">
<value>The configuration to use.</value>
</data>
<data name="ConnectionDescription" xml:space="preserve">
<value>The connection string to the database.</value>
</data>
Expand Down Expand Up @@ -243,9 +246,6 @@
<data name="MigrationsAddDescription" xml:space="preserve">
<value>Adds a new migration.</value>
</data>
<data name="MigrationsBundleConfigurationDescription" xml:space="preserve">
<value>The configuration to use for the bundle.</value>
</data>
<data name="MigrationsBundleDescription" xml:space="preserve">
<value>Creates an executable to update the database.</value>
</data>
Expand Down

0 comments on commit 302b246

Please sign in to comment.