Skip to content

Commit

Permalink
Fix tool when using under .NET 6 for real this time.
Browse files Browse the repository at this point in the history
After trying the current preview tool as I must use the preview EFCore builds with .NET 6 due to reasons I cannot control. I still had the tool be broken even with the roll forward. As such I have discovered the reason for this is because of the fact that for some reason even roll forward did not properly tell it how to run as if the tool were compiled for .NET 6. As such the tool had to be patched to change .NET Core 2.0 to .NET 6 in order to get it to work.

Fixes dotnet#27660 (comment).
  • Loading branch information
AraHaan committed Jun 12, 2022
1 parent 27a83b9 commit 89af3aa
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/EFCore.Tools/EFCore.Tools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<PackageId>Microsoft.EntityFrameworkCore.Tools</PackageId>
<NuspecFile>$(MSBuildThisFileDirectory)$(MSBuildProjectName).nuspec</NuspecFile>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
Expand Down
6 changes: 3 additions & 3 deletions src/EFCore.Tools/EFCore.Tools.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<file src="../../artifacts/bin/ef/$configuration$/net461/ef.pdb" target="tools/net461/any/" />
<file src="../../artifacts/bin/ef/x86/$configuration$/net461/ef.exe" target="tools/net461/win-x86/" />
<file src="../../artifacts/bin/ef/x86/$configuration$/net461/ef.pdb" target="tools/net461/win-x86/" />
<file src="../../artifacts/bin/ef/$configuration$/netcoreapp2.0/ef.dll" target="tools/netcoreapp2.0/any/" />
<file src="../../artifacts/bin/ef/$configuration$/netcoreapp2.0/ef.pdb" target="tools/netcoreapp2.0/any/" />
<file src="../../artifacts/bin/ef/$configuration$/netcoreapp2.0/ef.runtimeconfig.json" target="tools/netcoreapp2.0/any/" />
<file src="../../artifacts/bin/ef/$configuration$/net6.0/ef.dll" target="tools/net6.0/any/" />
<file src="../../artifacts/bin/ef/$configuration$/net6.0/ef.pdb" target="tools/net6.0/any/" />
<file src="../../artifacts/bin/ef/$configuration$/net6.0/ef.runtimeconfig.json" target="tools/net6.0/any/" />
</files>
</package>
2 changes: 1 addition & 1 deletion src/EFCore.Tools/tools/EntityFrameworkCore.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ function EF($project, $startupProject, $params, $applicationArgs, [switch] $skip
$projectAssetsFile = GetCpsProperty $startupProject 'ProjectAssetsFile'
$runtimeConfig = Join-Path $targetDir ($startupTargetName + '.runtimeconfig.json')
$runtimeFrameworkVersion = GetCpsProperty $startupProject 'RuntimeFrameworkVersion'
$efPath = Join-Path $PSScriptRoot 'netcoreapp2.0\any\ef.dll'
$efPath = Join-Path $PSScriptRoot 'net6.0\any\ef.dll'

$dotnetParams = 'exec', '--depsfile', $depsFile

Expand Down
2 changes: 1 addition & 1 deletion src/dotnet-ef/RootCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected override int Execute(string[] _)
args.Add(startupProject.RuntimeFrameworkVersion);
}

