Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Overhaul external / binplacing / reference from runtime #15705

Merged
merged 4 commits into from
Feb 2, 2017
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
9 changes: 7 additions & 2 deletions Tools-Override/FrameworkTargeting.targets
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,17 @@
</Target>

<Target Name="MarkReferencePrivateFalse"
BeforeTargets="ResolveAssemblyReferences">
BeforeTargets="ResolveAssemblyReferences;AssignProjectConfiguration">
<ItemGroup>
<!-- Simple name references will be resolved from the targeting pack folders and should never be copied to outpu -->
<!-- Simple name references will be resolved from the targeting pack folders and should never be copied to output -->
<Reference Condition="'%(Reference.Extension)' != '.dll'">
<Private>false</Private>
</Reference>

<!-- Project references for non-test assemblies should never be copied to the output. -->
<ProjectReference Condition="'$(IsTestProject)' != 'true'">
<Private>false</Private>
</ProjectReference>
</ItemGroup>
</Target>

Expand Down
22 changes: 14 additions & 8 deletions binplace.targets
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<BinPlaceStuffDependsOn Condition="'$(IsRuntimeAssembly)' == 'true' OR '$(IsRuntimeAndReferenceAssembly)' == 'true'">$(BinPlaceStuffDependsOn);BinPlaceRuntimeAssembly</BinPlaceStuffDependsOn>
</PropertyGroup>

<ItemGroup>
<ItemGroup Condition="'@(BinplaceConfiguration)' == ''">
<BinplaceConfiguration Include="$(BuildConfiguration)">
<RefPath>$(BuildConfigurationRefPath)</RefPath>
<RuntimePath>$(RuntimePath)</RuntimePath>
Expand All @@ -31,22 +31,28 @@
<Message Importance="low" Text="IsRuntimeAndReferenceAssembly: $(IsRuntimeAndReferenceAssembly)" />
</Target>

<Target Name="BinPlaceReferenceAssembly" DependsOnTargets="GetBinplaceDirs">
<Target Name="BinPlaceReferenceAssembly" DependsOnTargets="GetBinplaceDirs;GetBinplaceItems">
<Message Importance="low" Text="TargetingPackDir: @(TargetingPackDir)" />
<Copy Condition="'@(TargetingPackDir)' != ''" SourceFiles="$(TargetPath)" DestinationFolder="%(TargetingPackDir.Identity)" >
<Copy Condition="'@(TargetingPackDir)' != ''" SourceFiles="@(BinplaceItem)" DestinationFolder="%(TargetingPackDir.Identity)" >
<Output TaskParameter="DestinationFiles" ItemName="FileWrites" />
</Copy>
</Target>

<Target Name="BinPlaceRuntimeAssembly" DependsOnTargets="GetBinplaceDirs">
<Copy Condition="'@(RuntimeDir)' != ''" SourceFiles="$(TargetPath)" DestinationFolder="%(RuntimeDir.Identity)">
<Output TaskParameter="DestinationFiles" ItemName="FileWrites" />
</Copy>
<Copy Condition="'@(RuntimeDir)' != '' And Exists($(TargetPath.Replace('.dll', '.pdb')))" SourceFiles="$(TargetPath.Replace('.dll', '.pdb'))" DestinationFolder="%(RuntimeDir.Identity)">
<Target Name="BinPlaceRuntimeAssembly" DependsOnTargets="GetBinplaceDirs;GetBinplaceItems">
<Copy Condition="'@(RuntimeDir)' != ''" SourceFiles="@(BinplaceItem)" DestinationFolder="%(RuntimeDir.Identity)">
<Output TaskParameter="DestinationFiles" ItemName="FileWrites" />
</Copy>
</Target>

<Target Name="GetBinplaceItems" DependsOnTargets="GetCopyToOutputDirectoryItems">
<ItemGroup>
<BinplaceItem Condition="Exists('$(TargetPath)')" Include="$(TargetPath)" />
<BinplaceItem Condition="Exists('$(TargetDir)$(TargetName).pdb')" Include="$(TargetDir)$(TargetName).pdb" />
<BinplaceItem Condition="'$(BinplaceReferenceCopyLocalPaths)' != 'false'" Include="@(ReferenceCopyLocalPaths)" />
<BinplaceItem Condition="'$(BinplaceCopyToOutputDirectoryItems)' != 'false'" Include="@(AllItemsFullPathWithTargetPath)" />
</ItemGroup>
</Target>

