﻿<?xml version="1.0" encoding="utf-8"?>

<!--
***********************************************************************************************
Microsoft.Web.Designtime.targets

WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
          created a backup copy.  Incorrect changes to this file will make it
          impossible to load or build your projects from the command-line or the IDE.

Copyright (C) Microsoft Corporation. All rights reserved.
***********************************************************************************************
-->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <!--
    Locate the approriate localized xaml resources based on the language ID or name.

    The logic here matches the resource manager sufficiently to handle the fixed set of 
    possible VS languages and directories on disk.

    We cannot respect the exact probe order of the resource manager as this has to evaluate statically
    and we have only LangName and LangID and no access to System.Globalization API.
  -->
  <PropertyGroup Condition="'$(XamlResourcesDirectory)' == ''">
    <!-- 1. Probe for exact match against LangName. (e.g. pt-BR) -->
    <XamlResourcesDirectory>$(MSBuildThisFileDirectory)$(LangName)</XamlResourcesDirectory>

    <!-- 2. Handle special cases of languages which would not match above or below. -->
    <XamlResourcesDirectory Condition="!Exists('$(XamlResourcesDirectory)') and '$(LangID)' == '2052'">$(MSBuildThisFileDirectory)zh-Hans</XamlResourcesDirectory>
    <XamlResourcesDirectory Condition="!Exists('$(XamlResourcesDirectory)') and '$(LangID)' == '1028'">$(MSBuildThisFileDirectory)zh-Hant</XamlResourcesDirectory>

    <!-- 3. Probe for parent by taking portion the portion before the hyphen (e.g. fr-FR -> fr) -->
    <XamlResourcesDirectory Condition="!Exists('$(XamlResourcesDirectory)')">$(MSBuildThisFileDirectory)$(LangName.Split('-')[0])</XamlResourcesDirectory>

    <!-- 4. Fall back to neutral English resources if all of the above fail -->
    <XamlResourcesDirectory Condition="!Exists('$(XamlResourcesDirectory)')">$(MSBuildThisFileDirectory)</XamlResourcesDirectory>

    <XamlResourcesDirectory Condition="!HasTrailingSlash('$(XamlResourcesDirectory)')">$(XamlResourcesDirectory)\</XamlResourcesDirectory>
  </PropertyGroup>

  <PropertyGroup>
    <!--
      Web item templates have some files that should not have indexes added to names when files are being created,
      like packages.json etc. To opt out from that we need to specify this property.
      -->
    <AlwaysUseNumericalSuffixInItemNames>false</AlwaysUseNumericalSuffixInItemNames>
  </PropertyGroup>

  <!--
      Web project capabilities that enables Visual Studio web features for .NET Core projects. Note that the capabiliites "DotNetCoreWeb", "AspNetCore" and "Web" come from the
      imported web sdk targets file and are not included here
    -->
  <ItemGroup>
    <ProjectCapability Include="SupportHierarchyContextSvc" />
    <ProjectCapability Include="DynamicDependentFile" />
    <ProjectCapability Include="DynamicFileNesting" />
    <ProjectCapability Include="DynamicFileNestingEnabled" />

    <!-- 
      Enables UI for managing secret values when Microsoft.Extensions.Configuration.UserSecrets 1.x is referenced. 
      Newer versions of this package include a MSBuild file to set this ProjectCapability, but older versions did not include this.
      See https://github.com/aspnet/Configuration/blob/9135af4b4e95c080ca4a9f0e91ba5a0b8a561c96/src/Microsoft.Extensions.Configuration.UserSecrets/build/netstandard1.0/Microsoft.Extensions.Configuration.UserSecrets.targets#L10
    -->
    <ProjectCapability Include="LocalUserSecrets" Condition=" '$(GenerateUserSecretsAttribute)' != 'false' " />

  </ItemGroup>

  <!-- Web specific property schemas -->
  <ItemGroup>
    <PropertyPageSchema Include="$(XamlResourcesDirectory)GeneralBrowseObject.xaml">
      <Context>BrowseObject</Context>
    </PropertyPageSchema>
  </ItemGroup>

  <ItemGroup>
    <PropertyPageSchema Include="$(XamlResourcesDirectory)IISDebugPropertyPage.xaml">
      <Context>Project</Context>
    </PropertyPageSchema>
    <PropertyPageSchema Include="$(XamlResourcesDirectory)IISExpressDebugPropertyPage.xaml">
      <Context>Project</Context>
    </PropertyPageSchema>
    <PropertyPageSchema Include="$(XamlResourcesDirectory)ProjectDebugPropertyPage.xaml">
      <Context>Project</Context>
    </PropertyPageSchema>
    <PropertyPageSchema Include="$(XamlResourcesDirectory)BuildPropertyPage.xaml">
      <Context>Project</Context>
    </PropertyPageSchema>
  </ItemGroup>

  <!-- This target is used at design time to retrieve the set of generated code files from the gRPC references -->
  <Target Name="GetProtobufOutputFiles" DependsOnTargets="Protobuf_Compile" Returns="@(Protobuf_ExpectedOutputs)" />
</Project>
