Skip to content

Commit 3662a68

Browse files
committed
Quick fix: Ensure $(BuildNative) is always set correctly
- fix problems using `-all` or `/p:BuildAllProjects=true` without `-buildNative` - ensure `$(BuildNative)` is `false` where it's not supported - move some duplicated settings into eng/Common.props and `<Import />` the new file - remove now-duplicated parts of conditions using `$(BuildNative)`
1 parent 8bc7551 commit 3662a68

File tree

9 files changed

+65
-57
lines changed

9 files changed

+65
-57
lines changed

Directory.Build.props

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<Project>
2+
<Import Project="eng\Common.props" />
3+
24
<PropertyGroup>
35
<RepoRoot>$(MSBuildThisFileDirectory)</RepoRoot>
46
<RepositoryUrl>https://github.com/dotnet/aspnetcore</RepositoryUrl>
@@ -121,12 +123,7 @@
121123

122124
<!-- Compilation options which apply to all languages. Language-specific options should be set in eng/targets/$(lang).Common.props -->
123125
<PropertyGroup>
124-
<TargetOsName Condition=" '$(TargetOsName)' == '' AND $([MSBuild]::IsOSPlatform('Windows'))">win</TargetOsName>
125-
<TargetOsName Condition=" '$(TargetOsName)' == '' AND $([MSBuild]::IsOSPlatform('OSX'))">osx</TargetOsName>
126-
<TargetOsName Condition=" '$(TargetOsName)' == '' AND $([MSBuild]::IsOSPlatform('Linux'))">linux</TargetOsName>
127126
<BuildArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant())</BuildArchitecture>
128-
<TargetArchitecture Condition="'$(TargetArchitecture)' == ''">x64</TargetArchitecture>
129-
<TargetRuntimeIdentifier>$(TargetOsName)-$(TargetArchitecture)</TargetRuntimeIdentifier>
130127

131128
<!-- This defines the list of RIDs supported by the ASP.NET Core shared framework. -->
132129
<SupportedRuntimeIdentifiers>
@@ -179,7 +176,7 @@
179176
<!-- Projects which reference Microsoft.AspNetCore.Mvc.Testing should import this targets file to ensure dependency .deps.json files are copied into test output. -->
180177
<MvcTestingTargets>$(MSBuildThisFileDirectory)src\Mvc\Mvc.Testing\src\Microsoft.AspNetCore.Mvc.Testing.targets</MvcTestingTargets>
181178
<!-- IIS native projects can only be built on Windows for x86 and x64. -->
182-
<BuildIisNativeProjects Condition="'$(BuildNative)' == 'true' AND '$(TargetOsName)' == 'win' AND ('$(TargetArchitecture)' == 'x86' OR '$(TargetArchitecture)' == 'x64')">true</BuildIisNativeProjects>
179+
<BuildIisNativeProjects Condition=" $(BuildNative) AND ('$(TargetArchitecture)' == 'x86' OR '$(TargetArchitecture)' == 'x64') ">true</BuildIisNativeProjects>
183180
<!-- This property is shared by several projects to layout the AspNetCore.App targeting pack for installers -->
184181
<TargetingPackLayoutRoot>$(ArtifactsObjDir)TargetingPack.Layout\$(Configuration)\</TargetingPackLayoutRoot>
185182
<!-- This property is shared by several projects to layout the AspNetCore.App shared framework for installers -->

eng/Build.props

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
<Project>
2-
<PropertyGroup>
3-
<TargetRuntimeIdentifier Condition="'$(TargetRuntimeIdentifier)' == ''">$(TargetOsName)-$(TargetArchitecture)</TargetRuntimeIdentifier>
4-
</PropertyGroup>
5-
6-
<PropertyGroup Condition=" '$(BuildAllProjects)' == 'true' ">
7-
<BuildNative Condition="'$(BuildNative)' == ''">true</BuildNative>
8-
<BuildManaged Condition="'$(BuildManaged)' == ''">true</BuildManaged>
9-
<BuildNodeJS Condition="'$(BuildNodeJS)' == ''">true</BuildNodeJS>
10-
<BuildJava Condition="'$(BuildJava)' == ''">true</BuildJava>
11-
</PropertyGroup>
2+
<Import Project="Common.props" />
123

