Skip to content

Commit ac3fe49

Browse files
committed
Enable building managed projects depending on native assets
- splitting native builds out confuses these projects - use `$(BuildNative)` less, only to control actual building (not bundling) - build both native platforms in one `msbuild` invocation
1 parent a5741d5 commit ac3fe49

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
<!-- Projects which reference Microsoft.AspNetCore.Mvc.Testing should import this targets file to ensure dependency .deps.json files are copied into test output. -->
181181
<MvcTestingTargets>$(MSBuildThisFileDirectory)src\Mvc\Mvc.Testing\src\Microsoft.AspNetCore.Mvc.Testing.targets</MvcTestingTargets>
182182
<!-- IIS native projects can only be built on Windows for x86 and x64. -->
183-
<BuildIisNativeProjects Condition=" $(BuildNative) AND ('$(TargetArchitecture)' == 'x86' OR '$(TargetArchitecture)' == 'x64') ">true</BuildIisNativeProjects>
183+
<BuildIisNativeProjects Condition=" '$(TargetOsName)' == 'win' AND ('$(TargetArchitecture)' == 'x86' OR '$(TargetArchitecture)' == 'x64') ">true</BuildIisNativeProjects>
184184
<!-- This property is shared by several projects to layout the AspNetCore.App targeting pack for installers -->
185185
<TargetingPackLayoutRoot>$(ArtifactsObjDir)TargetingPack.Layout\$(Configuration)\</TargetingPackLayoutRoot>
186186
<!-- This property is shared by several projects to layout the AspNetCore.App shared framework for installers -->

eng/Build.props

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,12 @@
8484
Include="$(RepoRoot)src\Installers\Rpm\**\*.*proj" />
8585
</ItemGroup>
8686

87-
<ItemGroup>
88-
<NativeProjects Condition=" '$(TargetOsName)' == 'win' AND ('$(TargetArchitecture)' == 'x86' OR '$(TargetArchitecture)' == 'x64') "
89-
Include="$(RepoRoot)src\**\*.vcxproj" Exclude="@(ProjectToExclude)">
90-
<!-- Required to prevent triggering double-builds. See src\Servers\IIS\ResolveIisReferences.targets for details. -->
91-
<AdditionalProperties Condition="'$(TargetArchitecture)' == 'x64'">Platform=x64</AdditionalProperties>
92-
<AdditionalProperties Condition="'$(TargetArchitecture)' == 'x86'">Platform=Win32</AdditionalProperties>
93-
</NativeProjects>
87+
<ItemGroup Condition=" '$(TargetOsName)' == 'win' AND ('$(TargetArchitecture)' == 'x86' OR '$(TargetArchitecture)' == 'x64') ">
88+
<NativeProjects Include="$(RepoRoot)src\**\*.vcxproj" Exclude="@(ProjectToExclude)" AdditionalProperties="Platform=x64" />
89+
<NativeProjects Include="$(RepoRoot)src\**\*.vcxproj" Exclude="@(ProjectToExclude)" AdditionalProperties="Platform=Win32" />
90+
</ItemGroup>
9491

92+
<ItemGroup>
9593
<ProjectToBuild Condition=" $(BuildNative) " Include="@(NativeProjects)" Exclude="@(ProjectToExclude)" />
9694
<ProjectToExclude Condition=" !$(BuildNative) " Include="@(NativeProjects)" />
9795

eng/targets/ResolveIisReferences.targets

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,4 @@ with the right MSBuild incantations to get output copied to the right place.
3030
</ProjectReference>
3131
<NativeProjectReference Remove="@(NativeProjectReference)" />
3232
</ItemGroup>
33-
34-
<Target Name="_WarnAboutUnbuiltNativeDependencies"
35-
BeforeTargets="Build"
36-
Condition=" @(NativeProjectReference->Count()) != 0 AND !$(BuildNative) ">
37-
<Warning Text="This project has native dependencies which were not built. Without this, tests may not function correctly. Run `build.cmd -native` to build native projects. Run `build.cmd -managed -native` to build both C# and C++." />
38-
</Target>
39-
4033
</Project>

src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ This package is an internal implementation of the .NET Core SDK and is not meant
117117

118118
<FrameworkListFileName>RuntimeList.xml</FrameworkListFileName>
119119
<FrameworkListOutputPath>$(ArtifactsObjDir)$(FrameworkListFileName)</FrameworkListOutputPath>
120+
121+
<NativePlatform>$(TargetArchitecture)</NativePlatform>
122+
<NativePlatform Condition=" '$(NativePlatform)' == 'x86' ">Win32</NativePlatform>
120123
</PropertyGroup>
121124

122125
<ItemGroup>
@@ -127,17 +130,21 @@ This package is an internal implementation of the .NET Core SDK and is not meant
127130

128131
<Reference Include="microsoft.netcore.app.runtime.$(RuntimeIdentifier)" ExcludeAssets="All" PrivateAssets="All" />
129132

130-
<ProjectReference Condition=" '$(BuildIisNativeProjects)' == 'true' "
133+
<ProjectReference Condition=" '$(BuildIisNativeProjects)' == 'true' AND $(BuildNative) "
131134
Include="$(RepoRoot)src\Servers\IIS\AspNetCoreModuleV2\InProcessRequestHandler\InProcessRequestHandler.vcxproj">
132-
<SetPlatform>Platform=$(TargetArchitecture)</SetPlatform>
133-
<SetPlatform Condition="'$(TargetArchitecture)' == 'x86'">Platform=Win32</SetPlatform>
135+
<SetPlatform>Platform=$(NativePlatform)</SetPlatform>
134136
<!-- Custom attribute used to distinguish managed from native references. -->
135137
<IsNativeImage>true</IsNativeImage>
136138
<!-- A custom item group to be used in targets later. -->
137139
<OutputItemType>_ResolvedNativeProjectReferencePaths</OutputItemType>
138140
<!-- C++ projects don't invoke GetTargetPath by default when building. -->
139141
<Targets>Build;GetTargetPath</Targets>
140142
</ProjectReference>
143+
144+
<_ResolvedNativeProjectReferencePaths Condition=" '$(BuildIisNativeProjects)' == 'true' AND !$(BuildNative) "
145+
Include="$(ArtifactsBinDir)InProcessRequestHandler\$(NativePlatform)\$(Configuration)\aspnetcorev2_inprocess.dll">
146+
<IsNativeImage>true</IsNativeImage>
147+
</_ResolvedNativeProjectReferencePaths>
141148
</ItemGroup>
142149

143150
<ItemGroup>
@@ -216,7 +223,8 @@ This package is an internal implementation of the .NET Core SDK and is not meant
216223

217224
<Target Name="_WarnAboutUnbuiltNativeDependencies"
218225
BeforeTargets="Build"
219-
Condition=" '$(BuildIisNativeProjects)' == 'true' AND !$(BuildNative) ">
226+
Condition=" '$(BuildIisNativeProjects)' == 'true' AND !$(BuildNative) AND
227+
!EXISTS('$(ArtifactsBinDir)InProcessRequestHandler\$(NativePlatform)\$(Configuration)\aspnetcorev2_inprocess.dll') ">
220228
<Warning Text="This project has native dependencies which were not built. Without this, tests may not function correctly. Run `build.cmd -BuildNative -BuildManaged` to build both C# and C++." />
221229
</Target>
222230

0 commit comments

Comments
 (0)