<Project Sdk="Microsoft.NET.Sdk">
  <Import Project="..\..\build\common.props" />

  <PropertyGroup>
    <TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
    <TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
    <PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">$(PackageTargetFallback);portable-net451+win8</PackageTargetFallback>

    <DefineConstants Condition="'$(GenerateBaselines)'=='true'">$(DefineConstants);GENERATE_BASELINES</DefineConstants>
    <DefineConstants>$(DefineConstants);__RemoveThisBitTo__GENERATE_BASELINES</DefineConstants>
    <DefineConstants>$(DefineConstants);FUNCTIONAL_TESTS</DefineConstants>

    <!--
      The functional tests act as the host application for all test websites. Since the CLI copies all reference
      assembly dependencies in websites to their corresponding bin/{config}/refs folder we need to re-calculate
      reference assemblies for this project so there's a corresponding refs folder in our output. Without it
      our websites deps files will fail to find their assembly referenes.
    -->
    <PreserveCompilationContext>true</PreserveCompilationContext>
  </PropertyGroup>

  <PropertyGroup Condition=" '$(TargetFramework)' != 'netcoreapp2.0' ">
    <!-- Work around https://github.com/dotnet/sdk/issues/926. Align with bitness of the web site projects. -->
    <PlatformTarget>x86</PlatformTarget>

    <!--
      Work around https://github.com/Microsoft/vstest/issues/428 aka https://github.com/aspnet/Mvc/issues/5873.
      Create the appropriate binding redirects.
    -->
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="..\Microsoft.AspNetCore.Mvc.Formatters.Xml.Test\XmlAssert.cs" />
    <EmbeddedResource Include="compiler\resources\**\*" />

    <!--
      Work around https://github.com/Microsoft/vstest/issues/196. Execute tests with assemblies in the bin folder, not
      a temporary location. Unable to find the web site project folders otherwise.
    -->
    <None Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\WebSites\ApiExplorerWebSite\ApiExplorerWebSite.csproj" />
    <ProjectReference Include="..\WebSites\ApplicationModelWebSite\ApplicationModelWebSite.csproj" />
    <ProjectReference Include="..\WebSites\BasicWebSite\BasicWebSite.csproj" />
    <ProjectReference Include="..\WebSites\ControllersFromServicesWebSite\ControllersFromServicesWebSite.csproj" />
    <ProjectReference Include="..\WebSites\CorsWebSite\CorsWebSite.csproj" />
    <ProjectReference Include="..\WebSites\ErrorPageMiddlewareWebSite\ErrorPageMiddlewareWebSite.csproj" />
    <ProjectReference Include="..\WebSites\FilesWebSite\FilesWebSite.csproj" />
    <ProjectReference Include="..\WebSites\FiltersWebSite\FiltersWebSite.csproj" />
    <ProjectReference Include="..\WebSites\FormatterWebSite\FormatterWebSite.csproj" />
    <ProjectReference Include="..\WebSites\HtmlGenerationWebSite\HtmlGenerationWebSite.csproj" />
    <ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestCommon\Microsoft.AspNetCore.Mvc.TestCommon.csproj" />
    <ProjectReference Include="..\..\samples\MvcSandbox\MvcSandbox.csproj" />
    <ProjectReference Include="..\WebSites\RazorPageExecutionInstrumentationWebSite\RazorPageExecutionInstrumentationWebSite.csproj" />
    <ProjectReference Include="..\WebSites\RazorPagesWebSite\RazorPagesWebSite.csproj" />
    <ProjectReference Include="..\WebSites\RazorWebSite\RazorWebSite.csproj" />
    <ProjectReference Include="..\WebSites\RoutingWebSite\RoutingWebSite.csproj" />
    <ProjectReference Include="..\WebSites\SecurityWebSite\SecurityWebSite.csproj" />
    <ProjectReference Include="..\WebSites\SimpleWebSite\SimpleWebSite.csproj" />
    <ProjectReference Include="..\WebSites\TagHelpersWebSite\TagHelpersWebSite.csproj" />
    <ProjectReference Include="..\WebSites\VersioningWebSite\VersioningWebSite.csproj" />
    <ProjectReference Include="..\WebSites\WebApiCompatShimWebSite\WebApiCompatShimWebSite.csproj" />
    <ProjectReference Include="..\WebSites\XmlFormattersWebSite\XmlFormattersWebSite.csproj" />

    <PackageReference Include="Microsoft.AspNetCore.ChunkingCookieManager.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
    <PackageReference Include="Microsoft.AspNetCore.Http" Version="$(AspNetCoreVersion)" />
    <PackageReference Include="Microsoft.AspNetCore.TestHost" Version="$(AspNetCoreVersion)" />
    <PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="$(AspNetCoreVersion)" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="$(AspNetCoreVersion)" />
    <PackageReference Include="Microsoft.Extensions.Logging.Testing" Version="$(AspNetCoreVersion)" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
    <PackageReference Include="xunit" Version="$(XunitVersion)" />
    <PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
  </ItemGroup>

  <!--
    Work around https://github.com/NuGet/Home/issues/4412. MVC uses DependencyContext.Load() which looks next to a .dll
    for a .deps.json. Information isn't available elsewhere. Need the .deps.json file for all web site applications.
  -->
  <Target Name="CopyDepsFiles" AfterTargets="Build" Condition="'$(TargetFramework)'!=''">
    <ItemGroup>
      <DepsFilePaths Include="$([System.IO.Path]::ChangeExtension('%(_ResolvedProjectReferencePaths.FullPath)', '.deps.json'))" />
    </ItemGroup>

    <Copy SourceFiles="%(DepsFilePaths.FullPath)" DestinationFolder="$(OutputPath)" Condition="Exists('%(DepsFilePaths.FullPath)')" />
  </Target>
</Project>