<Target Name="GetBinplaceDirs" DependsOnTargets="GetBuildConfigurations">
<!-- find which, if any, build configuration of this project is best
for each binplace configuration -->
Expand Down
3 changes: 3 additions & 0 deletions dir.props
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@
<NetStandardRefPath>$(RefRootPath)netstandard/</NetStandardRefPath>
<NetFxRefPath>$(RefRootPath)netfx/</NetFxRefPath>

<!-- project file to use when resolving ReferenceFromRuntime items -->
<RuntimeProjectFile Condition="'$(RuntimeProjectFile)' == ''">$(ProjectDir)\external\runtime\runtime.depproj</RuntimeProjectFile>

<!-- Paths to binplace package content -->
<NETCoreAppPackageRefPath>$(BinDir)netcoreapp\pkg\ref</NETCoreAppPackageRefPath>
<NETCoreAppPackageRuntimePath>$(BinDir)netcoreapp\pkg\lib</NETCoreAppPackageRuntimePath>
Expand Down
1 change: 1 addition & 0 deletions dir.targets
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<Import Condition="Exists('$(MSBuildThisFileDirectory)..\open.targets')" Project="$(MSBuildThisFileDirectory)..\open.targets" />

<Import Project="$(MSBuildThisFileDirectory)binplace.targets" />
<Import Project="$(MSBuildThisFileDirectory)referenceFromRuntime.targets" />

<PropertyGroup>
<!-- We don't use any of MSBuild's resolution logic for resolving the framework, so just set these two properties to any folder that exists to skip
Expand Down
8 changes: 0 additions & 8 deletions external/NETNative/Configurations.props

This file was deleted.

10 changes: 0 additions & 10 deletions external/coreclr/coreclr.depproj

This file was deleted.

3 changes: 1 addition & 2 deletions external/dir.proj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

<!-- Build for all configurations -->
<ItemGroup>
<Project Include="coreclr/coreclr.depproj" />
<Project Include="netstandard/netstandard.depproj" />
<Project Include="netfx/netfx.depproj" />
<Project Include="NETNative/NETNative.depproj" />
<Project Include="runtime/runtime.depproj" />
<Project Include="test-runtime/XUnit.Runtime.depproj" />
</ItemGroup>

Expand Down
4 changes: 0 additions & 4 deletions external/dir.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\dir.props" />
<PropertyGroup>
<!-- HACK to work around binplacing issue right now for depproj's -->
<IsRuntimeAssembly>false</IsRuntimeAssembly>
</PropertyGroup>
<PropertyGroup>
<IntermediateOutputPath>$(IntermediateOutputPath)$(ArchGroup)/</IntermediateOutputPath>
<NugetRuntimeIdentifier>$(RuntimeOS)-$(ArchGroup)</NugetRuntimeIdentifier>
Expand Down
11 changes: 11 additions & 0 deletions external/dir.targets
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
Outputs="$(ProjectJson)"
Condition="Exists('$(ProjectJsonTemplate)')"
>
<MakeDir Directories="$([System.IO.Path]::GetDirectoryName('$(ProjectJson)'))" />
<!-- Update project.json template -->
<WriteLinesToFile
File="$(ProjectJson)"
Expand All @@ -31,4 +32,14 @@

</Target>

<!-- Override build and GetTargetPath to return all items deployed -->
<Target Name="Build"
Condition=" '$(_InvalidConfigurationWarning)' != 'true' "
DependsOnTargets="$(BuildDependsOn)"
Returns="@(BinplaceItem)" />

<!-- Depprojs need to run Compile in order to populate items that will be copied to output -->
<Target Name="GetTargetPath"
DependsOnTargets="Compile;GetBinplaceItems"
Returns="@(BinplaceItem)" />
</Project>
10 changes: 8 additions & 2 deletions external/netfx/netfx.depproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<IsReferenceAssembly>true</IsReferenceAssembly>
<NuGetDeploySourceItem>Reference</NuGetDeploySourceItem>
<NugetRuntimeIdentifier>None</NugetRuntimeIdentifier>
<OutputPath>$(RefRootPath)/$(TargetGroup)</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(NuGetTargetMoniker)' == '.NETFramework,Version=v4.6.3'">
<!-- Missing 4.6.3 targeting pack, use 462 for now -->
Expand All @@ -14,9 +14,15 @@
<!-- For things not .NETFramework we need the net461 targeting pack to generate facades -->
<NuGetTargetMoniker>.NETFramework,Version=v4.6.1</NuGetTargetMoniker>
<TargetingPackNugetPackageId>Microsoft.TargetingPack.NETFramework.v4.6.1</TargetingPackNugetPackageId>
<OutputPath>$(NetFxRefPath)</OutputPath>
<ForShims>true</ForShims>
</PropertyGroup>
<ItemGroup>
<BinplaceConfiguration Include="$(Configuration)">
<RefPath Condition="'$(ForShims)' != 'true'">$(RefPath)</RefPath>
<RefPath Condition="'$(ForShims)' == 'true'">$(NetFxRefPath)</RefPath>
</BinplaceConfiguration>
</ItemGroup>

