Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
<PackageVersion Include="NetTopologySuite.IO.SqlServerBytes" Version="2.1.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="mod_spatialite" Version="4.3.0.1" />
<PackageVersion Include="SQLitePCLRaw.core" Version="$(SQLitePCLRawVersion)" />
<PackageVersion Include="SQLitePCLRaw.bundle_sqlite3" Version="$(SQLitePCLRawVersion)" />
<PackageVersion Include="SQLitePCLRaw.bundle_e_sqlite3" Version="$(SQLitePCLRawVersion)" />
<PackageVersion Include="SQLitePCLRaw.core" Version="2.1.11" />
<PackageVersion Include="SQLitePCLRaw.bundle_sqlite3" Version="2.1.11" />
<PackageVersion Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.11" />
</ItemGroup>
</Project>
23 changes: 3 additions & 20 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<Import Project="Version.Details.props" Condition="Exists('Version.Details.props')" />
<PropertyGroup Label="Version settings">
<VersionPrefix>10.0.1</VersionPrefix>
<PreReleaseVersionLabel>servicing</PreReleaseVersionLabel>
<PreReleaseVersionLabel>servicing</PreReleaseVersionLabel>
<PreReleaseVersionIteration></PreReleaseVersionIteration>
<IncludeSourceRevisionInInformationalVersion>False</IncludeSourceRevisionInInformationalVersion>
<IncludeSourceRevisionInInformationalVersion>False</IncludeSourceRevisionInInformationalVersion>
<IsServicingBuild Condition="'$(PreReleaseVersionLabel)' == 'servicing'">true</IsServicingBuild>
<!--
When StabilizePackageVersion is set to 'true', this branch will produce stable outputs for 'Shipping' packages
Expand All @@ -17,29 +17,12 @@
<UsingToolXliff>False</UsingToolXliff>
</PropertyGroup>
<PropertyGroup Label="MSBuild and Roslyn" Condition="'$(IsServicingBuild)' == 'true'">
<!-- For MSBuild and Roslyn packages use the previous stable version until the current stable build is released. -->
<MicrosoftBuildFrameworkVersion>17.14.28</MicrosoftBuildFrameworkVersion>
<MicrosoftBuildUtilitiesCoreVersion>17.14.28</MicrosoftBuildUtilitiesCoreVersion>
<MicrosoftBuildTasksCoreVersion>17.14.28</MicrosoftBuildTasksCoreVersion>
<MicrosoftCodeAnalysisCSharpVersion>4.14.0</MicrosoftCodeAnalysisCSharpVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesVersion>4.14.0</MicrosoftCodeAnalysisCSharpWorkspacesVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildVersion>4.14.0</MicrosoftCodeAnalysisWorkspacesMSBuildVersion>
</PropertyGroup>
<!-- Revert once roslyn publishes 5.0.0 packages
<PropertyGroup Label="MSBuild and Roslyn" Condition="'$(IsServicingBuild)' == 'true'">
<!-- Use the current stable builds for MSBuild and Roslyn packages, next version (non-servicing) will use the preview builds -->
<MicrosoftBuildFrameworkVersion>17.15.0</MicrosoftBuildFrameworkVersion>
<MicrosoftBuildUtilitiesCoreVersion>17.15.0</MicrosoftBuildUtilitiesCoreVersion>
<MicrosoftBuildTasksCoreVersion>17.15.0</MicrosoftBuildTasksCoreVersion>
<MicrosoftCodeAnalysisCSharpVersion>5.0.0</MicrosoftCodeAnalysisCSharpVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesVersion>5.0.0</MicrosoftCodeAnalysisCSharpWorkspacesVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildVersion>5.0.0</MicrosoftCodeAnalysisWorkspacesMSBuildVersion>
</PropertyGroup> -->
<PropertyGroup Label="Other dependencies">
<MicrosoftCodeAnalysisAnalyzerTestingVersion>1.1.3-beta1.24423.1</MicrosoftCodeAnalysisAnalyzerTestingVersion>
<MicrosoftCodeAnalysisCSharpTestingVersion>1.1.3-beta1.24352.1</MicrosoftCodeAnalysisCSharpTestingVersion>
<AzureIdentityVersion>1.14.2</AzureIdentityVersion>
<AzureResourceManagerCosmosDBVersion>1.3.2</AzureResourceManagerCosmosDBVersion>
<OpenTelemetryExporterInMemoryVersion>1.12.0</OpenTelemetryExporterInMemoryVersion>
<SQLitePCLRawVersion>2.1.11</SQLitePCLRawVersion>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/EFCore.Design/EFCore.Design.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<ItemGroup>
<PackageReference Include="Humanizer.Core" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" PrivateAssets="analyzers;build" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" />
<PackageReference Include="Microsoft.Extensions.HostFactoryResolver.Sources" PrivateAssets="All" />
<PackageReference Include="Mono.TextTemplating" />
Expand Down
5 changes: 5 additions & 0 deletions src/EFCore.Tasks/Tasks/Internal/OperationTaskBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public abstract class OperationTaskBase : ToolTask
/// </summary>
public bool Nullable { get; set; }