134
<!-- These projects are always excluded, even when -projects is specified on command line. -->
145
<ItemGroup>
@@ -102,8 +93,8 @@
10293
<AdditionalProperties Condition="'$(TargetArchitecture)' == 'x86'">Platform=Win32</AdditionalProperties>
10394
</NativeProjects>
10495

105-
<ProjectToBuild Condition=" '$(BuildNative)' == 'true'" Include="@(NativeProjects)" Exclude="@(ProjectToExclude)" />
106-
<ProjectToExclude Condition=" '$(BuildNative)' != 'true'" Include="@(NativeProjects)" />
96+
<ProjectToBuild Condition=" $(BuildNative) " Include="@(NativeProjects)" Exclude="@(ProjectToExclude)" />
97+
<ProjectToExclude Condition=" !$(BuildNative) " Include="@(NativeProjects)" />
10798

10899
<NodeJsProjects Include="
109100
$(RepoRoot)src\Components\Web.JS\Microsoft.AspNetCore.Components.Web.JS.npmproj;

eng/Common.props

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project>
2+
<PropertyGroup>
3+
<TargetOsName Condition=" '$(TargetOsName)' == '' AND $([MSBuild]::IsOSPlatform('Windows'))">win</TargetOsName>
4+
<TargetOsName Condition=" '$(TargetOsName)' == '' AND $([MSBuild]::IsOSPlatform('OSX'))">osx</TargetOsName>
5+
<TargetOsName Condition=" '$(TargetOsName)' == '' AND $([MSBuild]::IsOSPlatform('Linux'))">linux</TargetOsName>
6+
<TargetArchitecture Condition="'$(TargetArchitecture)' == ''">x64</TargetArchitecture>
7+
<TargetRuntimeIdentifier Condition="'$(TargetRuntimeIdentifier)' == ''">$(TargetOsName)-$(TargetArchitecture)</TargetRuntimeIdentifier>
8+
</PropertyGroup>
9+
10+
<PropertyGroup Condition=" '$(BuildAllProjects)' == 'true' ">
11+
<!-- Ignore $(BuildNative) when using MSBuild Core, on non-Windows platforms, or when C++ bits are missing. -->
12+
<BuildNative Condition=" '$(MSBuildRuntimeType)' == 'Core' ">false</BuildNative>
13+
<BuildNative Condition=" '$(TargetOsName)' != 'win' ">false</BuildNative>
14+
<BuildNative Condition=" '$(VCTargetsPath)' == '' ">false</BuildNative>
15+
<BuildNative Condition=" '$(BuildNative)' == '' ">true</BuildNative>
16+
17+
<BuildManaged Condition="'$(BuildManaged)' == ''">true</BuildManaged>
18+
<BuildNodeJS Condition="'$(BuildNodeJS)' == ''">true</BuildNodeJS>
19+
<BuildJava Condition="'$(BuildJava)' == ''">true</BuildJava>
20+
</PropertyGroup>
21+
22+
<PropertyGroup>
23+
<BuildNative Condition=" '$(BuildNative)' == '' ">false</BuildNative>
24+
</PropertyGroup>
25+
</Project>

eng/Signing.props

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
2-
32
<!-- See https://github.com/dotnet/arcade/blob/master/Documentation/CorePackages/Signing.md for details. -->
3+
<Import Project="Common.props" />
44

55
<ItemGroup>
66
<!-- Reset Arcade's defaults. -->
@@ -69,7 +69,6 @@
6969
</ItemGroup>
7070

7171
<PropertyGroup>
72-
<TargetRuntimeIdentifier Condition="'$(TargetRuntimeIdentifier)' == ''">$(TargetOsName)-$(TargetArchitecture)</TargetRuntimeIdentifier>
7372
<BaseRedistNetCorePath>$(ArtifactsObjDir)RedistSharedFx.Layout\$(Configuration)\</BaseRedistNetCorePath>
7473
<RedistNetCorePath>$(BaseRedistNetCorePath)$(TargetRuntimeIdentifier)\</RedistNetCorePath>
7574
</PropertyGroup>

