<!--
***********************************************************************************************
Microsoft.VisualBasic.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 VB .NET projects.
For example, it contains the step that actually calls the VB 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">

    <PropertyGroup>
        <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildToolsPath)\Microsoft.VisualBasic.targets</MSBuildAllProjects>
        <DefaultLanguageSourceExtension>.vb</DefaultLanguageSourceExtension>
        <Language>VB</Language>
    </PropertyGroup>

    <!--
    The CreateManifestResourceNames target create the manifest resource names from the .RESX
    files.      
    
        [IN]
        @(EmbeddedResource) - The list of EmbeddedResource items that have been pre-processed to add metadata about resource type
                              Expected Metadata "Type" can either be "Resx" or "Non-Resx"

        [OUT]
        @(EmbeddedResource) - EmbeddedResource items with metadata    

    For VB applications the transformation is like:

        Resources1.resx => RootNamespace.Resources1 => Build into main assembly
        SubFolder\Resources1.resx => RootNamespace.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="'@(EmbeddedResource)' != ''"
        DependsOnTargets="$(CreateManifestResourceNamesDependsOn)"
        >
        
        <ItemGroup>
            <_Temporary Remove="@(_Temporary)" />
        </ItemGroup>
        
        <!-- Create manifest names for culture and non-culture Resx files, and for non-culture Non-Resx resources -->
        <CreateVisualBasicManifestResourceName
              ResourceFiles="@(EmbeddedResource)"
              RootNamespace="$(RootNamespace)"
              Condition="'%(EmbeddedResource.ManifestResourceName)' == '' and ('%(EmbeddedResource.WithCulture)' == 'false' or '%(EmbeddedResource.Type)' == 'Resx')">

            <Output TaskParameter="ResourceFilesWithManifestResourceNames" ItemName="_Temporary" />

        </CreateVisualBasicManifestResourceName>
        
        <!-- Create manifest names for all culture non-resx resources -->
        <CreateVisualBasicManifestResourceName
              ResourceFiles="@(EmbeddedResource)"
              RootNamespace="$(RootNamespace)"
              PrependCultureAsDirectory="false"              
              Condition="'%(EmbeddedResource.ManifestResourceName)' == '' and '%(EmbeddedResource.WithCulture)' == 'true' and '%(EmbeddedResource.Type)' == 'Non-Resx'">

            <Output TaskParameter="ResourceFilesWithManifestResourceNames" ItemName="_Temporary" />

        </CreateVisualBasicManifestResourceName>

        <ItemGroup>
            <EmbeddedResource Remove="@(EmbeddedResource)" Condition="'%(EmbeddedResource.ManifestResourceName)' == ''"/>
            <EmbeddedResource Include="@(_Temporary)" />
            <_Temporary Remove="@(_Temporary)" />
        </ItemGroup>
      
    </Target>

    <PropertyGroup>
        <FinalDefineConstants>CONFIG=&quot;$(Configuration)&quot;</FinalDefineConstants>
        <FinalDefineConstants Condition=" '$(DefineDebug)' == 'true' ">$(FinalDefineConstants),DEBUG=-1</FinalDefineConstants>
        <FinalDefineConstants Condition=" '$(DefineTrace)' == 'true' ">$(FinalDefineConstants),TRACE=-1</FinalDefineConstants>
        <FinalDefineConstants Condition=" '$(MyType)' != '' ">$(FinalDefineConstants),_MyType=&quot;$(MyType)&quot;</FinalDefineConstants>
        <FinalDefineConstants Condition=" '$(Platform)' != '' ">$(FinalDefineConstants),PLATFORM=&quot;$(Platform)&quot;</FinalDefineConstants>
        <FinalDefineConstants Condition=" '$(Platform)' == '' ">$(FinalDefineConstants),PLATFORM=&quot;AnyCPU&quot;</FinalDefineConstants>
        <FinalDefineConstants Condition=" '$(DefineConstants)' != '' ">$(FinalDefineConstants),$(DefineConstants)</FinalDefineConstants>

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

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

    <PropertyGroup>
        <CoreCompileDependsOn>_ComputeNonExistentFileProperty</CoreCompileDependsOn>
    </PropertyGroup>
    <Target
        Name="CoreCompile"
        Inputs="$(MSBuildAllProjects);
                @(Compile);                             
                @(_CoreCompileResourceInputs);
                $(ApplicationIcon);
                $(AssemblyOriginatorKeyFile);              
                @(ReferencePath);
                @(CompiledLicenseFile);
                @(EmbeddedDocumentation);
                $(Win32Resource);
                $(Win32Manifest);
                @(CustomAdditionalCompileInputs)"
        Outputs="@(DocFileItem);
                 @(IntermediateAssembly);
                 @(_DebugSymbolsIntermediatePath);
                 $(NonExistentFile);
                 @(CustomAdditionalCompileOutputs)"
        DependsOnTargets="$(CoreCompileDependsOn)"
    >
        <PropertyGroup>
            <_NoWarnings Condition=" '$(WarningLevel)' == '0' ">true</_NoWarnings>
            <_NoWarnings Condition=" '$(WarningLevel)' == '1' ">false</_NoWarnings>
        </PropertyGroup> 
        
        <!-- Condition is to filter out the _CoreCompileResourceInputs so that it doesn't pass in culture resources to the compiler -->
        <Vbc  Condition=" '%(_CoreCompileResourceInputs.WithCulture)' != 'true' "
              AdditionalLibPaths="$(AdditionalLibPaths)"
              AddModules="@(AddModules)"
              BaseAddress="$(BaseAddress)"          
              CodePage="$(CodePage)"
              DebugType="$(DebugType)"
              DefineConstants="$(FinalDefineConstants)"
              DelaySign="$(DelaySign)"
              DisabledWarnings="$(NoWarn)"
              DocumentationFile="@(DocFileItem)"
              EmitDebugInformation="$(DebugSymbols)"
              ErrorReport="$(ErrorReport)"
              FileAlignment="$(FileAlignment)"
              GenerateDocumentation="$(GenerateDocumentation)"
              Imports="@(Import)"
              KeyContainer="$(KeyContainerName)"
              KeyFile="$(KeyOriginatorFile)"
              MainEntryPoint="$(StartupObject)"
              ModuleAssemblyName="$(ModuleAssemblyName)"
              NoConfig="true"
              NoStandardLib="$(NoStdLib)"
              NoVBRuntimeReference="$(NoVBRuntimeReference)"
              NoWarnings="$(_NoWarnings)"
              NoWin32Manifest="$(NoWin32Manifest)"
              Optimize="$(Optimize)"
              OptionCompare="$(OptionCompare)"
              OptionExplicit="$(OptionExplicit)"
              OptionInfer="$(OptionInfer)"
              OptionStrict="$(OptionStrict)"
              OptionStrictType="$(OptionStrictType)" 
              OutputAssembly="@(IntermediateAssembly)"
              Platform="$(PlatformTarget)"
              References="@(ReferencePath)"
              RemoveIntegerChecks="$(RemoveIntegerChecks)"
              Resources="@(_CoreCompileResourceInputs);@(CompiledLicenseFile)"
              ResponseFiles="$(CompilerResponseFile)"
              RootNamespace="$(RootNamespace)"
              SdkPath="$(FrameworkPathOverride)"
              Sources="@(Compile)"
              TargetCompactFramework="$(TargetCompactFramework)"
              TargetType="$(OutputType)"
              ToolExe="$(VbcToolExe)"
              ToolPath="$(VbcToolPath)"
              TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
              UseHostCompilerIfAvailable="$(UseHostCompilerIfAvailable)"
              Utf8Output="$(Utf8Output)"
              Verbosity="$(VbcVerbosity)"
              WarningsAsErrors="$(WarningsAsErrors)"
              WarningsNotAsErrors="$(WarningsNotAsErrors)"
              Win32Icon="$(ApplicationIcon)"
              Win32Manifest="$(Win32Manifest)"              
              Win32Resource="$(Win32Resource)"
              />

              <ItemGroup>
                  <_CoreCompileResourceInputs Remove="@(_CoreCompileResourceInputs)" />                  
              </ItemGroup>              
              
    </Target>

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

</Project>
