aspnetcore/eng/targets/ResolveIisReferences.targets

93 lines
4.9 KiB
XML

<!--
The targets in this file resolve References to ANCM into ProjectReferences,
with the right MSBuild incantations to get output copied to the right place.
-->
<Project>
<Choose>
<!-- IIS native projects only build on Windows with MSBuild.exe -->
<When Condition="'$(OS)' == 'Windows_NT' AND '$(MSBuildRuntimeType)' != 'Core' ">
<ItemGroup Condition=" '@(Reference->AnyHaveMetadataValue('Identity', 'AspNetCoreModule'))' == 'true' ">
<Reference Remove="AspNetCoreModule" />
<NativeProjectReference Include="$(RepositoryRoot)src\Servers\IIS\AspNetCoreModuleV1\AspNetCore\AspNetCore.vcxproj" />
</ItemGroup>
<ItemGroup Condition=" '@(Reference->AnyHaveMetadataValue('Identity', 'AspNetCoreModuleV2'))' == 'true' ">
<Reference Remove="AspNetCoreModuleV2" />
<NativeProjectReference Include="$(RepositoryRoot)src\Servers\IIS\AspNetCoreModuleV2\AspNetCore\AspNetCore.vcxproj" />
<NativeProjectReference Include="$(RepositoryRoot)src\Servers\IIS\AspNetCoreModuleV2\OutOfProcessRequestHandler\OutOfProcessRequestHandler.vcxproj" HandlerPath="2.0.0" />
<NativeProjectReference Include="$(RepositoryRoot)src\Servers\IIS\AspNetCoreModuleV2\InProcessRequestHandler\InProcessRequestHandler.vcxproj" />
</ItemGroup>
<ItemGroup Condition="@(NativeProjectReference->Count()) != 0">
<!-- TODO: investigate building just one arch at a time. -->
<ProjectReference Include="@(NativeProjectReference)">
<!-- Set the arch-->
<SetPlatform>Platform=x64</SetPlatform>
<!-- The base path for the output. -->
<LinkBase>x64\%(HandlerPath)\</LinkBase>
<!-- This reference assembly doesn't need -->
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<!-- NativeContent is a custom type of item group which is assigned a target path after project references are resolved. -->
<OutputItemType>NativeContent</OutputItemType>
<!-- Set the copy policy. -->
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<!-- This instructs the ProjectRef protocol to collect symbols as well as built output -->
<Targets>Build;BuiltProjectOutputGroup;DebugSymbolsProjectOutputGroup</Targets>
<!-- Optimization. Native projects don't have a .NET TargetFramework -->
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
<UndefineProperties>TargetFramework</UndefineProperties>
<!-- Don't put this reference into generated .nuspec -->
<PrivateAssets>All</PrivateAssets>
<!-- Publish assets from this reference -->
<Publish>true</Publish>
</ProjectReference>
<ProjectReference Include="@(NativeProjectReference)">
<!-- Set the arch-->
<SetPlatform>Platform=Win32</SetPlatform>
<!-- The base path for the output. -->
<LinkBase>x86\%(HandlerPath)\</LinkBase>
<!-- This reference assembly doesn't need -->
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<!-- NativeContent is a custom type of item group which is assigned a target path after project references are resolved. -->
<OutputItemType>NativeContent</OutputItemType>
<!-- Set the copy policy. -->
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<!-- This instructs the ProjectRef protocol to collect symbols as well as built output -->
<Targets>Build;BuiltProjectOutputGroup;DebugSymbolsProjectOutputGroup</Targets>
<!-- Optimization. Native projects don't have a .NET TargetFramework -->
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
<UndefineProperties>TargetFramework</UndefineProperties>
<!-- Don't put this reference into generated .nuspec -->
<PrivateAssets>All</PrivateAssets>
<!-- Publish assets from this reference -->
<Publish>true</Publish>
</ProjectReference>
<NativeProjectReference Remove="@(NativeProjectReference)" />
</ItemGroup>
</When>
</Choose>
<Target Name="_GetNativeContentCopyToOutputDirectoryItems"
BeforeTargets="GetCopyToOutputDirectoryItems"
DependsOnTargets="ResolveProjectReferences">
<ItemGroup>
<!-- Prepend LinkBase to output path. -->
<NativeContent>
<Link>%(LinkBase)%(FileName)%(Extension)</Link>
<!-- Don't put this content in a nuget package. -->
<Pack>false</Pack>
</NativeContent>
</ItemGroup>
<!-- Add the item to the ContentWithTargetPath group, which is then used by GetCopyToOutputDirectoryItems to copy to the correct output location. -->
<AssignTargetPath Files="@(NativeContent)" RootFolder="$(MSBuildProjectDirectory)">
<Output TaskParameter="AssignedFiles" ItemName="ContentWithTargetPath" />
</AssignTargetPath>
</Target>
</Project>