* xbuild/Microsoft.Common.targets (DeployOutputFiles):
[mono.git] / mcs / tools / xbuild / xbuild / Microsoft.Common.targets
index 59fa40cf89c26b6b1c50731db25009d9074020cf..9d0c322d46b3e4c789486e3f8283bb23563fb5ef 100644 (file)
                <OutputPath Condition="'$(OutputPath)' != '' and !HasTrailingSlash('$(OutputPath)')">$(OutputPath)\</OutputPath> 
                <OutputPath Condition=" '$(Platform)'=='' and '$(Configuration)'=='' and '$(OutputPath)'=='' ">bin\Debug\</OutputPath>
                <WarningLevel Condition="'$(WarningLevel)' == ''" >2</WarningLevel>
+               <TargetFrameworkVersion Condition="'$(TargetFrameworkVersion)' == ''">v2.0</TargetFrameworkVersion>
        </PropertyGroup>
 
        <PropertyGroup>
                <OutDir Condition="'$(OutDir)' == ''">$(OutputPath)</OutDir>
                <OutDir Condition="'$(OutDir)' != '' and !HasTrailingSlash('$(OutDir)')">$(OutDir)\</OutDir>
 
+               <_OriginalConfiguration>$(Configuration)</_OriginalConfiguration>
                <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
                <ConfigurationName Condition="'$(ConfigurationName)' == ''">$(Configuration)</ConfigurationName>
 
+               <_OriginalPlatform>$(Platform)</_OriginalPlatform>
                <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
                <PlatformName Condition="'$(PlatformName)' == ''">$(Platform)</PlatformName>
        </PropertyGroup>
        </PropertyGroup>
 
        <Target Name="_ValidateEssentialProperties">
+               <Error Condition=" '$(OutputPath)' == '' and '$(SkipInvalidConfigurations)' != 'true'"
+                       Text="'OutputPath' property is not set for this project. Usually this is caused by invalid Configuration/Platform combination. Original values: Configuration: $(_OriginalConfiguration) Platform: $(_OriginalPlatform)."/>
+
+               <Warning Condition=" '$(OutputPath)' == '' and '$(SkipInvalidConfigurations)' == 'true'"
+                       Text="'OutputPath' property is not set for this project. Usually this is caused by invalid Configuration/Platform combination. Original values: Configuration: $(_OriginalConfiguration) Platform: $(_OriginalPlatform)."/>
+
                <!-- If OutDir is specified via the command line, then the earlier check
                     to add a trailing slash won't have any affect, so error here. -->
                <Error
                />
 
                <GetFrameworkPath>
-                       <Output TaskParameter="Path" PropertyName="TargetFrameworkPath"/>
+                       <Output Condition="'$(TargetFrameworkVersion)' == 'v3.5'"
+                               TaskParameter="FrameworkVersion35Path"
+                               ItemName="TargetFrameworkDirectories"/>
+                       <Output Condition="'$(TargetFrameworkVersion)' == 'v3.0' or '$(TargetFrameworkVersion)' == 'v3.5'" 
+                               TaskParameter="FrameworkVersion30Path"
+                               ItemName="TargetFrameworkDirectories"/>
+                       <Output Condition="'$(TargetFrameworkVersion)' == 'v2.0' or '$(TargetFrameworkVersion)' == 'v3.0' or '$(TargetFrameworkVersion)' == 'v3.5'" 
+                               TaskParameter="FrameworkVersion20Path"
+                               ItemName="TargetFrameworkDirectories"/>
                </GetFrameworkPath>
        </Target>
 
                        AssemblyFiles="@(ChildProjectReferences)"
                        SearchPaths="$(AssemblySearchPaths)"
                        CandidateAssemblyFiles="@(Content);@(None)"
-                       TargetFrameworkDirectories="$(TargetFrameworkPath)"
+                       TargetFrameworkDirectories="@(TargetFrameworkDirectories)"
                        AllowedAssemblyExtensions="$(AllowedReferenceAssemblyFileExtensions)"
                        AllowedRelatedFileExtensions="$(AllowedReferenceRelatedFileExtensions)"
                        FindDependencies="true"
                >
                        <Output TaskParameter="ResolvedFiles" ItemName="ResolvedFiles"/>
                        <Output TaskParameter="ResolvedFiles" ItemName="ReferencePath"/>
-                       <Output TaskParameter="ResolvedDependencyFiles" ItemName="_ResolveAssemblyReferenceResolvedFiles"/>
+                       <Output TaskParameter="ResolvedDependencyFiles" ItemName="_ResolvedDependencyFiles"/>
                        <Output TaskParameter="RelatedFiles" ItemName="_ReferenceRelatedPaths"/>
                        <Output TaskParameter="SatelliteFiles" ItemName="ReferenceSatellitePaths"/>
                        <Output TaskParameter="CopyLocalFiles" ItemName="ReferenceCopyLocalPaths"/>
 
        </Target>
 
+       <!-- Split projects into 2 lists
+               ProjectReferenceWithConfigurationExistent: Projects existent on disk
+               ProjectReferenceWithConfigurationNonExistent: Projects non-existent on disk -->
 