/// <summary>
/// Runtime copy local items for dependency resolution.
/// </summary>
public ITaskItem[]? RuntimeCopyLocalItems { get; set; }

/// <summary>
/// The additional arguments to pass to the dotnet-ef command.
/// </summary>
Expand Down
46 changes: 46 additions & 0 deletions src/EFCore.Tasks/Tasks/OptimizeDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public override bool Execute()
if (PrecompileQueries)
{
AdditionalArguments.Add("--precompile-queries");

CopyBuildHost();
}

AdditionalArguments.Add("--nativeaot");
Expand All @@ -106,4 +108,48 @@ public override bool Execute()

return !Log.HasLoggedErrors;
}

private void CopyBuildHost()
{
var msbuildWorkspacesItem = RuntimeCopyLocalItems?.FirstOrDefault(item =>
string.Equals(item.GetMetadata("Filename"), "Microsoft.CodeAnalysis.Workspaces.MSBuild", StringComparison.OrdinalIgnoreCase));
if (msbuildWorkspacesItem == null
|| !string.Equals(msbuildWorkspacesItem.GetMetadata("CopyLocal"), "true", StringComparison.OrdinalIgnoreCase)
|| msbuildWorkspacesItem.GetMetadata("FullPath") is not { } fullPath
|| string.IsNullOrEmpty(fullPath)
|| Path.GetDirectoryName(fullPath) is not { } itemDirectory
|| string.IsNullOrEmpty(itemDirectory))
{
return;
}

var contentFilesPath = Path.GetFullPath(Path.Combine(itemDirectory, "..", "..", "contentFiles", "any", "any"));
var targetDir = Path.GetDirectoryName(Path.GetFullPath(Assembly.ItemSpec))!;

CopyDirectoryRecursive(contentFilesPath, targetDir);
}