<!-- Filter the targeting pack to just these assemblies which we need netcoreapp shims for -->
<ItemGroup>
<TargetingPackReference Include="mscorlib" />
Expand Down
42 changes: 15 additions & 27 deletions external/netstandard/netstandard.depproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,26 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<IsNetFx Condition="$(NuGetTargetMoniker.StartsWith('.NETFramework,'))">true</IsNetFx>
<IsNetFxVertical Condition="'$(_bc_TargetGroup)' == 'netfx' OR $(_bc_TargetGroup.StartsWith('net4'))">true</IsNetFxVertical>
<IsNETStandard1x Condition="$(NuGetTargetMoniker.StartsWith('.NETStandard,Version=v1.'))">true</IsNETStandard1x>
<IsReferenceAssembly>true</IsReferenceAssembly>
<!-- when building for any NetFx vertical, also place facades in runtime folder -->
<IsRuntimeAndReferenceAssembly Condition="'$(IsNetFx)' == 'true' AND '$(IsNetFxVertical)' == 'true'">true</IsRuntimeAndReferenceAssembly>
<NuGetDeploySourceItem>Reference</NuGetDeploySourceItem>
<NugetRuntimeIdentifier>None</NugetRuntimeIdentifier>
<OutputPath>$(RefRootPath)/$(TargetGroup)</OutputPath>
<ProjectJsonTemplate Condition="$(NuGetTargetMoniker.Contains('Version=v1.'))">$(MSBuildProjectDirectory)\netstandard1.x\project.json.template</ProjectJsonTemplate>
<ProjectJsonTemplate Condition="'$(IsNETStandard1x)' == 'true'">$(MSBuildProjectDirectory)\netstandard1.x\project.json.template</ProjectJsonTemplate>
<_NETStandardTFMFolder Condition="'$(NuGetTargetMoniker)' == '.NETStandard,Version=v2.0'">netstandard2.0</_NETStandardTFMFolder>
<_NETStandardTFMFolder Condition="$(NuGetTargetMoniker.StartsWith('.NETFramework'))">net461</_NETStandardTFMFolder>
<_NETStandardTFMFolder Condition="'$(IsNetFx)' == 'true'">net461</_NETStandardTFMFolder>
</PropertyGroup>

<ItemGroup>
<!-- on desktop facades are used at runtime as well -->
<AdditionalOutputDirectory Condition="$(NuGetTargetMoniker.StartsWith('.NETFramework'))" Include="$(RuntimePath)" />
<!-- for all configurations this project provides refs for that configuration -->
<BinplaceConfiguration Include="$(Configuration)">
<RefPath>$(RefPath)</RefPath>
<!-- only for netfx verticals will this project provide runtime assets -->
<RuntimePath>$(RuntimePath)</RuntimePath>
</BinplaceConfiguration>
</ItemGroup>

<Target Name="AddNETStandardRefs" AfterTargets="ResolveReferences"
Expand All @@ -31,26 +40,5 @@
</ItemGroup>
</Target>

<Target Name="CopyToAdditionalOutputDirectories"
Inputs="%(AdditionalOutputDirectory.Identity)"
Outputs="unused"
AfterTargets="CopyFilesToOutputDirectory">
<PropertyGroup>
<_additionalOutDir>%(AdditionalOutputDirectory.Identity)</_additionalOutDir>
</PropertyGroup>
<Copy
SourceFiles = "@(_SourceItemsToCopyToOutputDirectory)"
DestinationFiles = "@(_SourceItemsToCopyToOutputDirectory->'$(_additionalOutDir)%(TargetPath)')"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
UseHardlinksIfPossible="$(CreateHardLinksForAdditionalFilesIfPossible)"
>

<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>