eng/targets/ResolveIisReferences.targets

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,35 @@ with the right MSBuild incantations to get output copied to the right place.
55
66
-->
77
<Project>
8-
<Choose>
9-
<!-- IIS native projects only build on Windows with MSBuild.exe -->
10-
<When Condition="'$(OS)' == 'Windows_NT' AND '$(MSBuildRuntimeType)' != 'Core' ">
11-
<ItemGroup Condition="@(NativeProjectReference->Count()) != 0 AND '$(BuildNative)' != 'false' ">
12-
<!-- TODO: investigate building just one arch at a time. -->
13-
<ProjectReference Include="@(NativeProjectReference)">
14-
<!-- Set the arch-->
15-
<SetPlatform>Platform=%(Platform)</SetPlatform>
16-
<SetPlatform Condition="'%(Platform)' == 'x86'">Platform=Win32</SetPlatform>
17-
<!-- The base path for the output. -->
18-
<LinkBase>%(Platform)\%(HandlerPath)\</LinkBase>
19-
<!-- This reference assembly doesn't need -->
20-
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
21-
<!-- NativeContent is a custom type of item group which is assigned a target path after project references are resolved. -->
22-
<OutputItemType>NativeContent</OutputItemType>
23-
<!-- This instructs the ProjectRef protocol to collect symbols as well as built output -->
24-
<Targets>Build;BuiltProjectOutputGroup;DebugSymbolsProjectOutputGroup</Targets>
25-
<!-- Optimization. Native projects don't have a .NET TargetFramework -->
26-
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
27-
<UndefineProperties>TargetFramework</UndefineProperties>
28-
<!-- Don't put this reference into generated .nuspec -->
29-
<PrivateAssets>All</PrivateAssets>
30-
<!-- Publish assets from this reference -->
31-
<Publish>true</Publish>
32-
</ProjectReference>
33-
34-
<NativeProjectReference Remove="@(NativeProjectReference)" />
35-
</ItemGroup>
36-
</When>
37-
</Choose>
8+
<!-- IIS native projects only build on Windows with MSBuild.exe -->
9+
<ItemGroup Condition="@(NativeProjectReference->Count()) != 0 AND $(BuildNative) ">
10+
<!-- TODO: investigate building just one arch at a time. -->
11+
<ProjectReference Include="@(NativeProjectReference)">
12+
<!-- Set the arch-->
13+
<SetPlatform>Platform=%(Platform)</SetPlatform>
14+
<SetPlatform Condition="'%(Platform)' == 'x86'">Platform=Win32</SetPlatform>
15+
<!-- The base path for the output. -->
16+
<LinkBase>%(Platform)\%(HandlerPath)\</LinkBase>
17+
<!-- This reference assembly doesn't need -->
18+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
19+
<!-- NativeContent is a custom type of item group which is assigned a target path after project references are resolved. -->
20+
<OutputItemType>NativeContent</OutputItemType>
21+
<!-- This instructs the ProjectRef protocol to collect symbols as well as built output -->
22+
<Targets>Build;BuiltProjectOutputGroup;DebugSymbolsProjectOutputGroup</Targets>
23+
<!-- Optimization. Native projects don't have a .NET TargetFramework -->
24+
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
25+
<UndefineProperties>TargetFramework</UndefineProperties>
26+
<!-- Don't put this reference into generated .nuspec -->
27+
<PrivateAssets>All</PrivateAssets>
28+
<!-- Publish assets from this reference -->
29+
<Publish>true</Publish>
30+
</ProjectReference>
31+
<NativeProjectReference Remove="@(NativeProjectReference)" />
32+
</ItemGroup>
3833

3934
<Target Name="_WarnAboutUnbuiltNativeDependencies"
4035
BeforeTargets="Build"
41-
Condition=" @(NativeProjectReference->Count()) != 0 AND '$(BuildNative)' == 'false' ">
36+
Condition=" @(NativeProjectReference->Count()) != 0 AND !$(BuildNative) ">
4237
<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++." />
4338
</Target>
4439

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ This package is an internal implementation of the .NET Core SDK and is not meant
126126

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