args.Add(Path.Combine(toolsPath, "netcoreapp2.0", "any", "ef.dll"));
args.Add(Path.Combine(toolsPath, "net6.0", "any", "ef.dll"));
}
else if (targetFramework.Identifier == ".NETStandard")
{
Expand Down
6 changes: 3 additions & 3 deletions src/dotnet-ef/dotnet-ef.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ dotnet ef database update

<NuspecProperty Include="SettingsFile=$(_ToolsSettingsFilePath)" />
<NuspecProperty Include="Output=$(PublishDir)**\*" />
<NuspecProperty Include="OutputBinary=..\..\artifacts\bin\ef\$(Configuration)\netcoreapp2.0\ef.dll" />
<NuspecProperty Include="OutputRuntimeConfig=..\..\artifacts\bin\ef\$(Configuration)\netcoreapp2.0\ef.runtimeconfig.json" />
<NuspecProperty Include="OutputSymbol=..\..\artifacts\bin\ef\$(Configuration)\netcoreapp2.0\ef.pdb" />
<NuspecProperty Include="OutputBinary=..\..\artifacts\bin\ef\$(Configuration)\net6.0\ef.dll" />
<NuspecProperty Include="OutputRuntimeConfig=..\..\artifacts\bin\ef\$(Configuration)\net6.0\ef.runtimeconfig.json" />
<NuspecProperty Include="OutputSymbol=..\..\artifacts\bin\ef\$(Configuration)\net6.0\ef.pdb" />
<NuspecProperty Include="OutputExe=..\..\artifacts\bin\ef\$(Configuration)\net461\ef.exe" />
<NuspecProperty Include="OutputExeSymbol=..\..\artifacts\bin\ef\$(Configuration)\net461\ef.pdb" />
<NuspecProperty Include="OutputX86Exe=..\..\artifacts\bin\ef\x86\$(Configuration)\net461\ef.exe" />
Expand Down
6 changes: 3 additions & 3 deletions src/dotnet-ef/dotnet-ef.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
$CommonFileElements$
<file src="$SettingsFile$" target="tools\$targetFramework$\any" />
<file src="$Output$" target="tools\$targetFramework$\any" />
<file src="$OutputBinary$" target="tools\$targetFramework$\any\tools\netcoreapp2.0\any" />
<file src="$OutputRuntimeConfig$" target="tools\$targetFramework$\any\tools\netcoreapp2.0\any" />
<file src="$OutputSymbol$" target="tools\$targetFramework$\any\tools\netcoreapp2.0\any" />
<file src="$OutputBinary$" target="tools\$targetFramework$\any\tools\net6.0\any" />
<file src="$OutputRuntimeConfig$" target="tools\$targetFramework$\any\tools\net6.0\any" />
<file src="$OutputSymbol$" target="tools\$targetFramework$\any\tools\net6.0\any" />
<file src="$OutputExe$" target="tools\$targetFramework$\any\tools\net461\any" />
<file src="$OutputExeSymbol$" target="tools\$targetFramework$\any\tools\net461\any" />
<file src="$OutputX86Exe$" target="tools\$targetFramework$\any\tools\net461\win-x86" />
Expand Down
2 changes: 1 addition & 1 deletion src/ef/AppDomainOperationExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public override void Dispose()
}
}
}
#elif NETCOREAPP2_0
#elif NET6_0
#else
#error target frameworks need to be updated.
#endif
6 changes: 3 additions & 3 deletions src/ef/Commands/MigrationsBundleCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected override int Execute(string[] args)
string context;
using (var executor = CreateExecutor(args))
{
context = (string)executor.GetContextInfo(Context!.Value())["Type"];
context = (string)executor.GetContextInfo(Context!.Value())["Type"]!;
}

Reporter.WriteInformation(Resources.BuildBundleStarted);
Expand Down Expand Up @@ -90,7 +90,7 @@ protected override int Execute(string[] args)
var searchPath = WorkingDir!.Value();
do
{
foreach (var file in Directory.EnumerateFiles(searchPath))
foreach (var file in Directory.EnumerateFiles(searchPath!))
{
var fileName = Path.GetFileName(file);
if (fileName.Equals("NuGet.Config", StringComparison.OrdinalIgnoreCase))
Expand Down Expand Up @@ -132,7 +132,7 @@ protected override int Execute(string[] args)

var runtime = _runtime!.HasValue()
? _runtime!.Value()!
: (string)AppContext.GetData("RUNTIME_IDENTIFIER");
: (string)AppContext.GetData("RUNTIME_IDENTIFIER")!;
publishArgs.Add("--runtime");
publishArgs.Add(runtime);

Expand Down
2 changes: 1 addition & 1 deletion src/ef/Commands/ProjectCommandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected IOperationExecutor CreateExecutor(string[] remainingArguments)
}
}
}
#elif !NETCOREAPP2_0
#elif !NET6_0
#error target frameworks need to be updated.
#endif
return new ReflectionOperationExecutor(
Expand Down
2 changes: 1 addition & 1 deletion src/ef/ef.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
<TargetFrameworks>net6.0;net461</TargetFrameworks>
<Description>Entity Framework Core Command-line Tools</Description>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
Expand Down

0 comments on commit 89af3aa

Please sign in to comment.