Skip to content

Commit 167695f

Browse files
authored
Port native project ref changes to 2.1 (#6071)
1 parent 3641761 commit 167695f

File tree

5 files changed

+89
-10
lines changed

5 files changed

+89
-10
lines changed

Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@
4646
<Import Project="eng\targets\Wix.Common.props" Condition="'$(MSBuildProjectExtension)' == '.wixproj'" />
4747
<Import Project="eng\targets\CSharp.Common.props" Condition="'$(MSBuildProjectExtension)' == '.csproj'" />
4848
<Import Project="eng\targets\Cpp.Common.props" Condition="'$(MSBuildProjectExtension)' == '.vcxproj'" />
49+
<Import Project="eng\targets\ResolveIisReferences.targets" Condition=" '$(MSBuildProjectExtension)' != '.vcxproj' " />
4950

5051
</Project>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<!--
2+
The targets in this file resolve References to ANCM into ProjectReferences,
3+
with the right MSBuild incantations to get output copied to the right place.
4+
-->
5+
<Project>
6+
<Choose>
7+
<!-- IIS native projects only build on Windows with MSBuild.exe -->
8+
<When Condition="'$(OS)' == 'Windows_NT' AND '$(MSBuildRuntimeType)' != 'Core' ">
9+
<ItemGroup Condition=" '@(Reference->AnyHaveMetadataValue('Identity', 'AspNetCoreModuleV1'))' == 'true' ">
10+
<Reference Remove="AspNetCoreModuleV1" />
11+
<NativeProjectReference Include="$(MSBuildThisFileDirectory)src\AspNetCoreModuleV1\AspNetCore\AspNetCore.vcxproj" />
12+
</ItemGroup>
13+
14+
<ItemGroup Condition="@(NativeProjectReference->Count()) != 0">
15+
<!-- TODO: investigate building just one arch at a time. -->
16+
<ProjectReference Include="@(NativeProjectReference)">
17+
<!-- Set the arch-->
18+
<SetPlatform>Platform=x64</SetPlatform>
19+
<!-- The base path for the output. -->
20+
<LinkBase>x64\%(HandlerPath)\</LinkBase>
21+
<!-- This reference assembly doesn't need -->
22+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
23+
<!-- NativeContent is a custom type of item group which is assigned a target path after project references are resolved. -->
24+
<OutputItemType>NativeContent</OutputItemType>
25+
<!-- Set the copy policy. -->
26+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
27+
<!-- This instructs the ProjectRef protocol to collect symbols as well as built output -->
28+
<Targets>Build;BuiltProjectOutputGroup;DebugSymbolsProjectOutputGroup</Targets>
29+
<!-- Optimization. Native projects don't have a .NET TargetFramework -->
30+
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
31+
<UndefineProperties>TargetFramework</UndefineProperties>
32+
<!-- Don't put this reference into generated .nuspec -->
33+
<PrivateAssets>All</PrivateAssets>
34+
<!-- Publish assets from this reference -->
35+
<Publish>true</Publish>
36+
</ProjectReference>
37+
38+
<ProjectReference Include="@(NativeProjectReference)">
39+
<!-- Set the arch-->
40+
<SetPlatform>Platform=x86</SetPlatform>
41+
<!-- The base path for the output. -->
42+
<LinkBase>x86\%(HandlerPath)\</LinkBase>
43+
<!-- This reference assembly doesn't need -->
44+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
45+
<!-- NativeContent is a custom type of item group which is assigned a target path after project references are resolved. -->
46+
<OutputItemType>NativeContent</OutputItemType>
47+
<!-- Set the copy policy. -->
48+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
49+
<!-- This instructs the ProjectRef protocol to collect symbols as well as built output -->
50+
<Targets>Build;BuiltProjectOutputGroup;DebugSymbolsProjectOutputGroup</Targets>
51+
<!-- Optimization. Native projects don't have a .NET TargetFramework -->
52+
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
53+
<UndefineProperties>TargetFramework</UndefineProperties>
54+
<!-- Don't put this reference into generated .nuspec -->
55+
<PrivateAssets>All</PrivateAssets>
56+
<!-- Publish assets from this reference -->
57+
<Publish>true</Publish>
58+
</ProjectReference>
59+
60+
<NativeProjectReference Remove="@(NativeProjectReference)" />
61+
</ItemGroup>
62+
</When>
63+
</Choose>
64+
65+
<Target Name="_GetNativeContentCopyToOutputDirectoryItems"
66+
BeforeTargets="GetCopyToOutputDirectoryItems"
67+
DependsOnTargets="ResolveProjectReferences">
68+
69+
<ItemGroup>
70+
<!-- Prepend LinkBase to output path. -->
71+
<NativeContent>
72+
<Link>%(LinkBase)%(FileName)%(Extension)</Link>
73+
<!-- Don't put this content in a nuget package. -->
74+
<Pack>false</Pack>
75+
</NativeContent>
76+
</ItemGroup>
77+
78+
<!-- Add the item to the ContentWithTargetPath group, which is then used by GetCopyToOutputDirectoryItems to copy to the correct output location. -->
79+
<AssignTargetPath Files="@(NativeContent)" RootFolder="$(MSBuildProjectDirectory)">
80+
<Output TaskParameter="AssignedFiles" ItemName="ContentWithTargetPath" />
81+
</AssignTargetPath>
82+
</Target>
83+
</Project>

src/Servers/IIS/.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ project.lock.json
3535
*.tlog
3636
*.CppClean.log
3737
*msbuild.log
38-
src/*/*/Debug/
39-
src/*/*/x64/Debug/
40-
src/*/*/Release/
41-
src/*/*/x64/Release/
38+
Debug/
39+
Release/
4240
x64/
4341
*vcxproj.filters
4442
*.aps

src/Servers/test/FunctionalTests/ServerComparison.FunctionalTests.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
<Content Include="*.config;*.conf" CopyToPublishDirectory="PreserveNewest" CopyToOutputDirectory="PreserveNewest" />
1010
</ItemGroup>
1111

12-
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
13-
<!-- Temporary work around until ANCM ProjectReference changes are in 2.1 -->
14-
<PackageReference Include="Microsoft.AspNetCore.AspNetCoreModuleV1" Version="$(MicrosoftAspNetCoreAspNetCoreModuleV1PackageVersion)" />
15-
</ItemGroup>
16-
1712
<ItemGroup>
1813
<Reference Include="Microsoft.AspNetCore.Server.IntegrationTesting" />
1914
<Reference Include="Microsoft.Extensions.Logging" />

src/Servers/testassets/TestSites/ServerComparison.TestSites.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

3+
<Import Project="$(RepositoryRoot)src\Servers\IIS\build\testsite.props" />
4+
35
<PropertyGroup>
46
<TargetFrameworks>netcoreapp2.1;netcoreapp2.0;net461</TargetFrameworks>
57
<RuntimeIdentifiers>win7-x86;win7-x64;linux-x64;osx-x64</RuntimeIdentifiers>
68
</PropertyGroup>
79

810
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
9-
<PackageReference Include="Microsoft.AspNetCore.AspNetCoreModuleV1" Version="$(MicrosoftAspNetCoreAspNetCoreModuleV1PackageVersion)" />
11+
<NativeProjectReference Include="$(MSBuildThisFileDirectory)src\AspNetCoreModuleV1\AspNetCore\AspNetCore.vcxproj" />
1012
</ItemGroup>
1113

1214
<ItemGroup>

0 commit comments

Comments
 (0)