mirror of
https://github.com/BepInEx/dotnet-runtime.git
synced 2026-11-22 14:09:34 -10:00
* Don't use Targets* helper properties in libs projs This change makes it possible to migrate 200+ (ref+src) projects to use TargetFramework instead of TargetFrameworks which avoids the additional outer build evaluation and invocation which ultimately makes the overall build faster. Targets* properties (i.e. TargetsWindows, TargetsAnyOS, TargetsUnix, etc.) rely on the TargetFramework property which usually are set inside a project. The TargetFramework property is only available before a project specifies it if it's explicitly set in a props file or if the project is cross-targeting and the outer-build dispatches into the inner-build. During the dispatch, the TargetFramework property is passed in as a global property. Until now that behavior wasn't a problem because every libraries project cross-targeted (by setting the TargetFrameworks property) even though many only include a single TargetFramework (i.e. NetCoreAppCurrent). To allow projects to use the TargetFramework property instead of TargetFrameworks, the Targets* helper properties can't be calculated anymore early in a props file as the TargetFramework property isn't set at that time. In general, the guidance by the SDK/msbuild team is to not read from the TargetFramework property before the project sets it (in a property group). That effectively means that the TargetFramework property shouldn't be used in props files at all. Therefore these helper properties can't be used anymore for property conditions and I'm replacing their usage with TargetPlatformIdentifier comparisons for both properties and items. In nearly all cases, the Targets* helper properties can be replaced with TargetPlatformIdentifier checks on items and in the few cases where TargetsUnix or TargetsLinux marks multiple tfms as compatible, the exact tfms must be used instead for the TargetPlatformIdentifier comparison. Whenever a project needs to condition properties on the platform, I'm first setting the TargetPlatformIdentifier the same way the SDK sets it so that the SDK later doesn't need to set it again to avoid the additional expensive msbuild function call. * Use TargetFramework singular to avoid outer builds Use TargetFramework instead of TargetFrameworks property whenever a projects only targets a single target framework. This avoid unnecessary outer builds and evaluations and makes the build faster.
51 lines
3.3 KiB
XML
51 lines
3.3 KiB
XML
<Project>
|
|
<PropertyGroup>
|
|
<TestProjectName Condition="'$(TestProjectName)' == ''">$(MSBuildProjectName)</TestProjectName>
|
|
<TestFramework Condition="'$(TestFramework)' == ''">xunit</TestFramework>
|
|
<!-- Implicit test build support when invoking the Test target on the project directly. -->
|
|
<TestDependsOn Condition="'$(TestNoBuild)' != 'true' and '$(BuildAllProjects)' != 'true'">Build</TestDependsOn>
|
|
<TestDependsOn>$(TestDependsOn);GenerateRunScript;RunTests</TestDependsOn>
|
|
<VSTestNoLogo>true</VSTestNoLogo>
|
|
<ILLinkDescriptorsPath>$(MSBuildThisFileDirectory)ILLinkDescriptors\</ILLinkDescriptorsPath>
|
|
<TestSingleFile Condition="'$(TestNativeAot)' == 'true'">true</TestSingleFile>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<!-- Default and user defined categories -->
|
|
<_withCategories Condition="'$(WithCategories)' != ''">;$(WithCategories.Trim(';'))</_withCategories>
|
|
<_withoutCategories Condition="'$(WithoutCategories)' != ''">;$(WithoutCategories.Trim(';'))</_withoutCategories>
|
|
|
|
<TestScope Condition="'$(TestScope)' == '' and '$(Outerloop)' == 'true'">all</TestScope>
|
|
<_withCategories Condition="'$(TestScope)' == 'outerloop'">$(_withCategories);OuterLoop</_withCategories>
|
|
<_withoutCategories Condition="'$(ArchiveTests)' == 'true'">$(_withoutCategories);IgnoreForCI</_withoutCategories>
|
|
<_withoutCategories Condition="'$(TestScope)' == '' or '$(TestScope)' == 'innerloop'">$(_withoutCategories);OuterLoop</_withoutCategories>
|
|
<_withoutCategories Condition="!$(_withCategories.Contains('failing'))">$(_withoutCategories);failing</_withoutCategories>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="'$(TargetsMobile)' == 'true'">
|
|
<!-- Test runners are built as part of libs.pretest so we need to use libraries configuration -->
|
|
<AppleTestRunnerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AppleTestRunner', '$(Configuration)', '$(NetCoreAppCurrent)'))</AppleTestRunnerDir>
|
|
<AndroidTestRunnerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AndroidTestRunner', '$(Configuration)', '$(NetCoreAppCurrent)'))</AndroidTestRunnerDir>
|
|
<WasmTestRunnerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'WasmTestRunner', '$(Configuration)', '$(NetCoreAppCurrent)'))</WasmTestRunnerDir>
|
|
|
|
<RuntimeIdentifier>$(PackageRID)</RuntimeIdentifier>
|
|
<SelfContained>true</SelfContained>
|
|
</PropertyGroup>
|
|
|
|
<!-- Provide runtime options to Mono (interpreter, aot, debugging, etc) -->
|
|
<ItemGroup Condition="'$(MonoEnvOptions)' != '' and '$(TargetsMobile)' != 'true'">
|
|
<RunScriptCommands Condition="'$(TargetsWindows)' == 'true' or '$(TargetPlatformIdentifier)' == 'windows'" Include="set MONO_ENV_OPTIONS='$(MonoEnvOptions)'" />
|
|
<RunScriptCommands Condition="'$(TargetsWindows)' != 'true' and '$(TargetPlatformIdentifier)' != 'windows'" Include="export MONO_ENV_OPTIONS='$(MonoEnvOptions)'" />
|
|
</ItemGroup>
|
|
|
|
<ItemGroup Condition="'$(TestRunRequiresLiveRefPack)' == 'true'">
|
|
<None Include="$(MicrosoftNetCoreAppRefPackRefDir)**/*.dll" CopyToOutputDirectory="PreserveNewest" LinkBase="live-ref-pack/" Visible="false" />
|
|
</ItemGroup>
|
|
|
|
<!--
|
|
Unit/Functional/Integration test support.
|
|
Supported runners: xunit.
|
|
-->
|
|
<Import Project="$(MSBuildThisFileDirectory)xunit\xunit.props" Condition="'$(TestFramework)' == 'xunit'" />
|
|
</Project>
|