-       <Target
-               Name="ResolveProjectReferences"
-               DependsOnTargets="AssignProjectConfigurations"
-       >
-               <!-- Build only project files that can be found on disk, ignore others -->
+       <Target Name="SplitProjectReferencesByExistent"
+               DependsOnTargets="AssignProjectConfigurations">
 
-               <CreateItem Include="@(ProjectReferenceWithConfiguration)">
+               <CreateItem Include="@(ProjectReferenceWithConfiguration)" Condition="'@(ProjectReferenceWithConfiguration)' != ''">
                        <Output TaskParameter="Include" ItemName="ProjectReferenceWithConfigurationExistent"
                                Condition="Exists ('%(ProjectReferenceWithConfiguration.Identity)')"/>
 
                        <Output TaskParameter="Include" ItemName="ProjectReferenceWithConfigurationNonExistent"
                                Condition="!Exists ('%(ProjectReferenceWithConfiguration.Identity)')"/>
                </CreateItem>
+       </Target>
 
+       <Target
+               Name="ResolveProjectReferences"
+               DependsOnTargets="SplitProjectReferencesByExistent"
+       >
                <!-- If building from a .sln.proj or from IDE, then referenced projects have already
                     been built, so just get the target paths -->
                <MSBuild
                        <Output TaskParameter="TargetOutputs" ItemName="ChildProjectReferences" />
                </MSBuild>
 
-               <!-- Emit warning about missing project files -->
                <Warning Text="Referenced Project %(ProjectReferenceWithConfigurationNonExistent.Identity) not found, ignoring."
                         Condition="'@(ProjectReferenceWithConfigurationNonExistent)' != ''"/>
        </Target>
                        ResolveReferences;
                        CopyFilesMarkedCopyLocal;
                        BuildResources;
+                       CompileLicxFiles;
                        Compile;
                        PrepareForRun;
                        DeployOutputFiles;
        </Target>
 
        <Target Name="SplitResourcesByCulture" DependsOnTargets="AssignTargetPaths">
-               <AssignCulture Files="@(EmbeddedResourceWithTargetPath)">
+               <!-- Extract .licx files into @(LicxFiles) -->
+               <CreateItem Include="@(EmbeddedResourceWithTargetPath)" Condition="'%(Extension)' == '.licx'">
+                       <Output TaskParameter="Include" ItemName="LicxFiles"/>
+               </CreateItem>
+
+               <!-- Split *remaining* resource files into various groups.. -->
+               <AssignCulture Files="@(EmbeddedResourceWithTargetPath)" Condition="'%(Extension)' != '.licx'">
                        <Output TaskParameter="AssignedFilesWithNoCulture" ItemName="ResourcesWithNoCulture"/>
                        <Output TaskParameter="AssignedFilesWithCulture" ItemName="ResourcesWithCulture"/>
                </AssignCulture>
                        DelaySign="$(DelaySign)"
                        EmbedResources = "@(ManifestResourceWithCulture);@(ManifestNonResxWithCultureOnDisk)"
                        KeyFile="$(KeyOriginatorFile)"
+                       ToolExe="$(AlToolExe)"
+                       ToolPath="$(AlToolPath)"
                        OutputAssembly = "$(IntermediateOutputPath)%(Culture)\$(AssemblyName).resources.dll" >
                        <Output TaskParameter="OutputAssembly" ItemName="FileWrites"/>
                </AL>
                </CreateItem>
        </Target>
 
+       <PropertyGroup>
+               <CompileLicxFilesDependsOn></CompileLicxFilesDependsOn>
+       </PropertyGroup>
+
+       <Target Name = "CompileLicxFiles"
+               Condition = "'@(LicxFiles)' != ''"
+               DependsOnTargets = "$(CompileLicxFilesDependsOn)"
+               Outputs = "$(IntermediateOutputPath)$(TargetFileName).licenses">
+               <LC
+                       Sources = "@(LicxFiles)"
+                       LicenseTarget = "$(TargetFileName)"
+                       OutputDirectory = "$(IntermediateOutputPath)"
+                       OutputLicense = "$(IntermediateOutputPath)$(TargetFileName).licenses"
+                       ReferencedAssemblies = "@(ReferencePath);@(_ResolvedDependencyFiles)"
+                       ToolPath = "$(LCToolPath)"
+                       ToolExe = "$(LCToolExe)">
+
+                       <Output TaskParameter="OutputLicense" ItemName="CompiledLicenseFile"/>
+                       <Output TaskParameter="OutputLicense" ItemName="FileWrites"/>
+               </LC>
+       </Target>
+
        <!-- Assign target paths to files that will need to be copied along with the project -->
        <Target Name = "AssignTargetPaths">
                <AssignTargetPath Files="@(None)" RootFolder="$(MSBuildProjectDirectory)">
 
                <Copy 
                        SourceFiles="$(IntermediateOutputPath)$(AssemblyName)$(TargetExt).mdb"
