<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <UsingTask TaskName="GenerateResourcesCode" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll" />

  <PropertyGroup>
    <ResourcesSourceOutputDirectory Condition="'$(ResourcesSourceOutputDirectory)' == ''">$(MSBuildProjectDirectory)/Resources/</ResourcesSourceOutputDirectory>
    <StringResourcesPath Condition="'$(StringResourcesPath)'=='' And Exists('$(ResourcesSourceOutputDirectory)Strings.resx')">$(ResourcesSourceOutputDirectory)/Strings.resx</StringResourcesPath>
    <IntermediateResOutputFileFullPath Condition="'$(MSBuildProjectExtension)' == '.csproj'">$(IntermediateOutputPath)SR.cs</IntermediateResOutputFileFullPath>
    <IntermediateResOutputFileFullPath Condition="'$(MSBuildProjectExtension)' == '.vbproj'">$(IntermediateOutputPath)SR.vb</IntermediateResOutputFileFullPath>
    <DefineConstants Condition="'$(ConfigurationGroup)' == 'Debug'">$(DefineConstants);DEBUGRESOURCES</DefineConstants>
  </PropertyGroup>
  
  <PropertyGroup Condition="'$(StringResourcesPath)'!=''">
      <CompileDependsOn>
          GenerateResourcesSource;
          $(CompileDependsOn);
      </CompileDependsOn>
  </PropertyGroup>

  <Target Name="GenerateResourcesSource"
          Condition="'$(StringResourcesPath)'!='' AND '$(OmitResources)'!='true'"
          Inputs="$(StringResourcesPath)"
          Outputs="$(IntermediateResOutputFileFullPath)">
    
    

    <GenerateResourcesCode
        ResxFilePath="$(StringResourcesPath)" 
        OutputSourceFilePath="$(IntermediateResOutputFileFullPath)" 
        AssemblyName="$(AssemblyName)" />

    <ItemGroup>
      <!-- The following Compile element has to be included dynamically inside the Target otherwise intellisense will not work -->
      <Compile Include="$(IntermediateResOutputFileFullPath)" />
    </ItemGroup>

    <ItemGroup>
      <FileWrites Include="$(IntermediateResOutputFileFullPath)" />
    </ItemGroup>
  </Target>
  
  <ItemGroup Condition="'$(StringResourcesPath)'!='' AND '$(OmitResources)'!='true'">
    <EmbeddedResource Include="$(StringResourcesPath)">
      <Visible>true</Visible>
      <LogicalName>FxResources.$(AssemblyName).SR.resources</LogicalName>
    </EmbeddedResource>
  </ItemGroup>
  
  <ItemGroup Condition="Exists('$(StringResourcesPath)') And '$(SkipCommonResourcesIncludes)'=='' AND '$(OmitResources)'!='true'">
    <Compile Condition="'$(MSBuildProjectExtension)' == '.csproj'" Include="$(CommonPath)/System/SR.cs">
      <Visible>true</Visible>
      <Link>Resources/Common/SR.cs</Link>
    </Compile>
    <Compile Condition="'$(MSBuildProjectExtension)' == '.vbproj'" Include="$(CommonPath)/System/SR.vb">
      <Visible>true</Visible>
      <Link>Resources/Common/SR.vb</Link>
    </Compile>
  </ItemGroup>
</Project>
