<!--
***********************************************************************************************
Microsoft.CSharp.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.

This file defines the steps in the standard build process specific for C# .NET projects.
For example, it contains the step that actually calls the C# compiler.  The remainder
of the build process is defined in Microsoft.Common.targets, which is imported by 
this file.

Copyright (C) Microsoft Corporation. All rights reserved.
***********************************************************************************************
-->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <UsingTask TaskName="CreateCSharpManifestResourceName" AssemblyName="Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

    <PropertyGroup>
        <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildBinPath)\Microsoft.CSharp.targets</MSBuildAllProjects>
        <DefaultLanguageSourceExtension>.cs</DefaultLanguageSourceExtension>
        <Language>C#</Language>
    </PropertyGroup>

    <!--
    The CreateManifestResourceNames target create the manifest resource names from the .RESX
    files.

        [IN]
        @(ResxWithNoCulture) - The names the non-culture .RESX files.
        @(ResxWithCulture) - The names the culture .RESX files.
        @(NonResxWithNoCulture) - The names of the non-culture non-RESX files (like bitmaps, etc).
        @(NonResxWithCulture) - The names of the culture non-RESX files (like bitmaps, etc).

        [OUT]
        @(ManifestResourceWithNoCultureName) - The corresponding manifest resource name (.RESOURCE)
        @(ManifestResourceWithCultureName) - The corresponding manifest resource name (.RESOURCE)
        @(ManifestNonResxWithNoCulture) - The corresponding manifest resource name.
        @(ManifestNonResxWithCulture) - The corresponding manifest resource name.

    For C# applications the transformation is like:

        Resources1.resx => RootNamespace.Resources1 => Build into main assembly
        SubFolder\Resources1.resx => RootNamespace.SubFolder.Resources1 => Build into main assembly
        Resources1.fr.resx => RootNamespace.Resources1.fr => Build into satellite assembly
        Resources1.notaculture.resx => RootNamespace.Resources1.notaculture => Build into main assembly

    For other project systems, this transformation may be different.
    -->
    <PropertyGroup>
        <CreateManifestResourceNamesDependsOn></CreateManifestResourceNamesDependsOn>
    </PropertyGroup>
    <Target
        Name="CreateManifestResourceNames"
        Condition="'@(ResxWithNoCulture)@(ResxWithCulture)@(NonResxWithNoCulture)@(NonResxWithCulture)'!=''"
        DependsOnTargets="$(CreateManifestResourceNamesDependsOn)"
        >

        <!-- Create the target resource names for non-culture resx files. -->
        <CreateCSharpManifestResourceName Condition="'@(ResxWithNoCulture)'!=''"
              ResourceFiles="@(ResxWithNoCulture)"
              RootNamespace="$(RootNamespace)">

            <Output TaskParameter="ManifestResourceNames" ItemName="ManifestResourceWithNoCultureName"/>

        </CreateCSharpManifestResourceName>

        <!-- Create the target resource names for culture resx files. -->
        <CreateCSharpManifestResourceName Condition="'@(ResxWithCulture)'!=''"
              ResourceFiles="@(ResxWithCulture)"
              RootNamespace="$(RootNamespace)">

            <Output TaskParameter="ManifestResourceNames" ItemName="ManifestResourceWithCultureName"/>

        </CreateCSharpManifestResourceName>

        <!-- Create the target resource names for non-culture non-resx files. -->
        <CreateCSharpManifestResourceName Condition="'@(NonResxWithNoCulture)'!=''"
              ResourceFiles="@(NonResxWithNoCulture)"
              RootNamespace="$(RootNamespace)">

            <Output TaskParameter="ManifestResourceNames" ItemName="ManifestNonResxWithNoCulture"/>

        </CreateCSharpManifestResourceName>

        <!-- Create the target resource names for culture non-resx files. -->
        <CreateCSharpManifestResourceName Condition="'@(NonResxWithCulture)'!=''"
              ResourceFiles="@(NonResxWithCulture)"
              RootNamespace="$(RootNamespace)">

            <Output TaskParameter="ManifestResourceNames" ItemName="ManifestNonResxWithCulture"/>

        </CreateCSharpManifestResourceName>
    </Target>

    <PropertyGroup>
    
        <!-- If DebugSymbols is explicitly false, we definitely don't want symbols, so clear DebugType too-->
        <DebugType    Condition=" '$(DebugSymbols)' == 'false' "></DebugType>    

        <!-- "None" is not technically a valid DebugType, so we can't pass it in as such
             to the compiler.  So here, we modify the properties so they make sense. -->
        <DebugSymbols Condition=" '$(DebugType)' == 'none' ">false</DebugSymbols>
        <DebugType    Condition=" '$(DebugType)' == 'none' "></DebugType>    

        <_DisabledWarnings>$(NoWarn)</_DisabledWarnings>
        
        <!-- Provide a facility to override UseHostCompilerIfAvailable-->
        <UseHostCompilerIfAvailable Condition=" '$(UseHostCompilerIfAvailable)' == ''">true</UseHostCompilerIfAvailable>

    </PropertyGroup>

    <!-- These two compiler warnings are raised when a reference is bound to a different version
             than specified in the assembly reference version number.  MSBuild raises the same warning in this case,
             so the compiler warning would be redundant. -->
    <PropertyGroup Condition="('$(TargetFrameworkVersion)' != 'v1.0') and ('$(TargetFrameworkVersion)' != 'v1.1')">
        <_DisabledWarnings Condition="'$(_DisabledWarnings)' != ''">$(_DisabledWarnings);</_DisabledWarnings>
        <_DisabledWarnings>$(_DisabledWarnings)1701;1702</_DisabledWarnings>
    </PropertyGroup>    

    <ItemGroup>
        <DocFileItem Include="$(DocumentationFile)" Condition="'$(DocumentationFile)'!=''"/>
    </ItemGroup>

    <PropertyGroup>
        <CoreCompileDependsOn>_ComputeNonExistentFileProperty</CoreCompileDependsOn>
    </PropertyGroup>
    <Target
        Name="CoreCompile"
        Inputs="$(MSBuildAllProjects);
                @(Compile);
                @(ManifestResourceWithNoCulture);
                $(ApplicationIcon);
                $(AssemblyOriginatorKeyFile);
                @(ManifestNonResxWithNoCultureOnDisk);
                @(ReferencePath);
                @(CompiledLicenseFile);
                @(EmbeddedDocumentation);                
                @(CustomAdditionalCompileInputs)"
        Outputs="@(DocFileItem);
                 @(IntermediateAssembly);
                 $(NonExistentFile);
                 @(CustomAdditionalCompileOutputs)"
        DependsOnTargets="$(CoreCompileDependsOn)"
    >
       
        <Csc
              AdditionalLibPaths="$(AdditionalLibPaths)"
              AddModules="@(AddModules)"
              AllowUnsafeBlocks="$(AllowUnsafeBlocks)"
              BaseAddress="$(BaseAddress)"
              CheckForOverflowUnderflow="$(CheckForOverflowUnderflow)"
              CodePage="$(CodePage)"
              DebugType="$(DebugType)"
              DefineConstants="$(DefineConstants)"
              DelaySign="$(DelaySign)"
              DisabledWarnings="$(_DisabledWarnings)"
              DocumentationFile="@(DocFileItem)"
              EmitDebugInformation="$(DebugSymbols)"
              ErrorReport="$(ErrorReport)"
              FileAlignment="$(FileAlignment)"
              GenerateFullPaths="$(GenerateFullPaths)"
              KeyContainer="$(KeyContainerName)"
              KeyFile="$(KeyOriginatorFile)"
              LangVersion="$(LangVersion)"
              MainEntryPoint="$(StartupObject)"
              ModuleAssemblyName="$(ModuleAssemblyName)"
              NoConfig="true"
              NoLogo="$(NoLogo)"
              NoStandardLib="$(NoStdLib)"
              Optimize="$(Optimize)"
              OutputAssembly="@(IntermediateAssembly)"
              PdbFile="$(PdbFile)" 
              Platform="$(PlatformTarget)"
              References="@(ReferencePath)"
              Resources="@(ManifestResourceWithNoCulture);@(ManifestNonResxWithNoCultureOnDisk);@(CompiledLicenseFile)"
              ResponseFiles="$(CompilerResponseFile)"
              Sources="@(Compile)"
              TargetType="$(OutputType)"
              ToolPath="$(CscToolPath)"
              TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
              UseHostCompilerIfAvailable="$(UseHostCompilerIfAvailable)"
              Utf8Output="$(Utf8Output)"
              WarningLevel="$(WarningLevel)"
              WarningsAsErrors="$(WarningsAsErrors)"
              WarningsNotAsErrors="$(WarningsNotAsErrors)"
              Win32Icon="$(ApplicationIcon)"
              Win32Resource="$(Win32Resource)"
              />

    </Target>

    <Import Project="Microsoft.Common.targets" />

</Project>
