-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
NativeAOT targets define the CopyNativeBinary target which copies the linked binary to the publish directory after the Publish target. It also adds the native binary to the IntermediateAssembly itemgroup, which gets copied to the publish directory in _CopyResolvedFilesToPublishPreserveNewest.
runtime/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
Lines 13 to 35 in 78abe10
| <!-- | |
| This target hooks into the dotnet CLI publish pipeline. That pipeline has | |
| a target called ComputeFilesToPublish which produces the ItemGroup | |
| ResolvedFileToPublish based on the inputs of @(IntermediateAssembly) | |
| and @(ResolvedAssembliesToPublish). We modify those two item groups | |
| to control what gets published after NativeAOT optimizes the application. | |
| --> | |
| <Target Name="ComputeLinkedFilesToPublish" | |
| BeforeTargets="ComputeResolvedFilesToPublishList" | |
| DependsOnTargets="_ComputeAssembliesToCompileToNative;LinkNative"> | |
| <ItemGroup> | |
| <_ResolvedCopyLocalPublishAssets Remove="@(_AssembliesToSkipPublish)" /> | |
| <_ResolvedCopyLocalPublishAssets Include="@(_LinkedResolvedAssemblies)" /> | |
| <_DebugSymbolsIntermediatePath Remove="@(_DebugSymbolsIntermediatePath)" /> | |
| </ItemGroup> | |
| <ItemGroup> | |
| <_NativeIntermediateAssembly Include="@(IntermediateAssembly->'$(NativeOutputPath)%(Filename)$(NativeBinaryExt)')" /> | |
| <IntermediateAssembly Remove="@(IntermediateAssembly)" /> | |
| <IntermediateAssembly Include="@(_NativeIntermediateAssembly)" /> | |
| </ItemGroup> | |
| </Target> |
If the goal of overwriting IntermediateAssembly was to prevent the managed .dll from being copied over, we could instead set CopyBuildOutputToPublishDirectory=false and let CopyNativeBinary copy the file to the publish directory. Or we could remove CopyNativeBinary (or make it an empty target - some projects do reference it, but almost exclusively to run after it, not before). But we should avoid a double-write.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status