-                       Condition="Exists('$(IntermediateOutputPath)$(AssemblyName)$(TargetExt).mdb')"
+                       Condition="'$(OutDir)' != '' and Exists('$(IntermediateOutputPath)$(AssemblyName)$(TargetExt).mdb')"
                        DestinationFolder="$(OutDir)"
                        SkipUnchangedFiles="true" >
                        <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
                </Copy>
 
-               <Copy SourceFiles="@(IntermediateAssembly)" DestinationFolder="$(OutDir)" SkipUnchangedFiles="true">
+               <Copy SourceFiles="@(IntermediateAssembly)" Condition="'$(OutDir)' != ''" DestinationFolder="$(OutDir)" SkipUnchangedFiles="true">
                        <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
                </Copy>
 
 
        <Target Name="GetCopyToOutputDirectoryItems"
                Outputs="@(AllItemsFullPathWithTargetPath)"
-               DependsOnTargets="AssignTargetPaths">
+               DependsOnTargets="AssignTargetPaths;SplitProjectReferencesByExistent">
 
                <!-- FIXME: handle .vcproj
                     FIXME: Private ProjectReferences are honored only in 3.5
 
        <!-- this gets invoked in two cases, from CoreBuildDependsOn, if the build completes
             successfully, OR from OnError in CoreBuild, if the build failed and $(RunPostBuildEvent)
-            is 'Always' or 'OnOutputUpdated' -->
+            is 'Always' or 'OnOutputUpdated'. Invoke $(PostBuildEvent) if its either Empty (== OnBuildSuccess)
+            or OnBuildSuccess or Always OR (OnOutputUpdated and output assembly got updated) -->
        <Target Name="PostBuildEvent"
                Condition="'$(PostBuildEvent)' != '' and
-                       ('$(RunPostBuildEvent)' == 'Always' or '$(RunPostBuildEvent)' == 'OnBuildSuccess' or
-                         ('$(RunPostBuildEvent)' == 'OnOutputUpdated' and
-                           '$(_AssemblyModifiedTimeBeforeCompile)' != '$(_AssemblyModifiedTimeAfterCompile)')
-                       )"
+                       ('$(RunPostBuildEvent)' != 'OnOutputUpdated' or
+                         '$(_AssemblyModifiedTimeBeforeCompile)' != '$(_AssemblyModifiedTimeAfterCompile)')"
                DependsOnTargets="$(PostBuildEventDependsOn)">
 
                <Exec WorkingDirectory="$(OutDir)" Command="$(PostBuildEvent)" />
        <!-- Clean -->
        <Target Name="_RecordCleanFile"
                DependsOnTargets="_GetCompileOutputsForClean">
+
+               <!-- add to list of previous writes for this platform/config -->
+
+               <ReadLinesFromFile File="$(IntermediateOutputPath)$(CleanFile)">
+                       <Output TaskParameter="Lines" ItemName="PreviousFileWrites"/>
+               </ReadLinesFromFile>
+
+               <RemoveDuplicates Inputs="@(PreviousFileWrites);@(FileWrites->'%(FullPath)')">
+                       <Output TaskParameter="Filtered" ItemName="CombinedFileWrites"/>
+               </RemoveDuplicates>
+
                <WriteLinesToFile
-                       File="$(BaseIntermediateOutputPath)$(CleanFile)"
-                       Lines="@(FileWrites->'%(FullPath)')"
+                       File="$(IntermediateOutputPath)$(CleanFile)"
+                       Lines="@(CombinedFileWrites)"
                        Overwrite="true"/>
        </Target>
 
        </PropertyGroup>
 
        <Target Name="_GetCompileOutputsForClean">
+               <!-- assembly and debug file in the *intermediate output path* -->
                <CreateItem Include="@(IntermediateAssembly)" Condition="Exists('@(IntermediateAssembly)')">
                        <Output TaskParameter="Include" ItemName="FileWrites"/>
                </CreateItem>
        <!-- Get the list of files written, for clean -->
        <Target Name="_GetCleanFileWrites"
                DependsOnTargets="_GetCompileOutputsForClean">
-               <ReadLinesFromFile File="$(BaseIntermediateOutputPath)$(CleanFile)">
-                       <Output TaskParameter="Lines" ItemName="FileWrites"/>
+               <ReadLinesFromFile File="$(IntermediateOutputPath)$(CleanFile)">
+                       <Output TaskParameter="Lines" ItemName="PreviousFileWrites"/>
                </ReadLinesFromFile>
        </Target>
 
        <Target Name="AfterClean" />
 
        <Target Name="CoreClean" DependsOnTargets="_GetCleanFileWrites">
-               <Delete Files="@(FileWrites)" TreatErrorsAsWarnings="true"/>
+               <Delete Files="@(PreviousFileWrites);@(FileWrites)" TreatErrorsAsWarnings="true"/>
+
+               <!-- all previous files written for this platform/config have been deleted,
+                    we can safely remove the file list now -->
+               <Delete Files="$(IntermediateOutputPath)$(CleanFile)" TreatErrorsAsWarnings="true" />
        </Target>
 
 </Project>