DirectXTex/build/SetupBWOI.targets

199 lines
10 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="SetupVCTargets" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
Copyright (c) Microsoft Corporation.
Licensed under the MIT License.
-->
<PropertyGroup>
<GDKEditionNumber Condition="$(GDKEditionNumber)==''">999999</GDKEditionNumber>
<ExtractedFolder Condition="'$(ExtractedFolder)'==''">C:\xtracted\</ExtractedFolder>
<ExtractedFolder Condition="!HasTrailingSlash('$(ExtractedFolder)')">$(ExtractedFolder)\</ExtractedFolder>
</PropertyGroup>
<!--
A list of VCTargets folders that we expect to exist after copying the BWOI VS files
If any of these folders is not present then we assume that the VCTargets has not been setup
-->
<ItemGroup>
<BWOIVCFolders Include="$(ExtractedFolder)VCTargets160\" />
<BWOIVCFolders Include="$(ExtractedFolder)VCTargets160\Platforms\" />
<BWOIVCFolders Include="$(ExtractedFolder)VCTargets160\Platforms\gaming.desktop.x64" />
<BWOIVCFolders Include="$(ExtractedFolder)VCTargets160\Platforms\gaming.xbox.xboxone.x64" />
</ItemGroup>
<ItemGroup Condition="'$(VisualStudioVersion)' == '17.0'">
<BWOIVCFolders Include="$(ExtractedFolder)VCTargets170\" />
<BWOIVCFolders Include="$(ExtractedFolder)VCTargets170\Platforms\" />
<BWOIVCFolders Include="$(ExtractedFolder)VCTargets170\Platforms\gaming.desktop.x64" />
<BWOIVCFolders Include="$(ExtractedFolder)VCTargets170\Platforms\gaming.xbox.xboxone.x64" />
</ItemGroup>
<!--
Microsoft GDK NuGets for 2203 or later only support 64-bit MSBuild
-->
<UsingTask TaskName="Is64BitMSBuild" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<SixtyFourBit ParameterType="System.Boolean" Output="true" />
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
<![CDATA[
SixtyFourBit = (IntPtr.Size == 8) ? true : false;
]]>
</Code>
</Task>
</UsingTask>
<Target Name="_CheckMSBuild64">
<Is64BitMSBuild>
<Output TaskParameter="SixtyFourBit" PropertyName="_SixtyFourBit" />
</Is64BitMSBuild>
<Error Condition="'$(_SixtyFourBit)'=='false'"
Text="##[error]The 64-bit version of MSBuild is required to support NuGet GDK packages." />
</Target>
<Target Name="_ValidateGDK">
<Error Condition="'$(GDKEditionNumber)'=='999999'" Text="##[error]GDKEditionNumber was not set!" />
</Target>
<!--
Determine whether the VC Targets has already been setup
-->
<Target Name="_ProbeForExtractedVCTargets"
Outputs="%(BWOIVCFolders.Identity)">
<Error Condition="'$(ExtractedFolder)'==''"
Text="##[error]ExtractedFolder property is required" />
<PropertyGroup>
<_BWOIFolder>%(BWOIVCFolders.Identity)</_BWOIFolder>
</PropertyGroup>
<ItemGroup>
<_MissingBWOIVCFolders Condition="'$(ForceVCTargetsBWOIRefresh)'=='true' or !Exists($(_BWOIFolder))" Include="$(_BWOIFolder)" />
</ItemGroup>
<PropertyGroup>
<_ExtractedOutOfDate Condition="'@(_MissingBWOIVCFolders)' != ''">true</_ExtractedOutOfDate>
<_BWOIFolder />
</PropertyGroup>
</Target>
<Target Name="_CreateVCTargetsFolder"
Condition="'@(_MissingBWOIVCFolders)' != ''">
<PropertyGroup>
<_VSFolder Condition="'$(VisualStudioVersion)' == '17.0'">VS2022</_VSFolder>
<_VSFolder Condition="'$(VisualStudioVersion)' == '16.0'">VS2019</_VSFolder>
</PropertyGroup>
<Error Condition="'$(_VSFolder)'==''"
Text="##[error]Only supports VS 2019 or VS 2022" />
<!-- Set up files for v142 platform toolset projects -->
<ItemGroup>
<SourceVCTargetsFilesV160 Include="$(MSBuildExtensionsPath32)\Microsoft\VC\v160\**" />
</ItemGroup>
<ItemGroup Condition="Exists('$(ExtractedFolder)Microsoft.GDK.Xbox.XboxOne\native\$(GDKEditionNumber)\xbox\build')">
<GDKVCTargetsFilesV160 Include="$(ExtractedFolder)Microsoft.GDK.Xbox.XboxOne\native\$(GDKEditionNumber)\xbox\build\$(_VSFolder)\pc\v160\**" />
<GDKVCTargetsFilesV160 Include="$(ExtractedFolder)Microsoft.GDK.Xbox.XboxOne\native\$(GDKEditionNumber)\xbox\build\$(_VSFolder)\gen8\v160\**" />
<GDKVCTargetsFilesV160 Include="$(ExtractedFolder)Microsoft.GDK.Xbox.XboxOne\native\$(GDKEditionNumber)\xbox\build\$(_VSFolder)\gen9\v160\**" />
</ItemGroup>
<ItemGroup Condition="Exists('$(ExtractedFolder)Microsoft.GDK.Xbox.XboxSeriesX_S\native\$(GDKEditionNumber)\xbox\build')">
<GDKVCTargetsFilesV160 Include="$(ExtractedFolder)Microsoft.GDK.Xbox.XboxSeriesX_S\native\$(GDKEditionNumber)\xbox\build\$(_VSFolder)\pc\v160\**" />
<GDKVCTargetsFilesV160 Include="$(ExtractedFolder)Microsoft.GDK.Xbox.XboxSeriesX_S\native\$(GDKEditionNumber)\xbox\build\$(_VSFolder)\gen8\v160\**" />
<GDKVCTargetsFilesV160 Include="$(ExtractedFolder)Microsoft.GDK.Xbox.XboxSeriesX_S\native\$(GDKEditionNumber)\xbox\build\$(_VSFolder)\gen9\v160\**" />
</ItemGroup>
<Error Condition="@(GDKVCTargetsFilesV160->Count()) == 0"
Text="##[error]No MSBuild v142 files found in NuGets. Check GDKEditionNumber."/>
<Copy SkipUnchangedFiles="true" SourceFiles="@(SourceVCTargetsFilesV160)" DestinationFolder="$(ExtractedFolder)VCTargets160\%(RecursiveDir)/" />
<Copy SourceFiles="@(GDKVCTargetsFilesV160)" DestinationFolder="$(ExtractedFolder)VCTargets160\%(RecursiveDir)/" />
<!-- Set up files for v143 platform toolset projects -->
<ItemGroup Condition="'$(VisualStudioVersion)' == '17.0'">
<SourceVCTargetsFilesV170 Include="$(MSBuildExtensionsPath32)\Microsoft\VC\v170\**" />
</ItemGroup>
<ItemGroup Condition="'$(VisualStudioVersion)' == '17.0' and Exists('$(ExtractedFolder)Microsoft.GDK.Xbox.XboxOne\native\$(GDKEditionNumber)\xbox\build')">
<GDKVCTargetsFilesV170 Include="$(ExtractedFolder)Microsoft.GDK.Xbox.XboxOne\native\$(GDKEditionNumber)\xbox\build\$(_VSFolder)\pc\v170\**" />
<GDKVCTargetsFilesV170 Include="$(ExtractedFolder)Microsoft.GDK.Xbox.XboxOne\native\$(GDKEditionNumber)\xbox\build\$(_VSFolder)\gen8\v170\**" />
<GDKVCTargetsFilesV170 Include="$(ExtractedFolder)Microsoft.GDK.Xbox.XboxOne\native\$(GDKEditionNumber)\xbox\build\$(_VSFolder)\gen9\v170\**" />
</ItemGroup>
<ItemGroup Condition="'$(VisualStudioVersion)' == '17.0' and Exists('$(ExtractedFolder)Microsoft.GDK.Xbox.XboxSeriesX_S\native\$(GDKEditionNumber)\xbox\build')">
<GDKVCTargetsFilesV170 Include="$(ExtractedFolder)Microsoft.GDK.Xbox.XboxSeriesX_S\native\$(GDKEditionNumber)\xbox\build\$(_VSFolder)\pc\v170\**" />
<GDKVCTargetsFilesV170 Include="$(ExtractedFolder)Microsoft.GDK.Xbox.XboxSeriesX_S\native\$(GDKEditionNumber)\xbox\build\$(_VSFolder)\gen8\v170\**" />
<GDKVCTargetsFilesV170 Include="$(ExtractedFolder)Microsoft.GDK.Xbox.XboxSeriesX_S\native\$(GDKEditionNumber)\xbox\build\$(_VSFolder)\gen9\v170\**" />
</ItemGroup>
<Error Condition="'$(VisualStudioVersion)' == '17.0' AND @(GDKVCTargetsFilesV170->Count()) == 0"
Text="##[error]No MSBuild v143 files found in NuGets. Check GDKEditionNumber."/>
<Copy SkipUnchangedFiles="true" SourceFiles="@(SourceVCTargetsFilesV170)" DestinationFolder="$(ExtractedFolder)VCTargets170\%(RecursiveDir)/" />
<Copy SourceFiles="@(GDKVCTargetsFilesV170)" DestinationFolder="$(ExtractedFolder)VCTargets170\%(RecursiveDir)/" />
</Target>
<Target Name="_CreateVCTargetsFolderOld"
Condition="'@(_MissingBWOIVCFolders)' != ''">
<Error Condition="!Exists('$(ExtractedFolder)Microsoft.GDK.PC')"
Text="##[error]NuGet package Microsoft.GDK.PC not found in $(ExtractedFolder)" />
<PropertyGroup>
<_VSFolder Condition="'$(VisualStudioVersion)' == '17.0'">VS2022</_VSFolder>
<_VSFolder Condition="'$(VisualStudioVersion)' == '16.0'">VS2019</_VSFolder>
</PropertyGroup>
<Error Condition="'$(_VSFolder)'==''"
Text="##[error]Only supports VS 2019 or VS 2022" />
<!-- Set up files for v142 platform toolset projects -->
<ItemGroup>
<SourceVCTargetsFilesV160 Include="$(MSBuildExtensionsPath32)\Microsoft\VC\v160\**" />
</ItemGroup>
<ItemGroup>
<GDKVCTargetsFilesV160 Include="$(ExtractedFolder)Microsoft.GDK.PC\native\$(GDKEditionNumber)\GRDK\$(_VSFolder)\flatDeployment\MSBuild\Microsoft\VC\v160\**" />
<GDKVCTargetsFilesV160 Include="$(ExtractedFolder)Microsoft.GDK.Xbox\native\$(GDKEditionNumber)\GXDK\$(_VSFolder)\flatDeployment\MSBuild\Microsoft\VC\v160\**" />
</ItemGroup>
<Error Condition="@(GDKVCTargetsFilesV160->Count()) == 0"
Text="##[error]No MSBuild v142 files found in NuGets. Check GDKEditionNumber."/>
<Copy SkipUnchangedFiles="true" SourceFiles="@(SourceVCTargetsFilesV160)" DestinationFolder="$(ExtractedFolder)VCTargets160\%(RecursiveDir)/" />
<Copy SourceFiles="@(GDKVCTargetsFilesV160)" DestinationFolder="$(ExtractedFolder)VCTargets160\%(RecursiveDir)/" />
<!-- Set up files for v143 platform toolset projects -->
<ItemGroup Condition="'$(VisualStudioVersion)' == '17.0'">
<SourceVCTargetsFilesV170 Include="$(MSBuildExtensionsPath32)\Microsoft\VC\v170\**" />
</ItemGroup>
<ItemGroup Condition="'$(VisualStudioVersion)' == '17.0'">
<GDKVCTargetsFilesV170 Include="$(ExtractedFolder)Microsoft.GDK.PC\native\$(GDKEditionNumber)\GRDK\$(_VSFolder)\flatDeployment\MSBuild\Microsoft\VC\v170\**" />
<GDKVCTargetsFilesV170 Include="$(ExtractedFolder)Microsoft.GDK.Xbox\native\$(GDKEditionNumber)\GXDK\$(_VSFolder)\flatDeployment\MSBuild\Microsoft\VC\v170\**" />
</ItemGroup>
<Error Condition="'$(VisualStudioVersion)' == '17.0' AND @(GDKVCTargetsFilesV170->Count()) == 0"
Text="##[error]No MSBuild v143 files found in NuGets. Check GDKEditionNumber."/>
<Copy SkipUnchangedFiles="true" SourceFiles="@(SourceVCTargetsFilesV170)" DestinationFolder="$(ExtractedFolder)VCTargets170\%(RecursiveDir)/" />
<Copy SourceFiles="@(GDKVCTargetsFilesV170)" DestinationFolder="$(ExtractedFolder)VCTargets170\%(RecursiveDir)/" />
</Target>
<PropertyGroup>
<SetupTargets></SetupTargets>
<SetupTargets Condition="Exists('$(ExtractedFolder)Microsoft.GDK.Core')">;_CreateVCTargetsFolder</SetupTargets>
<SetupTargets Condition="'$(SetupTargets)'=='' AND Exists('$(ExtractedFolder)Microsoft.GDK.Xbox')">;_CreateVCTargetsFolderOld</SetupTargets>
</PropertyGroup>
<Target Name="SetupVCTargets" DependsOnTargets="_CheckMSBuild64;_ValidateGDK;_ProbeForExtractedVCTargets$(SetupTargets)" />
</Project>