diff options
Diffstat (limited to 'src/BuildIntegration')
3 files changed, 83 insertions, 14 deletions
diff --git a/src/BuildIntegration/BuildFrameworkNativeObjects.proj b/src/BuildIntegration/BuildFrameworkNativeObjects.proj index 3a1f2db03..806b087f4 100644 --- a/src/BuildIntegration/BuildFrameworkNativeObjects.proj +++ b/src/BuildIntegration/BuildFrameworkNativeObjects.proj @@ -1,7 +1,7 @@ <Project DefaultTargets="CreateLib" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> - <IlcCompileDependsOn>BuildOneFrameworkLibrary</IlcCompileDependsOn> + <IlcCompileDependsOn>ComputeIlcCompileInputs;BuildOneFrameworkLibrary</IlcCompileDependsOn> <CreateLibDependsOn>BuildAllFrameworkLibrariesAsSingleLib</CreateLibDependsOn> <IlcMultiModule>true</IlcMultiModule> <NativeIntermediateOutputPath Condition="'$(FrameworkObjPath)' != ''">$(FrameworkObjPath)\</NativeIntermediateOutputPath> @@ -11,12 +11,12 @@ <Import Project="Microsoft.NETCore.Native.targets" /> <Target Name="BuildAllFrameworkLibraries" - Inputs="@(IlcReference)" - Outputs="@(IlcReference->'$(NativeIntermediateOutputPath)\%(Filename)$(NativeObjectExt)')"> + Inputs="@(DefaultFrameworkAssemblies)" + Outputs="@(DefaultFrameworkAssemblies->'$(NativeIntermediateOutputPath)\%(Filename)$(NativeObjectExt)')"> <ItemGroup> <ProjectToBuild Include="$(MSBuildProjectFullPath)"> <AdditionalProperties> - LibraryToCompile=%(IlcReference.Identity) + LibraryToCompile=%(DefaultFrameworkAssemblies.Identity) </AdditionalProperties> </ProjectToBuild> </ItemGroup> diff --git a/src/BuildIntegration/Microsoft.NETCore.Native.Publish.targets b/src/BuildIntegration/Microsoft.NETCore.Native.Publish.targets new file mode 100644 index 000000000..755aa647f --- /dev/null +++ b/src/BuildIntegration/Microsoft.NETCore.Native.Publish.targets @@ -0,0 +1,61 @@ +<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + + <PropertyGroup> + <BuildTasksPath Condition="'$(BuildTasksPath)' == ''">$(MSBuildThisFileDirectory)..\tools\ILCompiler.Build.Tasks.dll</BuildTasksPath> + + <!-- + Prevent dotnet CLI from deploying the CoreCLR shim executable since we produce + a native executable. + --> + <DeployAppHost>false</DeployAppHost> + </PropertyGroup> + + <Target Name="_ComputeIlcCompileInputs" + BeforeTargets="ComputeIlcCompileInputs"> + <ItemGroup> + <IlcReference Include="@(_ManagedResolvedAssembliesToPublish)" /> + </ItemGroup> + </Target> + + <!-- + 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 CoreRT optimizes the application. + --> + <Target Name="ComputeLinkedFilesToPublish" + BeforeTargets="ComputeFilesToPublish" + DependsOnTargets="_ComputeAssembliesToCompileToNative;LinkNative"> + + <ItemGroup> + <ResolvedAssembliesToPublish Remove="@(_AssembliesToSkipPublish)" /> + <ResolvedAssembliesToPublish Include="@(_LinkedResolvedAssemblies)" /> + </ItemGroup> + + <ItemGroup> + <_NativeIntermediateAssembly Include="@(IntermediateAssembly->'$(NativeOutputPath)%(Filename)$(NativeBinaryExt)')" /> + <IntermediateAssembly Remove="@(IntermediateAssembly)" /> + <IntermediateAssembly Include="@(_NativeIntermediateAssembly)" /> + </ItemGroup> + </Target> + + <!-- + Filter the input publish file list selecting managed assemblies for compilation. + Also produces _AssembliesToSkipPublish which chops out things from the publish + pipeline we don't want to see in the output (native images, CoreCLR artifacts) + until we get a proper AOT NetCore app package. + --> + <UsingTask TaskName="ComputeManagedAssemblies" AssemblyFile="$(BuildTasksPath)" /> + <Target Name="_ComputeAssembliesToCompileToNative"> + + <ComputeManagedAssemblies Assemblies="@(ResolvedAssembliesToPublish)" + DotNetAppHostExecutableName="$(_DotNetAppHostExecutableName)" DotNetHostFxrLibraryName="$(_DotNetHostFxrLibraryName)" DotNetHostPolicyLibraryName="$(_DotNetHostPolicyLibraryName)" + SdkAssemblies="@(PrivateSdkAssemblies)" FrameworkAssemblies="@(FrameworkAssemblies)"> + <Output TaskParameter="ManagedAssemblies" ItemName="_ManagedResolvedAssembliesToPublish" /> + <Output TaskParameter="AssembliesToSkipPublish" ItemName="_AssembliesToSkipPublish" /> + </ComputeManagedAssemblies> + + </Target> + +</Project> diff --git a/src/BuildIntegration/Microsoft.NETCore.Native.targets b/src/BuildIntegration/Microsoft.NETCore.Native.targets index 6e522fe48..22dd34fb0 100644 --- a/src/BuildIntegration/Microsoft.NETCore.Native.targets +++ b/src/BuildIntegration/Microsoft.NETCore.Native.targets @@ -19,6 +19,7 @@ See the LICENSE file in the project root for more information. <PropertyGroup> <NativeIntermediateOutputPath Condition="'$(NativeIntermediateOutputPath)' == ''">$(IntermediateOutputPath)native\</NativeIntermediateOutputPath> <NativeOutputPath Condition="'$(NativeOutputPath)' == ''">$(OutputPath)native\</NativeOutputPath> + <NativeCompilationDuringPublish Condition="'$(NativeCompilationDuringPublish)' == ''">true</NativeCompilationDuringPublish> <!-- Workaround for lack of current host OS detection - https://github.com/Microsoft/msbuild/issues/539 --> <TargetOS Condition="'$(TargetOS)' == '' and '$(OS)' == 'Unix' and Exists('/Applications')">OSX</TargetOS> <TargetOS Condition="'$(TargetOS)' == ''">$(OS)</TargetOS> @@ -60,20 +61,23 @@ See the LICENSE file in the project root for more information. <SharedLibrary Condition="'$(OS)' != 'Windows_NT'">$(FrameworkLibPath)\libframework$(LibFileExt)</SharedLibrary> </PropertyGroup> - <ItemGroup Condition="$(BuildingFrameworkLibrary) != 'true'"> - <ManagedBinary Include="$(IntermediateOutputPath)$(TargetName)$(TargetExt)" /> - </ItemGroup> + <PropertyGroup Condition="'$(IlcCompileDependsOn)'=='' and '$(NativeCompilationDuringPublish)' != 'false'"> + <IlcCompileDependsOn Condition="'$(BuildingFrameworkLibrary)' != 'true'">Compile;ComputeIlcCompileInputs</IlcCompileDependsOn> + <IlcCompileDependsOn Condition="'$(IlcMultiModule)' == 'true' and '$(BuildingFrameworkLibrary)' != 'true'">$(IlcCompileDependsOn);BuildFrameworkLib</IlcCompileDependsOn> + </PropertyGroup> <ItemGroup> - <IlcCompileInput Include="@(ManagedBinary)" /> - <IlcReference Include="$(IlcPath)\sdk\*.dll" /> - <IlcReference Include="$(IlcPath)\framework\*.dll" /> + <DefaultFrameworkAssemblies Include="$(IlcPath)\sdk\*.dll" /> + <DefaultFrameworkAssemblies Include="$(IlcPath)\framework\*.dll" /> </ItemGroup> - <PropertyGroup Condition="'$(IlcCompileDependsOn)'==''"> - <IlcCompileDependsOn Condition="'$(BuildingFrameworkLibrary)' != 'true'">Compile</IlcCompileDependsOn> - <IlcCompileDependsOn Condition="'$(IlcMultiModule)' == 'true' and '$(BuildingFrameworkLibrary)' != 'true'">$(IlcCompileDependsOn);BuildFrameworkLib</IlcCompileDependsOn> - </PropertyGroup> + <Target Name="ComputeIlcCompileInputs"> + <ItemGroup> + <ManagedBinary Condition="$(BuildingFrameworkLibrary) != 'true'" Include="$(IntermediateOutputPath)$(TargetName)$(TargetExt)" /> + <IlcCompileInput Include="@(ManagedBinary)" /> + <IlcReference Include="@(DefaultFrameworkAssemblies)" /> + </ItemGroup> + </Target> <!-- BuildFrameworkLib is invoked before IlcCompile in multi-module builds to @@ -107,6 +111,7 @@ See the LICENSE file in the project root for more information. <IlcArg Condition="$(Optimize) == 'true'" Include="-O" /> <IlcArg Condition="$(DebugSymbols) == 'true'" Include="-g" /> <IlcArg Condition="$(IlcGenerateMapFile) == 'true'" Include="--map:$(NativeIntermediateOutputPath)%(ManagedBinary.Filename).map.xml" /> + <IlcArg Condition="$(RdXmlFile) != ''" Include="--rdxml:$(RdXmlFile)" /> </ItemGroup> <MakeDir Directories="$(NativeIntermediateOutputPath)" /> @@ -178,4 +183,7 @@ See the LICENSE file in the project root for more information. <Exec Command="$(CppLibCreator) @"$(NativeIntermediateOutputPath)lib.rsp"" Condition="'$(OS)' == 'Windows_NT'" /> <Exec Command="$(CppLibCreator) @(CustomLibArg, ' ')" Condition="'$(OS)' != 'Windows_NT'" /> </Target> + + <Import Project="$(MSBuildThisFileDirectory)\Microsoft.NETCore.Native.Publish.targets" Condition="'$(NativeCompilationDuringPublish)' != 'false'" /> + </Project> |