Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ItemGroup>
<_IlcManagedInputAssemblies Include="@(ResolvedFileToPublish)" Condition="'%(ResolvedFileToPublish.PostprocessAssembly)' == 'true'" />
<IlcReference Include="@(_IlcManagedInputAssemblies)" />
<IlcSatelliteAssembly Include="@(_SatelliteAssembliesToPublish)" />
<IlcSatelliteAssembly Include="@(ResolvedFileToPublish)" Condition="'%(ResolvedFileToPublish.AssetType)' == 'resources'" />
<IlcSatelliteAssembly Include="@(IntermediateSatelliteAssembliesWithTargetPath)" />
</ItemGroup>
</Target>
Expand All @@ -35,7 +35,7 @@
<ResolvedFileToPublish Remove="@(_IlcManagedInputAssemblies)" />
<!-- dotnet CLI produces managed debug symbols, which we will replace with native symbols instead -->
<ResolvedFileToPublish Remove="@(_DebugSymbolsIntermediatePath)" />
<ResolvedFileToPublish Remove="@(IntermediateSatelliteAssembliesWithTargetPath)" />
<ResolvedFileToPublish Remove="@(IlcSatelliteAssembly)" />
<!-- replace apphost with binary we generated during native compilation -->
<ResolvedFileToPublish Include="$(NativeBinary)">
<RelativePath>$(NativeBinaryPrefix)$(TargetName)$(NativeBinaryExt)</RelativePath>
Expand Down Expand Up @@ -122,7 +122,6 @@
SdkAssemblies="@(PrivateSdkAssemblies)"
FrameworkAssemblies="@(FrameworkAssemblies)">

<Output TaskParameter="SatelliteAssemblies" ItemName="_SatelliteAssembliesToPublish" />
<Output TaskParameter="RuntimePackFilesToSkipPublish" ItemName="_RuntimePackFilesToSkipPublish" />
</ComputeManagedAssembliesToCompileToNative>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection.Metadata;
using System.Reflection.PortableExecutable;



Expand Down Expand Up @@ -74,13 +72,6 @@ public string DotNetHostPolicyLibraryName
set;
}

[Output]
public ITaskItem[] SatelliteAssemblies
{
get;
set;
}

/// <summary>
/// CoreCLR runtime pack files (apphost, native assets, managed assemblies replaced by NativeAOT equivalents)
/// that should be removed from the publish output and replaced with NativeAOT runtime pack assemblies.
Expand All @@ -95,7 +86,6 @@ public ITaskItem[] RuntimePackFilesToSkipPublish
public override bool Execute()
{
var runtimePackFilesToSkipPublish = new List<ITaskItem>();
var satelliteAssemblies = new List<ITaskItem>();
var nativeAotFrameworkAssembliesToUse = new Dictionary<string, ITaskItem>();

foreach (ITaskItem taskItem in SdkAssemblies)
Expand Down Expand Up @@ -159,44 +149,9 @@ public override bool Execute()
runtimePackFilesToSkipPublish.Add(taskItem);
continue;
}

// Only classify files that the SDK has identified as managed runtime assemblies.
// Other files (e.g. Content items that happen to be managed assemblies) should be
// left alone and allowed to be published as-is.
if (!taskItem.GetMetadata("PostprocessAssembly").Equals("true", StringComparison.OrdinalIgnoreCase))
{
continue;
}

// Check if this is a satellite assembly by reading its culture metadata.
// Non-managed files are silently skipped as a safety measure.
try
{
using (FileStream moduleStream = File.OpenRead(itemSpec))
using (var module = new PEReader(moduleStream))
{
if (module.HasMetadata)
{
MetadataReader moduleMetadataReader = module.GetMetadataReader();
if (moduleMetadataReader.IsAssembly)
{
string culture = moduleMetadataReader.GetString(moduleMetadataReader.GetAssemblyDefinition().Culture);

if (culture != "" && !culture.Equals("neutral", StringComparison.OrdinalIgnoreCase))
{
satelliteAssemblies.Add(taskItem);
}
}
}
}
}
catch (BadImageFormatException)
{
}
}

RuntimePackFilesToSkipPublish = runtimePackFilesToSkipPublish.ToArray();
SatelliteAssemblies = satelliteAssemblies.ToArray();

return true;

Expand Down
Loading