aspnetcore/src/Servers/IIS/build/testsite.props

126 lines
6.5 KiB
XML

<Project>
<PropertyGroup>
<RuntimeIdentifiers>$(RuntimeIdentifiers);win-x64;win-x86</RuntimeIdentifiers>
<Platforms>x64;x86</Platforms>
<IISExpressAppHostConfig>$(MSBuildThisFileDirectory)applicationhost.config</IISExpressAppHostConfig>
<IISAppHostConfig>$(MSBuildThisFileDirectory)applicationhost.iis.config</IISAppHostConfig>
<PreserveCompilationContext>false</PreserveCompilationContext>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
<!-- Work around until we get a new WebSdk -->
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
<HasTestAssetProfile Condition="'$(TestAssetProfile)' != ''">true</HasTestAssetProfile>
<TestAssetOutputName Condition="'$(TestAssetOutputName)' == ''">$(MSBuildProjectName)</TestAssetOutputName>
</PropertyGroup>
<Import Project="assets.props" />
<PropertyGroup Condition="'$(NativePlatform)' == 'x86'">
<IISExpressPath>$(MSBuildProgramFiles32)\IIS Express\iisexpress.exe</IISExpressPath>
<IISPath>$(SystemRoot)\SysWOW64\inetsrv\w3wp.exe</IISPath>
<NativeFolder>Win32</NativeFolder>
</PropertyGroup>
<PropertyGroup Condition="'$(NativePlatform)' == 'x64'">
<IISExpressPath>$(ProgramW6432)\IIS Express\iisexpress.exe</IISExpressPath>
<IISPath>$(SystemRoot)\System32\inetsrv\w3wp.exe</IISPath>
<NativeFolder>x64</NativeFolder>
</PropertyGroup>
<PropertyGroup>
<IISExpressArguments>/config:"$(IISExpressAppHostConfig)" /systray:false</IISExpressArguments>
<IISArguments>-h "$(IISAppHostConfig)"</IISArguments>
<AncmInProcessRHPath>aspnetcorev2_inprocess.dll</AncmInProcessRHPath>
<!-- TODO: use LocalDotNetRoot instead to find dotnet.exe (see reporoot/Directory.Build.props). Requires a fix to https://github.com/dotnet/aspnetcore/issues/7196 -->
<DotNetPath>$(RepoRoot).dotnet\dotnet.exe</DotNetPath>
<DotNetPath Condition="'$(NativePlatform)' != 'x64'">$(RepoRoot).dotnet\$(NativePlatform)\dotnet.exe</DotNetPath>
</PropertyGroup>
<Target Name="CopyLaunchSettings" AfterTargets="CoreBuild">
<!-- This would always override launch settings files in test projects by the default one -->
<Copy SourceFiles="$(MSBuildThisFileDirectory)launchSettings.json" DestinationFolder="$(MSBuildProjectDirectory)\Properties" SkipUnchangedFiles="true" />
</Target>
<!-- Deps file injection-->
<ItemGroup Condition="('$(InProcessTestSite)' == 'true') AND ('$(ReferenceTestTasks)' != 'false')">
<ProjectReference Include="$(MSBuildThisFileDirectory)..\IIS\test\testassets\TestTasks\TestTasks.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Target Name="PrepareInjectionApp" Condition="'$(InProcessTestSite)' == 'true'">
<PropertyGroup>
<InjectDepsAssembly>$(MSBuildThisFileDirectory)..\IIS\test\testassets\TestTasks\bin\$(Configuration)\$(TargetFramework)\TestTasks</InjectDepsAssembly>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFrameworkIdentifier)' != '.NETFramework' ">
<InjectDepsApp>dotnet $(InjectDepsAssembly).dll</InjectDepsApp>
</PropertyGroup>
</Target>
<!--
GenerateBuildDependencyFile creates the .deps file used here. BuildDepsJson and CoreBuild are empty targets marking
the end of processes using the GenerateBuildDependencyFile target.
-->
<Target Name="InjectRequestHandler"
Condition=" '$(InProcessTestSite)' == 'true' AND '$(BuildIisNativeProjects)' == 'true' AND '$(TargetFrameworkIdentifier)' != '.NETFramework'"
BeforeTargets="BuildDepsJson;CoreBuild"
DependsOnTargets="GenerateBuildDependencyFile;PrepareInjectionApp">
<Exec Command="$(InjectDepsApp) &quot;$(ProjectDepsFilePath)&quot; $(RuntimeIdentifier) " />
</Target>
<!--
GeneratePublishDependencyFile creates an intermediate .deps file copied soon after into the publish folder.
CopyFilesToPublishDirectory is an empty target marking the end of all copies into the publish folder, including the
.deps file and native assets. Publish is an empty target marking the end of the entire process.
(GenerateSingleFileBundle also uses the intermediate .desp file but only in single-file publish cases ignored here.)
-->
<Target Name="InjectRequestHandlerOnPublish"
Condition=" '$(InProcessTestSite)' == 'true' AND '$(BuildIisNativeProjects)' == 'true' AND '$(TargetFrameworkIdentifier)' != '.NETFramework'"
BeforeTargets="Publish"
DependsOnTargets="GeneratePublishDependencyFile;CopyFilesToPublishDirectory;PrepareInjectionApp">
<Exec Command="$(InjectDepsApp) &quot;$(PublishDepsFilePath)&quot; $(RuntimeIdentifier) " />
</Target>
<Target Name="PreventProjectReferencesFromBuilding" BeforeTargets="BeforeResolveReferences" Condition="'@(TestAssetPublishProfile->Count())' != '0'">
<PropertyGroup>
<BuildProjectReferences Condition="'$(HasTestAssetProfile)' == 'true'">false</BuildProjectReferences>
</PropertyGroup>
</Target>
<Target Name="PrepareForTestAssetPublish" BeforeTargets="PrepareForPublish" Condition="'@(TestAssetPublishProfile->Count())' != '0'">
<PropertyGroup Condition="'$(HasTestAssetProfile)' == 'true'">
<PublishDir>$(PublishDir)\$(TestAssetOutputName)-$(TestAssetProfile)\</PublishDir>
</PropertyGroup>
<PropertyGroup Condition="'$(HasTestAssetProfile)' != 'true'">
<IsPublishable>false</IsPublishable>
<IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
</PropertyGroup>
</Target>
<Target Name="PublishTestsAsset" DependsOnTargets="Publish" Returns="@(PublishedTestAsset)">
<ConvertToAbsolutePath Paths="$(PublishDir)">
<Output TaskParameter="AbsolutePaths" PropertyName="PublishAbsoluteDir" />
</ConvertToAbsolutePath>
<ItemGroup>
<PublishedTestAsset Include="$(TestAssetOutputName)-$(TestAssetProfile)" Path="$(PublishAbsoluteDir)" />
</ItemGroup>
</Target>
<Target Name="PublishTestsAssets" Condition="'$(TestAssetProfile)' == '' AND '@(TestAssetPublishProfile->Count())' != '0'" Returns="@(PublishedTestAsset)">
<!--
_InsidePublishTestsAssets is to avoid invoking this target recursively
Platform;PlatformTarget removal is fix builds inside VS -->
<MSBuild Projects="$(MSBuildProjectFullPath)"
Targets="PublishTestsAsset"
RemoveProperties="Platform;PlatformTarget"
Properties="PublishDir=$(PublishDir);TestAssetProfile=%(TestAssetPublishProfile.Identity);ReferenceTestTasks=false;%(TestAssetPublishProfile.Properties)">
<Output TaskParameter="TargetOutputs" ItemName="PublishedTestAsset" />
</MSBuild>
</Target>
</Project>