</Copy>
</Target>

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
8 changes: 7 additions & 1 deletion external/portable/portable.depproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<IsReferenceAssembly>true</IsReferenceAssembly>
<NuGetDeploySourceItem>Reference</NuGetDeploySourceItem>
<NugetRuntimeIdentifier>None</NugetRuntimeIdentifier>
<OutputPath>$(RefRootPath)/$(TargetGroup)</OutputPath>
</PropertyGroup>
<ItemGroup>
<!-- for all configurations this project provides refs for that configuration -->
<BinplaceConfiguration Include="$(Configuration)">
<RefPath>$(RefPath)</RefPath>
</BinplaceConfiguration>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<Target Name="FilterTargetingPackResolvedNugetPackages" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<BuildConfigurations>
netcoreapp;
uap;
uapaot;
</BuildConfigurations>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<OutputPath>$(RuntimePath)</OutputPath>
<DisableReferenceCopyLocal>true</DisableReferenceCopyLocal>
<!-- WORKAROUND: Force external packages to be restored for x64 until arm packages are fully broughtup-->
<NugetRuntimeIdentifier Condition="'$(ArchGroup)' == 'arm'">$(RuntimeOS)-x64</NugetRuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetGroup)' == 'uapaot'">
<ProjectJsonTemplate>$(MSBuildThisFileDirectory)NETNative/project.json.template</ProjectJsonTemplate>
<NuGetDeploySourceItem>Reference</NuGetDeploySourceItem>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'uapaot'">
<TargetingPackReference Include="System.Private.CoreLib" />
<TargetingPackReference Include="System.Private.CoreLib.Augments" />
<TargetingPackReference Include="System.Private.CoreLib.DynamicDelegate" />
Expand Down
1 change: 0 additions & 1 deletion external/test-runtime/XUnit.Runtime.depproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<IsRuntimeAssembly>false</IsRuntimeAssembly>
<!-- Given that xunit packages bring with them part of the framework, we need to specify a runtime in order to get the assets
This RID value doesn't really matter, since the assets we are copying are not RID specific, so defaulting to Windows here
-->
Expand Down
48 changes: 48 additions & 0 deletions referenceFromRuntime.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="AddReferenceFromRuntimeForTests"
AfterTargets="ResolveAssemblyReferences"
Condition="'$(IsTestProject)'=='true' AND '@(ReferenceFromRuntime)' != ''">
<ItemGroup>
<!-- tests can use anything from the RuntimePath -->
<ReferencePath Include="@(ReferenceFromRuntime->'$(RuntimePath)%(Identity).dll')" />
</ItemGroup>
</Target>

<Target Name="AddRuntimeProjectReference"
BeforeTargets="AnnotateProjectReference"
Condition="'$(IsTestProject)'!='true' AND '@(ReferenceFromRuntime)' != ''">
<Error Condition="'$(IsReferenceAssembly)' != 'true' AND '$(RuntimeProjectFile)' == ''" Text="RuntimeProjectFile must be specified when using ReferenceFromRuntime from source projects." />
<Error Condition="'$(IsReferenceAssembly)' == 'true'" Text="ReferenceFromRuntime may not be used from reference assemblies." />

<ItemGroup>
<ProjectReference Include="$(RuntimeProjectFile)">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<OutputItemType>_referencePathFromRuntime</OutputItemType>
</ProjectReference>
</ItemGroup>
</Target>

<Target Name="FilterReferenceFromRuntime"
AfterTargets="ResolveProjectReferences"
Condition="'$(IsTestProject)'!='true' AND '@(ReferenceFromRuntime)' != ''">
<ItemGroup>
<!-- transform to filename in order to intersect -->
<_referencePathFromRuntimeByFileName Include="@(_referencePathFromRuntime->'%(FileName)')" >
<ReferencePath>%(Identity)</ReferencePath>
</_referencePathFromRuntimeByFileName>

<!-- intersect with ReferenceFromRuntime -->
<_filteredReferencePathFromRuntimeByFileName Include="@(_referencePathFromRuntimeByFileName)"
Condition="'@(_referencePathFromRuntimeByFileName)' == '@(ReferenceFromRuntime)' AND '%(Identity)' != ''" />

<_missingReferenceFromRuntime Include="@(ReferenceFromRuntime)" Exclude="'@(_referencePathFromRuntimeByFileName)" />

<!-- transform back to path -->
<ReferencePath Include="@(_filteredReferencePathFromRuntimeByFileName->'%(ReferencePath)')" />
</ItemGroup>

<Error Condition="'@(_missingReferenceFromRuntime)' != ''"
Text="Could not resolve ReferenceFromRuntime item(s) '@(_missingReferenceFromRuntime)' from '$(RuntimeProjectFile)'." />
</Target>
</Project>
2 changes: 0 additions & 2 deletions targetingpacks.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
<Reference Include="%(TargetingPackItems.Filename)" Exclude="@(TargetingPackExclusions)"> <!-- TODO: System.Private.CoreLib shouldn't even be in the targeting pack. -->
<Private>false</Private>
</Reference>
<ReferencePath Include="@(ReferenceFromRuntime->'$(RuntimePath)%(Identity).dll')" />
</ItemGroup>
</Target>

</Project>