129-
<ProjectReference Condition="'$(BuildIisNativeProjects)' == 'true' AND '$(BuildNative)' != 'false' AND '$(VCTargetsPath)' != ''" Include="$(RepoRoot)src\Servers\IIS\AspNetCoreModuleV2\InProcessRequestHandler\InProcessRequestHandler.vcxproj">
129+
<ProjectReference Condition=" '$(BuildIisNativeProjects)' == 'true' "
130+
Include="$(RepoRoot)src\Servers\IIS\AspNetCoreModuleV2\InProcessRequestHandler\InProcessRequestHandler.vcxproj">
130131
<SetPlatform>Platform=$(TargetArchitecture)</SetPlatform>
131132
<SetPlatform Condition="'$(TargetArchitecture)' == 'x86'">Platform=Win32</SetPlatform>
132133
<!-- Custom attribute used to distinguish managed from native references. -->
@@ -214,7 +215,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
214215

215216
<Target Name="_WarnAboutUnbuiltNativeDependencies"
216217
BeforeTargets="Build"
217-
Condition=" '$(BuildIisNativeProjects)' == 'true' AND '$(BuildNative)' == 'false' ">
218+
Condition=" '$(BuildIisNativeProjects)' == 'true' AND !$(BuildNative) ">
218219
<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++." />
219220
</Target>
220221

@@ -496,7 +497,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
496497
</Target>
497498

498499
<Target Name="IncludeVersionFile"
499-
DependsOnTargets="GenerateSharedFxVersionsFiles"
500+
DependsOnTargets="GenerateSharedFxVersionsFiles"
500501
BeforeTargets="_GetPackageFiles">
501502

502503
<ItemGroup>

src/Servers/IIS/AspNetCoreModuleV2/Symbols/Microsoft.AspNetCore.ANCMSymbols.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</None>
2929
</ItemGroup>
3030

31-
<ItemGroup Condition="'$(BuildIisNativeProjects)' == 'true' AND '$(VCTargetsPath)' != ''">
31+
<ItemGroup Condition=" '$(BuildIisNativeProjects)' == 'true' ">
3232
<NativeProjectReference Include="$(MSBuildThisFileDirectory)..\..\AspNetCoreModuleV2\OutOfProcessRequestHandler\OutOfProcessRequestHandler.vcxproj" Platform="$(NativeVCPlatform)" />
3333
<NativeProjectReference Include="$(MSBuildThisFileDirectory)..\..\AspNetCoreModuleV2\AspNetCore\AspNetCore.vcxproj" Platform="$(NativeVCPlatform)" />
3434
</ItemGroup>

src/Servers/IIS/IIS/src/Microsoft.AspNetCore.Server.IIS.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
Condition="'$(BuildIisNativeProjects)' == 'true' AND !Exists('$(AspNetCoreModuleV2InProcessHandlerDll)')" />
2929
</Target>
3030

31-
<ItemGroup Condition="'$(BuildIisNativeProjects)' == 'true' AND '$(VCTargetsPath)' != ''">
31+
<ItemGroup Condition=" '$(BuildIisNativeProjects)' == 'true' ">
3232
<NativeProjectReference Include="$(MSBuildThisFileDirectory)..\..\AspNetCoreModuleV2\InProcessRequestHandler\InProcessRequestHandler.vcxproj" Platform="x64" />
3333
<NativeProjectReference Include="$(MSBuildThisFileDirectory)..\..\AspNetCoreModuleV2\InProcessRequestHandler\InProcessRequestHandler.vcxproj" Platform="Win32" />
3434
</ItemGroup>

src/Servers/IIS/IntegrationTesting.IIS/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
Condition="!Exists('$(AspNetCoreModuleV2ShimDll)') OR !Exists('$(AspNetCoreModuleV2OutOfProcessHandlerDll)')" />
3535
</Target>
3636

37-
<ItemGroup Condition="'$(BuildIisNativeProjects)' == 'true' AND '$(VCTargetsPath)' != '' AND '$(TestGroupName)' != 'IISNewHandler.FunctionalTests'">
37+
<ItemGroup Condition="'$(BuildIisNativeProjects)' == 'true' AND '$(TestGroupName)' != 'IISNewHandler.FunctionalTests'">
3838
<NativeProjectReference Include="$(MSBuildThisFileDirectory)..\..\AspNetCoreModuleV2\AspNetCore\AspNetCore.vcxproj" Platform="x64"/>
3939
<NativeProjectReference Include="$(MSBuildThisFileDirectory)..\..\AspNetCoreModuleV2\OutOfProcessRequestHandler\OutOfProcessRequestHandler.vcxproj" Platform="x64" />
4040

0 commit comments

Comments
 (0)