private static void CopyDirectoryRecursive(string sourceDir, string targetDir)
{
var directory = new DirectoryInfo(sourceDir);
if (!directory.Exists)
{
return;
}

Directory.CreateDirectory(targetDir);
foreach (var file in directory.GetFiles())
{
var filePath = Path.Combine(targetDir, file.Name);
if (!File.Exists(filePath))
{
file.CopyTo(filePath, overwrite: false);
}
}

foreach (var subDir in directory.GetDirectories())
{
CopyDirectoryRecursive(subDir.FullName, Path.Combine(targetDir, subDir.Name));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ For Publish:
TargetNamespace="$(EFTargetNamespace)"
Language="$(Language)"
Nullable="$(EFNullable)"
RuntimeCopyLocalItems="@(RuntimeCopyLocalItems)"
OutputDir="$(EFOutputDir)"
Project="$(MSBuildProjectFullPath)"
ProjectDir="$(MSBuildProjectDirectory)"
Expand Down
18 changes: 18 additions & 0 deletions src/EFCore.Tools/tools/EntityFrameworkCore.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,24 @@ function EF($project, $startupProject, $params, $applicationArgs, [switch] $skip
$params += '--design-assembly', $designReference.FullPath
}

$msbuildWorkspacesItem = $references.Items.RuntimeCopyLocalItems | ? {
$_.Filename -eq 'Microsoft.CodeAnalysis.Workspaces.MSBuild'
} | Select-Object -First 1

if ($msbuildWorkspacesItem -ne $null -and $msbuildWorkspacesItem.CopyLocal -eq 'true')
{
$itemDirectory = [IO.Path]::GetDirectoryName($msbuildWorkspacesItem.FullPath)
if ($itemDirectory)
{
$contentFilesPath = [IO.Path]::GetFullPath([IO.Path]::Combine($itemDirectory, '..', '..', 'contentFiles', 'any', 'any'))

if ([IO.Directory]::Exists($contentFilesPath))
{
Copy-Item "$contentFilesPath\*" $targetDir -Recurse -ErrorAction SilentlyContinue
}
}
}

$arguments = ToArguments $params
if ($applicationArgs)
{
Expand Down
51 changes: 50 additions & 1 deletion src/dotnet-ef/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,16 @@ public static Project FromFile(

var metadata = JsonSerializer.Deserialize<ProjectMetadata>(output.ToString())!;

var designAssembly = metadata.Items["RuntimeCopyLocalItems"]
var runtimeCopyLocalItems = metadata.Items["RuntimeCopyLocalItems"];

var designAssembly = runtimeCopyLocalItems
.Select(i => i["FullPath"])
.FirstOrDefault(i => i.Contains("Microsoft.EntityFrameworkCore.Design", StringComparison.InvariantCulture));
var properties = metadata.Properties;

var outputPath = Path.GetFullPath(Path.Combine(properties[nameof(ProjectDir)]!, properties[nameof(OutputPath)]!));
CopyBuildHost(runtimeCopyLocalItems, outputPath);

var platformTarget = properties[nameof(PlatformTarget)];
if (platformTarget.Length == 0)
{
Expand Down Expand Up @@ -126,6 +131,50 @@ private record class ProjectMetadata
public Dictionary<string, Dictionary<string, string>[]> Items { get; set; } = null!;
}

private static void CopyBuildHost(
Dictionary<string, string>[] runtimeCopyLocalItems,
string targetDir)
{
var msbuildWorkspacesItem = runtimeCopyLocalItems.FirstOrDefault(item =>
string.Equals(item["Filename"], "Microsoft.CodeAnalysis.Workspaces.MSBuild", StringComparison.OrdinalIgnoreCase));

if (msbuildWorkspacesItem == null
|| !msbuildWorkspacesItem.TryGetValue("CopyLocal", out var copyLocal)
|| !string.Equals(copyLocal, "true", StringComparison.OrdinalIgnoreCase)
|| !msbuildWorkspacesItem.TryGetValue("FullPath", out var fullPath)
|| string.IsNullOrEmpty(fullPath))
{
return;
}

var contentFilesPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(fullPath)!, "..", "..", "contentFiles", "any", "any"));
CopyDirectoryRecursive(contentFilesPath, targetDir);
}

private static void CopyDirectoryRecursive(string sourceDir, string targetDir)
{
var directory = new DirectoryInfo(sourceDir);
if (!directory.Exists)
{
return;
}

Directory.CreateDirectory(targetDir);
foreach (var file in directory.GetFiles())
{
var filePath = Path.Combine(targetDir, file.Name);
if (!File.Exists(filePath))
{
file.CopyTo(filePath, overwrite: false);
}
}

foreach (var subDir in directory.GetDirectories())
{
CopyDirectoryRecursive(subDir.FullName, Path.Combine(targetDir, subDir.Name));
}
}

public void Build(IEnumerable<string>? additionalArgs)
{
var args = new List<string> { "build" };
Expand Down
49 changes: 18 additions & 31 deletions src/ef/ReflectionOperationExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.EntityFrameworkCore.Design.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Tools.Properties;

#if NET
using System.Runtime.Loader;
#endif
Expand Down Expand Up @@ -58,18 +59,13 @@ public ReflectionOperationExecutor(
AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly;

#if NET
_commandsAssembly = AssemblyLoadContext.LoadFromAssemblyName(new AssemblyName(DesignAssemblyName));
_commandsAssembly = DesignAssemblyPath != null
? AssemblyLoadContext.LoadFromAssemblyPath(DesignAssemblyPath)
: AssemblyLoadContext.LoadFromAssemblyName(new AssemblyName(DesignAssemblyName));
#else
if (DesignAssemblyPath != null)
{
var assemblyPath = Path.GetDirectoryName(DesignAssemblyPath);
assemblyPath = Path.Combine(assemblyPath, DesignAssemblyName + ".dll");
_commandsAssembly = Assembly.LoadFrom(assemblyPath);
}
else
{
_commandsAssembly = Assembly.Load(DesignAssemblyName);
}
_commandsAssembly = DesignAssemblyPath != null
? Assembly.LoadFrom(DesignAssemblyPath)
: Assembly.Load(DesignAssemblyName);
#endif
var reportHandlerType = _commandsAssembly.GetType(ReportHandlerTypeName, throwOnError: true, ignoreCase: false)!;

Expand Down Expand Up @@ -109,16 +105,12 @@ protected AssemblyLoadContext AssemblyLoadContext
return _assemblyLoadContext;
}

if (DesignAssemblyPath != null)
AssemblyLoadContext.Default.Resolving += (context, name) =>
{
AssemblyLoadContext.Default.Resolving += (context, name) =>
{
var assemblyPath = Path.GetDirectoryName(DesignAssemblyPath)!;
assemblyPath = Path.Combine(assemblyPath, name.Name + ".dll");
return File.Exists(assemblyPath) ? context.LoadFromAssemblyPath(assemblyPath) : null;
};
_assemblyLoadContext = AssemblyLoadContext.Default;
}
var assemblyPath = Path.Combine(AppBasePath, name.Name + ".dll");
return File.Exists(assemblyPath) ? context.LoadFromAssemblyPath(assemblyPath) : null;
};
_assemblyLoadContext = AssemblyLoadContext.Default;

return AssemblyLoadContext.Default;
}
Expand All @@ -136,18 +128,13 @@ public override string? EFCoreVersion

Assembly? assembly = null;
#if NET
assembly = AssemblyLoadContext.LoadFromAssemblyName(new AssemblyName(DesignAssemblyName));
assembly = DesignAssemblyPath != null
? AssemblyLoadContext.LoadFromAssemblyPath(DesignAssemblyPath)
: AssemblyLoadContext.LoadFromAssemblyName(new AssemblyName(DesignAssemblyName));
#else
if (DesignAssemblyPath != null)
{
var assemblyPath = Path.GetDirectoryName(DesignAssemblyPath);
assemblyPath = Path.Combine(assemblyPath, DesignAssemblyName + ".dll");
assembly = Assembly.LoadFrom(assemblyPath);
}
else
{
assembly = Assembly.Load(DesignAssemblyName);
}
assembly = DesignAssemblyPath != null
? Assembly.LoadFrom(DesignAssemblyPath)
: Assembly.Load(DesignAssemblyName);
#endif
_efcoreVersion = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
?.InformationalVersion;
Expand Down
10 changes: 0 additions & 10 deletions src/ef/ef.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Configuration" />
</ItemGroup>

<PropertyGroup>
<!-- Permit targeting `netcoreapp2.0`, see https://github.com/dotnet/efcore/issues/34654 -->
<NoWarn>$(NoWarn);NU1903</NoWarn>
</PropertyGroup>

<ItemGroup>
<!-- Permit targeting `netcoreapp2.0`, see https://github.com/dotnet/efcore/issues/34654 -->
<NuGetAuditSuppress Include="https://github.com/advisories/GHSA-7mfr-774f-w5r9" />
</ItemGroup>

<ItemGroup>
<None Update="Generators\BundleProgramGenerator.tt">
Expand Down
17 changes: 8 additions & 9 deletions test/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
<!-- Dependencies used only in tests -->
<ItemGroup>
<!-- See https://github.com/dotnet/roslyn-sdk/issues/1175 -->
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzer.Testing" Version="$(MicrosoftCodeAnalysisAnalyzerTestingVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" Version="$(MicrosoftCodeAnalysisCSharpTestingVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="$(MicrosoftCodeAnalysisCSharpTestingVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzer.Testing" Version="1.1.3-beta1.24423.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" Version="1.1.3-beta1.24352.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="1.1.3-beta1.24352.1" />

<PackageVersion Include="Azure.Identity" Version="$(AzureIdentityVersion)" />
<PackageVersion Include="Azure.ResourceManager.CosmosDB" Version="$(AzureResourceManagerCosmosDBVersion)" />
<PackageVersion Include="Azure.ResourceManager.CosmosDB" Version="1.3.2" />
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.5" />
<PackageVersion Include="Microsoft.AspNetCore.OData" Version="9.3.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="$(MicrosoftExtensionsConfigurationVersion)" />
Expand All @@ -18,10 +17,10 @@
<PackageVersion Include="IdentityServer4.EntityFramework" Version="4.1.2" />
<PackageVersion Include="Grpc.AspNetCore" Version="2.71.0" />
<PackageVersion Include="NetTopologySuite.IO.GeoJSON" Version="4.0.0" />
<PackageVersion Include="OpenTelemetry.Exporter.InMemory" Version="$(OpenTelemetryExporterInMemoryVersion)" />
<PackageVersion Include="SQLitePCLRaw.bundle_e_sqlcipher" Version="$(SQLitePCLRawVersion)" />
<PackageVersion Include="SQLitePCLRaw.bundle_e_sqlite3mc" Version="$(SQLitePCLRawVersion)" />
<PackageVersion Include="SQLitePCLRaw.bundle_winsqlite3" Version="$(SQLitePCLRawVersion)" />
<PackageVersion Include="OpenTelemetry.Exporter.InMemory" Version="1.12.0" />
<PackageVersion Include="SQLitePCLRaw.bundle_e_sqlcipher" Version="2.1.11" />
<PackageVersion Include="SQLitePCLRaw.bundle_e_sqlite3mc" Version="2.1.11" />
<PackageVersion Include="SQLitePCLRaw.bundle_winsqlite3" Version="2.1.11" />

<!-- Pinned versions for Component Governance/NuGetAudit - Remove when root dependencies are updated -->
<!--Workaround for IdentityServer4.EntityFramework v4.1.2-->
Expand Down
Loading