Skip to content

Commit

Permalink
adding support for net8 assembly list in emg (#10154)
Browse files Browse the repository at this point in the history
* adding support for net8 assembly list in emg

* re-adding emg tests

* breaking emg tests back out

* adding earlier frameworks for mapping

* tweaks
  • Loading branch information
brettsam authored May 15, 2024
1 parent bc19a41 commit 1e71f98
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ jobs:
**\WebJobs.Script.Scaling.Tests.csproj
**\WebJobs.Script.Tests.csproj
- task: DotNetCoreCLI@2
displayName: 'EGM Unit Tests'
displayName: 'ExtensionsMetadataGenerator Unit Tests'
inputs:
command: 'test'
testRunTitle: 'EGM Unit Tests'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

Expand All @@ -18,12 +15,35 @@ public class RemoveRuntimeDependencies : AppDomainIsolatedTask
public class RemoveRuntimeDependencies : Task
#endif
{
private const string Net6File = ".runtimeAssemblies-net6.txt";
private const string Net8File = ".runtimeAssemblies-net8.txt";

// everything up until net6 maps to the net6 assembly list
// net8 only maps to the net8 assembly list
// anything else (such as future versions) are unsupported
private static readonly IDictionary<string, string> _runtimeToAssemblyFileMap = new Dictionary<string, string>()
{
{ "netstandard2.0", Net6File },
{ "netstandard2.1", Net6File },
{ "netcoreapp2.0", Net6File },
{ "netcoreapp2.1", Net6File },
{ "netcoreapp2.2", Net6File },
{ "netcoreapp3.0", Net6File },
{ "netcoreapp3.1", Net6File },
{ "net5.0", Net6File },
{ "net6.0", Net6File },
{ "net8.0", Net8File }
};

[Required]
public string OutputPath { get; set; }

[Required]
public ITaskItem[] IgnoreFiles { get; set; }

[Required]
public string TargetFramework { get; set; }

public override bool Execute()
{
HashSet<string> ignoreFilesSet = new HashSet<string>();
Expand All @@ -32,8 +52,14 @@ public override bool Execute()
ignoreFilesSet.Add(item.ItemSpec);
}

if (!_runtimeToAssemblyFileMap.TryGetValue(TargetFramework, out var assemblyListFileName))
{
Log.LogError($"The TargetFramework '{TargetFramework}' is not supported in this project. Supported frameworks are: {string.Join(", ", _runtimeToAssemblyFileMap.Keys)}.");
return false;
}

Assembly assembly = typeof(RemoveRuntimeDependencies).Assembly;
using (Stream resource = assembly.GetManifestResourceStream(assembly.GetName().Name + ".runtimeassemblies-net6.txt"))
using (Stream resource = assembly.GetManifestResourceStream(assembly.GetName().Name + assemblyListFileName))
using (var reader = new StreamReader(resource))
{
string assemblyName = reader.ReadLine();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk" InitialTargets="UpdateRuntimeAssemblies">
<Import Project="..\..\build\metadatagenerator.props" />
<PropertyGroup>
<Version>4.0.2</Version>
<Version>4.0.3</Version>
<OutputType>Library</OutputType>
<TargetFrameworks>netstandard2.0;net46</TargetFrameworks>
<AssemblyName>Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator</AssemblyName>
Expand Down Expand Up @@ -37,11 +37,11 @@

<Target Name="PackReferenceAssemblies">
<ItemGroup>
<Content Include="$(OutputPath)\netstandard2.0\generator\*">
<Content Include="$(ArtifactsPath)\bin\ExtensionsMetadataGenerator\release_netstandard2.0\generator\*">
<Pack>true</Pack>
<PackagePath>tools\netstandard2.0\generator</PackagePath>
</Content>
<Content Include="$(OutputPath)\netstandard2.0\*.dll" Exclude="**\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.dll">
<Content Include="$(ArtifactsPath)\bin\ExtensionsMetadataGenerator\release_netstandard2.0\*.dll" Exclude="**\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.dll">
<Pack>true</Pack>
<PackagePath>tools\netstandard2.0\</PackagePath>
</Content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
AssemblyFile="$(_FunctionsExtensionsTaskAssemblyFullPath)"/>

<Target Name="_FunctionsBuildCleanOutput" AfterTargets="_GenerateFunctionsExtensionsMetadataPostBuild" Condition="$(_FunctionsSkipCleanOutput) != 'true'" >
<RemoveRuntimeDependencies OutputPath="$(TargetDir)bin" IgnoreFiles="@(FunctionsPreservedDependencies)"/>
<RemoveRuntimeDependencies OutputPath="$(TargetDir)bin" IgnoreFiles="@(FunctionsPreservedDependencies)" TargetFramework="$(TargetFramework)" />
</Target>

<Target Name="_FunctionsPublishCleanOutput" AfterTargets="_GenerateFunctionsExtensionsMetadataPostPublish" Condition="$(_FunctionsSkipCleanOutput) != 'true'" >
<RemoveRuntimeDependencies OutputPath="$(PublishDir)bin" IgnoreFiles="@(FunctionsPreservedDependencies)"/>
<RemoveRuntimeDependencies OutputPath="$(PublishDir)bin" IgnoreFiles="@(FunctionsPreservedDependencies)" TargetFramework="$(TargetFramework)" />
</Target>

<UsingTask TaskName="GenerateFunctionsExtensionsMetadata"
Expand Down

0 comments on commit 1e71f98

Please sign in to comment.