Skip to content

Commit 4d1b3a8

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 b2270bb commit 4d1b3a8

File tree

4 files changed

+13
-16
lines changed

4 files changed

+13
-16
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
<!-- Projects which reference Microsoft.AspNetCore.Mvc.Testing should import this targets file to ensure dependency .deps.json files are copied into test output. -->
177177
<MvcTestingTargets>$(MSBuildThisFileDirectory)src\Mvc\Mvc.Testing\src\Microsoft.AspNetCore.Mvc.Testing.targets</MvcTestingTargets>
178178
<!-- IIS native projects can only be built on Windows for x86 and x64. -->
179-
<BuildIisNativeProjects Condition=" $(BuildNative) AND ('$(TargetArchitecture)' == 'x86' OR '$(TargetArchitecture)' == 'x64') ">true</BuildIisNativeProjects>
179+
<BuildIisNativeProjects Condition=" '$(TargetOsName)' == 'win' AND ('$(TargetArchitecture)' == 'x86' OR '$(TargetArchitecture)' == 'x64') ">true</BuildIisNativeProjects>
180180
<!-- This property is shared by several projects to layout the AspNetCore.App targeting pack for installers -->
181181
<TargetingPackLayoutRoot>$(ArtifactsObjDir)TargetingPack.Layout\$(Configuration)\</TargetingPackLayoutRoot>
182182
<!-- 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
@@ -85,14 +85,12 @@
8585
Include="$(RepoRoot)src\Installers\Rpm\**\*.*proj" />
8686
</ItemGroup>
8787

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

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

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: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
127127

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

130-
<ProjectReference Condition=" '$(BuildIisNativeProjects)' == 'true' "
130+
<ProjectReference Condition=" '$(BuildIisNativeProjects)' == 'true' AND $(BuildNative) "
131131
Include="$(RepoRoot)src\Servers\IIS\AspNetCoreModuleV2\InProcessRequestHandler\InProcessRequestHandler.vcxproj">
132132
<SetPlatform>Platform=$(TargetArchitecture)</SetPlatform>
133133
<SetPlatform Condition="'$(TargetArchitecture)' == 'x86'">Platform=Win32</SetPlatform>
@@ -138,6 +138,12 @@ This package is an internal implementation of the .NET Core SDK and is not meant
138138
<!-- C++ projects don't invoke GetTargetPath by default when building. -->
139139
<Targets>Build;GetTargetPath</Targets>
140140
</ProjectReference>
141+
142+
<!-- Complicated condition here covers cases where native builds are separate but in-proc handler is needed. -->
143+
<_ResolvedNativeProjectReferencePaths Condition="('$(BuildIisNativeProjects)' != 'true' OR '$(BuildNative)' == 'false' OR '$(VCTargetsPath)' == '') AND '$(TargetOsName)' == 'win' AND ('$(TargetArchitecture)' == 'x86' OR '$(TargetArchitecture)' == 'x64')"
144+
Include="$(ArtifactsBinDir)InProcessRequestHandler\$(TargetArchitecture)\$(Configuration)\aspnetcorev2_inprocess.dll">
145+
<IsNativeImage>true</IsNativeImage>
146+
</_ResolvedNativeProjectReferencePaths>
141147
</ItemGroup>
142148

143149
<ItemGroup>

0 commit comments

Comments
 (0)