From 8b2d0c63cb66aed774ebdc05b48690b1aaed357a Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Mon, 22 Jul 2019 15:50:00 -0700 Subject: [PATCH] Clean up PowerShell assets Changes: - Merge changes made in EF6 - Enable Get-Help in PS2 - Also warn about EF 6.3 - Remove unnecessary workarounds - Remove xproj detection - Remove install.ps1 --- .../EntityFrameworkCore.PS2.psd1.in | 96 ++++++ .../EntityFrameworkCore.PowerShell2.psd1.in | 89 ----- src/EFCore.Tools/EntityFrameworkCore.psd1.in | 167 +++++---- .../tools/EntityFrameworkCore.PS2.psm1 | 318 ++++++++++++++++++ .../EntityFrameworkCore.PowerShell2.psm1 | 63 ---- .../tools/EntityFrameworkCore.psm1 | 42 +-- src/EFCore.Tools/tools/init.ps1 | 44 ++- src/EFCore.Tools/tools/install.ps1 | 5 - 8 files changed, 543 insertions(+), 281 deletions(-) create mode 100644 src/EFCore.Tools/EntityFrameworkCore.PS2.psd1.in delete mode 100644 src/EFCore.Tools/EntityFrameworkCore.PowerShell2.psd1.in create mode 100644 src/EFCore.Tools/tools/EntityFrameworkCore.PS2.psm1 delete mode 100644 src/EFCore.Tools/tools/EntityFrameworkCore.PowerShell2.psm1 delete mode 100644 src/EFCore.Tools/tools/install.ps1 diff --git a/src/EFCore.Tools/EntityFrameworkCore.PS2.psd1.in b/src/EFCore.Tools/EntityFrameworkCore.PS2.psd1.in new file mode 100644 index 00000000000..617ebf96d00 --- /dev/null +++ b/src/EFCore.Tools/EntityFrameworkCore.PS2.psd1.in @@ -0,0 +1,96 @@ +# +# Module manifest for module 'EntityFrameworkCore.PS2' +# + +@{ + +# Script module or binary module file associated with this manifest +ModuleToProcess = 'EntityFrameworkCore.PS2.psm1' + +# Version number of this module. +ModuleVersion = '${VersionPrefix}' + +# ID used to uniquely identify this module +GUID = '2de7c7fd-c848-41d7-8634-37fed4d3bb36' + +# Author of this module +Author = 'Entity Framework Team' + +# Company or vendor of this module +CompanyName = 'Microsoft Corporation' + +# Copyright statement for this module +Copyright = '(c) .NET Foundation. All rights reserved.' + +# Description of the functionality provided by this module +Description = 'Entity Framework Core Package Manager Console Tools' + +# Minimum version of the Windows PowerShell engine required by this module +PowerShellVersion = '2.0' + +# Name of the Windows PowerShell host required by this module +PowerShellHostName = 'Package Manager Host' + +# Minimum version of the Windows PowerShell host required by this module +PowerShellHostVersion = '1.2' + +# Minimum version of the .NET Framework required by this module +DotNetFrameworkVersion = '4.0' + +# Minimum version of the common language runtime (CLR) required by this module +CLRVersion = '' + +# Processor architecture (None, X86, Amd64, IA64) required by this module +ProcessorArchitecture = '' + +# Modules that must be imported into the global environment prior to importing this module +RequiredModules = @() + +# Assemblies that must be loaded prior to importing this module +RequiredAssemblies = @() + +# Script files (.ps1) that are run in the caller's environment prior to importing this module +ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +FormatsToProcess = @() + +# Modules to import as nested modules of the module specified in ModuleToProcess +NestedModules = @() + +# Functions to export from this module +FunctionsToExport = ( + 'Add-Migration', + 'Drop-Database', + 'Enable-Migrations', + 'Get-DbContext', + 'Remove-Migration', + 'Scaffold-DbContext', + 'Script-DbContext', + 'Script-Migration', + 'Update-Database' +) + +# Cmdlets to export from this module +CmdletsToExport = @() + +# Variables to export from this module +VariablesToExport = @() + +# Aliases to export from this module +AliasesToExport = @() + +# List of all modules packaged with this module +ModuleList = @() + +# List of all files packaged with this module +FileList = @() + +# Private data to pass to the module specified in ModuleToProcess +PrivateData = '' + +} + diff --git a/src/EFCore.Tools/EntityFrameworkCore.PowerShell2.psd1.in b/src/EFCore.Tools/EntityFrameworkCore.PowerShell2.psd1.in deleted file mode 100644 index 2677a033204..00000000000 --- a/src/EFCore.Tools/EntityFrameworkCore.PowerShell2.psd1.in +++ /dev/null @@ -1,89 +0,0 @@ -@{ - # Script module or binary module file associated with this manifest - ModuleToProcess = 'EntityFrameworkCore.PowerShell2.psm1' - - # Version number of this module. - ModuleVersion = '${VersionPrefix}' - - # ID used to uniquely identify this module - GUID = '2de7c7fd-c848-41d7-8634-37fed4d3bb36' - - # Author of this module - Author = 'Entity Framework Team' - - # Company or vendor of this module - CompanyName = 'Microsoft Corporation' - - # Copyright statement for this module - Copyright = '(c) .NET Foundation. All rights reserved.' - - # Description of the functionality provided by this module - Description = 'Entity Framework Core Package Manager Console Tools' - - # Minimum version of the Windows PowerShell engine required by this module - PowerShellVersion = '2.0' - - # Name of the Windows PowerShell host required by this module - PowerShellHostName = 'Package Manager Host' - - # Minimum version of the Windows PowerShell host required by this module - PowerShellHostVersion = '1.2' - - # Minimum version of the .NET Framework required by this module - DotNetFrameworkVersion = '4.0' - - # Minimum version of the common language runtime (CLR) required by this module - CLRVersion = '' - - # Processor architecture (None, X86, Amd64, IA64) required by this module - ProcessorArchitecture = '' - - # Modules that must be imported into the global environment prior to importing this module - RequiredModules = @() - - # Assemblies that must be loaded prior to importing this module - RequiredAssemblies = @() - - # Script files (.ps1) that are run in the caller's environment prior to importing this module - ScriptsToProcess = @() - - # Type files (.ps1xml) to be loaded when importing this module - TypesToProcess = @() - - # Format files (.ps1xml) to be loaded when importing this module - FormatsToProcess = @() - - # Modules to import as nested modules of the module specified in ModuleToProcess - NestedModules = @() - - # Functions to export from this module - FunctionsToExport = ( - 'Add-Migration', - 'Drop-Database', - 'Enable-Migrations', - 'Get-DbContext', - 'Remove-Migration', - 'Scaffold-DbContext', - 'Script-DbContext', - 'Script-Migration', - 'Update-Database' - ) - - # Cmdlets to export from this module - CmdletsToExport = @() - - # Variables to export from this module - VariablesToExport = @() - - # Aliases to export from this module - AliasesToExport = @() - - # List of all modules packaged with this module - ModuleList = @() - - # List of all files packaged with this module - FileList = @() - - # Private data to pass to the module specified in ModuleToProcess - PrivateData = '' -} diff --git a/src/EFCore.Tools/EntityFrameworkCore.psd1.in b/src/EFCore.Tools/EntityFrameworkCore.psd1.in index e66e1055417..81c2ea68ca9 100644 --- a/src/EFCore.Tools/EntityFrameworkCore.psd1.in +++ b/src/EFCore.Tools/EntityFrameworkCore.psd1.in @@ -1,98 +1,129 @@ +# +# Module manifest for module 'EntityFrameworkCore' +# + @{ - # Script module or binary module file associated with this manifest. - RootModule = 'EntityFrameworkCore.psm1' - # Version number of this module. - ModuleVersion = '${VersionPrefix}' +# Script module or binary module file associated with this manifest. +RootModule = 'EntityFrameworkCore.psm1' + +# Version number of this module. +ModuleVersion = '${VersionPrefix}' + +# Supported PSEditions +# CompatiblePSEditions = @() + +# ID used to uniquely identify this module +GUID = 'c126fb40-c0f1-43ae-8dd0-06bb50512eb2' + +# Author of this module +Author = 'Entity Framework Team' + +# Company or vendor of this module +CompanyName = 'Microsoft Corporation' + +# Copyright statement for this module +Copyright = '(c) .NET Foundation. All rights reserved.' - # Supported PSEditions - # CompatiblePSEditions = @() +# Description of the functionality provided by this module +Description = 'Entity Framework Core Package Manager Console Tools' - # ID used to uniquely identify this module - GUID = 'c126fb40-c0f1-43ae-8dd0-06bb50512eb2' +# Minimum version of the Windows PowerShell engine required by this module +PowerShellVersion = '3.0' - # Author of this module - Author = 'Entity Framework Team' +# Name of the Windows PowerShell host required by this module +PowerShellHostName = 'Package Manager Host' - # Company or vendor of this module - CompanyName = 'Microsoft Corporation' +# Minimum version of the Windows PowerShell host required by this module +PowerShellHostVersion = '1.2' - # Copyright statement for this module - Copyright = '(c) .NET Foundation. All rights reserved.' +# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +DotNetFrameworkVersion = '4.0' - # Description of the functionality provided by this module - Description = 'Entity Framework Core Package Manager Console Tools' +# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# CLRVersion = '' - # Minimum version of the Windows PowerShell engine required by this module - PowerShellVersion = '3.0' +# Processor architecture (None, X86, Amd64) required by this module +# ProcessorArchitecture = '' - # Name of the Windows PowerShell host required by this module - PowerShellHostName = 'Package Manager Host' +# Modules that must be imported into the global environment prior to importing this module +# RequiredModules = @() - # Minimum version of the Windows PowerShell host required by this module - PowerShellHostVersion = '1.2' +# Assemblies that must be loaded prior to importing this module +# RequiredAssemblies = @() - # Minimum version of the .NET Framework required by this module - DotNetFrameworkVersion = '4.0' +# Script files (.ps1) that are run in the caller's environment prior to importing this module. +# ScriptsToProcess = @() - # Minimum version of the common language runtime (CLR) required by this module - # CLRVersion = '' +# Type files (.ps1xml) to be loaded when importing this module +# TypesToProcess = @() - # Processor architecture (None, X86, Amd64) required by this module - # ProcessorArchitecture = '' +# Format files (.ps1xml) to be loaded when importing this module +# FormatsToProcess = @() - # Modules that must be imported into the global environment prior to importing this module - # RequiredModules = @() +# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess +# NestedModules = @() - # Assemblies that must be loaded prior to importing this module - # RequiredAssemblies = @() +# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. +FunctionsToExport = ( + 'Add-Migration', + 'Drop-Database', + 'Enable-Migrations', + 'Get-DbContext', + 'Remove-Migration', + 'Scaffold-DbContext', + 'Script-DbContext', + 'Script-Migration', + 'Update-Database' +) - # Script files (.ps1) that are run in the caller's environment prior to importing this module. - # ScriptsToProcess = @() +# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. +CmdletsToExport = @() - # Type files (.ps1xml) to be loaded when importing this module - # TypesToProcess = @() +# Variables to export from this module +VariablesToExport = @() - # Format files (.ps1xml) to be loaded when importing this module - # FormatsToProcess = @() +# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. +AliasesToExport = @() - # Modules to import as nested modules of the module specified in RootModule - # NestedModules = @() +# DSC resources to export from this module +# DscResourcesToExport = @() - # Functions to export from this module - FunctionsToExport = ( - 'Add-Migration', - 'Drop-Database', - 'Enable-Migrations', - 'Get-DbContext', - 'Remove-Migration', - 'Scaffold-DbContext', - 'Script-DbContext', - 'Script-Migration', - 'Update-Database' - ) +# List of all modules packaged with this module +# ModuleList = @() - # Cmdlets to export from this module - CmdletsToExport = @() +# List of all files packaged with this module +# FileList = @() - # Variables to export from this module - VariablesToExport = @() +# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. +PrivateData = @{ - # Aliases to export from this module - AliasesToExport = @() + PSData = @{ - # List of all modules packaged with this module. - # ModuleList = @() + # Tags applied to this module. These help with module discovery in online galleries. + # Tags = @() - # List of all files packaged with this module - # FileList = @() + # A URL to the license for this module. + # LicenseUri = '' - # Private data to pass to the module specified in RootModule - # PrivateData = '' + # A URL to the main website for this project. + # ProjectUri = '' - # HelpInfo URI of this module - # HelpInfoURI = '' + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + # ReleaseNotes = '' + + } # End of PSData hashtable + +} # End of PrivateData hashtable + +# HelpInfo URI of this module +# HelpInfoURI = '' + +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +# DefaultCommandPrefix = '' - # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. - # DefaultCommandPrefix = '' } + diff --git a/src/EFCore.Tools/tools/EntityFrameworkCore.PS2.psm1 b/src/EFCore.Tools/tools/EntityFrameworkCore.PS2.psm1 new file mode 100644 index 00000000000..689d8b4c694 --- /dev/null +++ b/src/EFCore.Tools/tools/EntityFrameworkCore.PS2.psm1 @@ -0,0 +1,318 @@ +$ErrorActionPreference = 'Stop' + +$versionErrorMessage = 'The Entity Framework Core Package Manager Console Tools require Windows PowerShell 3.0 or ' + + 'higher. Install Windows Management Framework 3.0, restart Visual Studio, and try again. https://aka.ms/wmf3download' + +<# +.SYNOPSIS + Adds a new migration. + +.DESCRIPTION + Adds a new migration. + +.PARAMETER Name + The name of the migration. + +.PARAMETER OutputDir + The directory (and sub-namespace) to use. Paths are relative to the project directory. Defaults to "Migrations". + +.PARAMETER Context + The DbContext type to use. + +.PARAMETER Project + The project to use. + +.PARAMETER StartupProject + The startup project to use. Defaults to the solution's startup project. + +.LINK + Remove-Migration + Update-Database + about_EntityFrameworkCore +#> +function Add-Migration( + $Name, + $OutputDir, + $Context, + $Project, + $StartupProject) +{ + WarnIfEF6 'Add-Migration' + throw $UpdatePowerShell +} + +<# +.SYNOPSIS + Drops the database. + +.DESCRIPTION + Drops the database. + +.PARAMETER Context + The DbContext to use. + +.PARAMETER Project + The project to use. + +.PARAMETER StartupProject + The startup project to use. Defaults to the solution's startup project. + +.LINK + Update-Database + about_EntityFrameworkCore +#> +function Drop-Database( + $Context, + $Project, + $StartupProject) +{ + throw $UpdatePowerShell +} + +function Enable-Migrations +{ + WarnIfEF6 'Enable-Migrations' + Write-Warning 'Enable-Migrations is obsolete. Use Add-Migration to start using Migrations.' +} + +<# +.SYNOPSIS + Gets information about DbContext types. + +.DESCRIPTION + Gets information about DbContext types. + +.PARAMETER Context + The DbContext to use. + +.PARAMETER Project + The project to use. + +.PARAMETER StartupProject + The startup project to use. Defaults to the solution's startup project. + +.LINK + about_EntityFrameworkCore +#> +function Get-DbContext( + $Context, + $Project, + $StartupProject) +{ + throw $UpdatePowerShell +} + +<# +.SYNOPSIS + Removes the last migration. + +.DESCRIPTION + Removes the last migration. + +.PARAMETER Force + Revert the migration if it has been applied to the database. + +.PARAMETER Context + The DbContext to use. + +.PARAMETER Project + The project to use. + +.PARAMETER StartupProject + The startup project to use. Defaults to the solution's startup project. + +.LINK + Add-Migration + about_EntityFrameworkCore +#> +function Remove-Migration( + [switch] $Force, + $Context, + $Project, + $StartupProject) +{ + throw $UpdatePowerShell +} + +<# +.SYNOPSIS + Scaffolds a DbContext and entity types for a database. + +.DESCRIPTION + Scaffolds a DbContext and entity types for a database. + +.PARAMETER Connection + The connection string to the database. + +.PARAMETER Provider + The provider to use. (E.g. Microsoft.EntityFrameworkCore.SqlServer) + +.PARAMETER OutputDir + The directory to put files in. Paths are relative to the project directory. + +.PARAMETER ContextDir + The directory to put DbContext file in. Paths are relative to the project directory. + +.PARAMETER Context + The name of the DbContext to generate. + +.PARAMETER Schemas + The schemas of tables to generate entity types for. + +.PARAMETER Tables + The tables to generate entity types for. + +.PARAMETER DataAnnotations + Use attributes to configure the model (where possible). If omitted, only the fluent API is used. + +.PARAMETER UseDatabaseNames + Use table and column names directly from the database. + +.PARAMETER Force + Overwrite existing files. + +.PARAMETER Project + The project to use. + +.PARAMETER StartupProject + The startup project to use. Defaults to the solution's startup project. + +.LINK + about_EntityFrameworkCore +#> +function Scaffold-DbContext( + $Connection, + $Provider, + $OutputDir, + $ContextDir, + $Context, + $Schemas, + $Tables, + [switch] $DataAnnotations, + [switch] $UseDatabaseNames, + [switch] $Force, + $Project, + $StartupProject) +{ + throw $UpdatePowerShell +} + +<# +.SYNOPSIS + Generates a SQL script from current DbContext. + +.DESCRIPTION + Generates a SQL script from current DbContext. + +.PARAMETER Output + The file to write the result to. + +.PARAMETER Context + The DbContext to use. + +.PARAMETER Project + The project to use. + +.PARAMETER StartupProject + The startup project to use. Defaults to the solution's startup project. + +.LINK + about_EntityFrameworkCore +#> +function Script-DbContext( + $Output, + $Context, + $Project, + $StartupProject) +{ + throw $UpdatePowerShell +} + +<# +.SYNOPSIS + Generates a SQL script from migrations. + +.DESCRIPTION + Generates a SQL script from migrations. + +.PARAMETER From + The starting migration. Defaults to '0' (the initial database). + +.PARAMETER To + The ending migration. Defaults to the last migration. + +.PARAMETER Idempotent + Generate a script that can be used on a database at any migration. + +.PARAMETER Output + The file to write the result to. + +.PARAMETER Context + The DbContext to use. + +.PARAMETER Project + The project to use. + +.PARAMETER StartupProject + The startup project to use. Defaults to the solution's startup project. + +.LINK + Update-Database + about_EntityFrameworkCore +#> +function Script-Migration( + $From, + $To, + [switch] $Idempotent, + $Output, + $Context, + $Project, + $StartupProject) +{ + throw $UpdatePowerShell +} + +<# +.SYNOPSIS + Updates the database to a specified migration. + +.DESCRIPTION + Updates the database to a specified migration. + +.PARAMETER Migration + The target migration. If '0', all migrations will be reverted. Defaults to the last migration. + +.PARAMETER Context + The DbContext to use. + +.PARAMETER Project + The project to use. + +.PARAMETER StartupProject + The startup project to use. Defaults to the solution's startup project. + +.LINK + Script-Migration + about_EntityFrameworkCore +#> +function Update-Database( + $Migration, + $Context, + $Project, + $StartupProject) +{ + WarnIfEF6 'Update-Database' + throw $UpdatePowerShell +} + +function WarnIfEF6($cmdlet) +{ + if (Get-Module 'EntityFramework6') + { + Write-Warning "Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework6\$cmdlet' for Entity Framework 6." + } + elseif (Get-Module 'EntityFramework') + { + Write-Warning "Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework\$cmdlet' for Entity Framework 6." + } +} diff --git a/src/EFCore.Tools/tools/EntityFrameworkCore.PowerShell2.psm1 b/src/EFCore.Tools/tools/EntityFrameworkCore.PowerShell2.psm1 deleted file mode 100644 index 275344ebc68..00000000000 --- a/src/EFCore.Tools/tools/EntityFrameworkCore.PowerShell2.psm1 +++ /dev/null @@ -1,63 +0,0 @@ -$ErrorActionPreference = 'Stop' - -$versionErrorMessage = 'The Entity Framework Core Package Manager Console Tools don''t support PowerShell version ' + - "$($PSVersionTable.PSVersion). Upgrade to PowerShell version 3.0 or higher, restart Visual Studio, and try again." - -function Add-Migration -{ - WarnIfEF6 'Add-Migration' - - throw $versionErrorMessage -} - -function Drop-Database -{ - throw $versionErrorMessage -} - -function Enable-Migrations -{ - WarnIfEF6 'Enable-Migrations' - - throw $versionErrorMessage -} - -function Get-DbContext -{ - throw $versionErrorMessage -} - -function Remove-Migration -{ - throw $versionErrorMessage -} - -function Scaffold-DbContext -{ - throw $versionErrorMessage -} - -function Script-DbContext -{ - throw $versionErrorMessage -} - -function Script-Migration -{ - throw $versionErrorMessage -} - -function Update-Database -{ - WarnIfEF6 'Update-Database' - - throw $versionErrorMessage -} - -function WarnIfEF6($cmdlet) -{ - if (Get-Module 'EntityFramework') - { - Write-Warning "Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework\$cmdlet' for Entity Framework 6." - } -} \ No newline at end of file diff --git a/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 b/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 index f4ebf003564..3cc442fce0a 100644 --- a/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 +++ b/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 @@ -656,9 +656,13 @@ function GetMigrations($context, $projectName, $startupProjectName) return $result | %{ $_.safeName } } -function WarnIfEF6 ($cmdlet) +function WarnIfEF6($cmdlet) { - if (Get-Module 'EntityFramework') + if (Get-Module 'EntityFramework6') + { + Write-Warning "Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework6\$cmdlet' for Entity Framework 6." + } + elseif (Get-Module 'EntityFramework') { Write-Warning "Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework\$cmdlet' for Entity Framework 6." } @@ -796,12 +800,6 @@ function WriteErrorLine($message) function EF($project, $startupProject, $params, [switch] $skipBuild) { - if (IsXproj $startupProject) - { - throw "Startup project '$($startupProject.ProjectName)' is an ASP.NET Core or .NET Core project for Visual " + - 'Studio 2015. This version of the Entity Framework Core Package Manager Console Tools doesn''t support ' + - 'these types of projects.' - } if (IsDocker $startupProject) { throw "Startup project '$($startupProject.ProjectName)' is a Docker project. Select an ASP.NET Core Web " + @@ -836,7 +834,7 @@ function EF($project, $startupProject, $params, [switch] $skipBuild) $startupProjectDir = GetProperty $startupProject.Properties 'FullPath' $outputPath = GetProperty $startupProject.ConfigurationManager.ActiveConfiguration.Properties 'OutputPath' $targetDir = [IO.Path]::GetFullPath([IO.Path]::Combine($startupProjectDir, $outputPath)) - $startupTargetFileName = GetOutputFileName $startupProject + $startupTargetFileName = GetProperty $startupProject.Properties 'OutputFileName' $startupTargetPath = Join-Path $targetDir $startupTargetFileName $targetFrameworkMoniker = GetProperty $startupProject.Properties 'TargetFrameworkMoniker' $frameworkName = New-Object 'System.Runtime.Versioning.FrameworkName' $targetFrameworkMoniker @@ -911,7 +909,7 @@ function EF($project, $startupProject, $params, [switch] $skipBuild) } $projectDir = GetProperty $project.Properties 'FullPath' - $targetFileName = GetOutputFileName $project + $targetFileName = GetProperty $project.Properties 'OutputFileName' $targetPath = Join-Path $targetDir $targetFileName $rootNamespace = GetProperty $project.Properties 'RootNamespace' $language = GetLanguage $project @@ -995,11 +993,6 @@ function EF($project, $startupProject, $params, [switch] $skipBuild) } } -function IsXproj($project) -{ - return $project.Kind -eq '{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}' -} - function IsDocker($project) { return $project.Kind -eq '{E53339B2-1760-4266-BCC7-CA923CBCF16C}' @@ -1031,12 +1024,6 @@ function IsUWP($project) function GetIntermediatePath($project) { - # TODO: Remove when dotnet/roslyn-project-system#665 is fixed - if (IsCpsProject $project) - { - return GetCpsProperty $project 'IntermediateOutputPath' - } - $intermediatePath = GetProperty $project.ConfigurationManager.ActiveConfiguration.Properties 'IntermediatePath' if ($intermediatePath) { @@ -1048,7 +1035,6 @@ function GetIntermediatePath($project) function GetPlatformTarget($project) { - # TODO: Remove when dotnet/roslyn-project-system#669 is fixed if (IsCpsProject $project) { $platformTarget = GetCpsProperty $project 'PlatformTarget' @@ -1066,6 +1052,7 @@ function GetPlatformTarget($project) return $platformTarget } + # NB: For classic F# projects $platformTarget = GetMSBuildProperty $project 'PlatformTarget' if ($platformTarget) { @@ -1075,17 +1062,6 @@ function GetPlatformTarget($project) return 'AnyCPU' } -function GetOutputFileName($project) -{ - # TODO: Remove when dotnet/roslyn-project-system#667 is fixed - if (IsCpsProject $project) - { - return GetCpsProperty $project 'TargetFileName' - } - - return GetProperty $project.Properties 'OutputFileName' -} - function GetLanguage($project) { if (IsCpsProject $project) diff --git a/src/EFCore.Tools/tools/init.ps1 b/src/EFCore.Tools/tools/init.ps1 index 543e9a90393..3788ca5dcf0 100644 --- a/src/EFCore.Tools/tools/init.ps1 +++ b/src/EFCore.Tools/tools/init.ps1 @@ -1,37 +1,35 @@ param($installPath, $toolsPath, $package, $project) -if ($PSVersionTable.PSVersion.Major -lt 3) +# NB: Not set for scripts in PowerShell 2.0 +if (!$PSScriptRoot) { - # This section needs to support PS2 syntax - # Use $toolsPath because PS2 does not support $PSScriptRoot - $env:PSModulePath = $env:PSModulePath + ';$toolsPath' + $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent +} +if ($PSVersionTable.PSVersion -lt '3.0') +{ # Import a "dummy" module that contains matching functions that throw on PS2 - Import-Module (Join-Path $toolsPath 'EntityFrameworkCore.PowerShell2.psd1') -DisableNameChecking + Import-Module (Join-Path $PSScriptRoot 'EntityFrameworkCore.PS2.psd1') -DisableNameChecking - throw "PowerShell version $($PSVersionTable.PSVersion) is not supported. Please upgrade PowerShell to 3.0 or " + - 'greater and restart Visual Studio.' + return } -else + +$importedModule = Get-Module 'EntityFrameworkCore' +$moduleToImport = Test-ModuleManifest (Join-Path $PSScriptRoot 'EntityFrameworkCore.psd1') +$import = $true +if ($importedModule) { - $importedModule = Get-Module 'EntityFrameworkCore' - $moduleToImport = Test-ModuleManifest (Join-Path $PSScriptRoot 'EntityFrameworkCore.psd1') - $import = $true - if ($importedModule) + if ($importedModule.Version -le $moduleToImport.Version) { - if ($importedModule.Version -le $moduleToImport.Version) - { - Remove-Module 'EntityFrameworkCore' - } - else - { - $import = $false - } + Remove-Module 'EntityFrameworkCore' } - - if ($import) + else { - Import-Module $moduleToImport -DisableNameChecking + $import = $false } } +if ($import) +{ + Import-Module $moduleToImport -DisableNameChecking +} diff --git a/src/EFCore.Tools/tools/install.ps1 b/src/EFCore.Tools/tools/install.ps1 deleted file mode 100644 index d260b151f73..00000000000 --- a/src/EFCore.Tools/tools/install.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -param($installPath, $toolsPath, $package, $project) - -Write-Host -Write-Host 'Type ''get-help EntityFrameworkCore'' to see all available Entity Framework Core commands.' -Write-Host