| 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
| 3 | <PropertyGroup> |
| 4 | <WslcPlatform Condition="'$(WslcPlatform)' == ''">$(Platform)</WslcPlatform> |
| 5 | <_wslcIsInvalidPlatform Condition="'$(WslcPlatform)' != 'x64' and '$(WslcPlatform)' != 'arm64'">true</_wslcIsInvalidPlatform> |
| 6 | <!-- Set to false to suppress the C++/WinRT winmd reference and activation manifest injection. --> |
| 7 | <WslcEnableCppWinRT Condition="'$(WslcEnableCppWinRT)' == ''">true</WslcEnableCppWinRT> |
| 8 | </PropertyGroup> |
| 9 | |
| 10 | <ItemDefinitionGroup> |
| 11 | <ClCompile> |
| 12 | <AdditionalIncludeDirectories> |
| 13 | $(MSBuildThisFileDirectory)..\..\include; |
| 14 | %(AdditionalIncludeDirectories) |
| 15 | </AdditionalIncludeDirectories> |
| 16 | </ClCompile> |
| 17 | <Link> |
| 18 | <AdditionalDependencies> |
| 19 | wslcsdk.lib; |
| 20 | %(AdditionalDependencies) |
| 21 | </AdditionalDependencies> |
| 22 | <AdditionalLibraryDirectories> |
| 23 | $(MSBuildThisFileDirectory)..\..\runtimes\win-$(WslcPlatform); |
| 24 | %(AdditionalLibraryDirectories) |
| 25 | </AdditionalLibraryDirectories> |
| 26 | </Link> |
| 27 | </ItemDefinitionGroup> |
| 28 | |
| 29 | <!-- Inject the activatable class manifest so RoGetActivationFactory resolves wslcsdk.dll |
| 30 | without requiring COM registration or renaming the DLL to match the namespace. --> |
| 31 | <ItemDefinitionGroup Condition="'$(WslcEnableCppWinRT)' == 'true' and '$(ConfigurationType)' != 'StaticLibrary'"> |
| 32 | <Manifest> |
| 33 | <AdditionalManifestFiles>$(MSBuildThisFileDirectory)..\..\manifests\Microsoft.WSL.Containers.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> |
| 34 | </Manifest> |
| 35 | </ItemDefinitionGroup> |
| 36 | |
| 37 | <ItemGroup> |
| 38 | <ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win-$(WslcPlatform)\native\wslcsdk.dll" /> |
| 39 | <Reference Include="Microsoft.WSL.Containers" Condition="'$(WslcEnableCppWinRT)' == 'true'"> |
| 40 | <HintPath>$(MSBuildThisFileDirectory)..\..\winmd\Microsoft.WSL.Containers.winmd</HintPath> |
| 41 | <Implementation>wslcsdk.dll</Implementation> |
| 42 | </Reference> |
| 43 | </ItemGroup> |
| 44 | |
| 45 | <Target Name="WslcValidatePlatform" BeforeTargets="PrepareForBuild" Condition="'$(_wslcIsInvalidPlatform)' == 'true'"> |
| 46 | <Error Text="wslcsdk.dll could not be copied because platform '$(WslcPlatform)' is not supported. Only x64 and arm64 platforms are supported. You can override the detected platform by setting the property WslcPlatform." /> |
| 47 | </Target> |
| 48 | |
| 49 | <Import Project="$(MSBuildThisFileDirectory)..\Microsoft.WSL.Containers.common.targets" /> |
| 50 | |
| 51 | <!-- ================================================================== --> |
| 52 | <!-- C++ specific: Write .tlog files for VS Fast Up-to-Date Check --> |
| 53 | <!-- ================================================================== --> |
| 54 | |
| 55 | <Target Name="_WslcWriteAllTlogs" |
| 56 | AfterTargets="WslcBuildAllImages" |
| 57 | Condition="'@(WslcImage)' != '' AND '$(TLogLocation)' != '' AND '$(DesignTimeBuild)' != 'true'"> |
| 58 | |
| 59 | <MSBuild Projects="$(MSBuildProjectFullPath)" |
| 60 | Targets="_WslcWriteSingleTlog" |
| 61 | Properties="Configuration=$(Configuration);Platform=$(Platform);_WslcName=%(WslcImage.Identity);_WslcImage=%(WslcImage.Image);_WslcDockerfile=%(WslcImage.Dockerfile);_WslcContext=%(WslcImage.Context);_WslcSourceDir=$([MSBuild]::Escape('%(WslcImage.Sources)'));_WslcIntDir=$(_WslcIntDir);_WslcTarLocation=%(WslcImage.TarLocation);_WslcOutDir=$(OutDir);_WslcBuildArgs=$([MSBuild]::Escape('%(WslcImage.BuildArgs)'));_WslcLabels=$([MSBuild]::Escape('%(WslcImage.Labels)'));_WslcPull=$(WslcImageBuildPull);_WslcNoCache=$(WslcImageBuildNoCache);_WslcTlogDir=$([MSBuild]::EnsureTrailingSlash('$(TLogLocation)'))" /> |
| 62 | </Target> |
| 63 | |
| 64 | <!-- tlog format requires one path per line; pass ItemGroups to WriteLinesToFile |
| 65 | so each entry is its own line (a single ';'-joined string would be one line). --> |
| 66 | <Target Name="_WslcWriteSingleTlog" |
| 67 | DependsOnTargets="_WslcWriteBuildSignature;_WslcResolveSavePath"> |
| 68 | <PropertyGroup> |
| 69 | <!-- Tool path is just a FUTDC group marker; don't GetFullPath |
| 70 | (would mis-resolve bare 'wslc' to <projdir>\wslc). --> |
| 71 | <_WslcTlogToolPath>$(WslcCliPath)</_WslcTlogToolPath> |
| 72 | <_WslcTarFullPath>$([System.IO.Path]::GetFullPath('$(_WslcTarPath)'))</_WslcTarFullPath> |
| 73 | </PropertyGroup> |
| 74 | |
| 75 | <ItemGroup> |
| 76 | <_WslcTlogReadLines Include="^$(_WslcTlogToolPath)" /> |
| 77 | <_WslcTlogReadLines Include="@(_WslcSourceFiles->'%(FullPath)')" /> |
| 78 | <_WslcTlogWriteLines Include="^$(_WslcTlogToolPath)" /> |
| 79 | <_WslcTlogWriteLines Include="$(_WslcTarFullPath)" /> |
| 80 | </ItemGroup> |
| 81 | |
| 82 | <WriteLinesToFile |
| 83 | File="$(_WslcTlogDir)wslc.$(_WslcName).read.1.tlog" |
| 84 | Lines="@(_WslcTlogReadLines)" |
| 85 | Overwrite="true" |
| 86 | Encoding="Unicode" /> |
| 87 | |
| 88 | <WriteLinesToFile |
| 89 | File="$(_WslcTlogDir)wslc.$(_WslcName).write.1.tlog" |
| 90 | Lines="@(_WslcTlogWriteLines)" |
| 91 | Overwrite="true" |
| 92 | Encoding="Unicode" /> |
| 93 | </Target> |
| 94 | |
| 95 | <!-- Clean tlog files --> |
| 96 | <Target Name="_WslcCleanTlogs" |
| 97 | AfterTargets="WslcClean" |
| 98 | Condition="'@(WslcImage)' != '' AND '$(TLogLocation)' != ''"> |
| 99 | <PropertyGroup> |
| 100 | <_WslcTlogDir>$([MSBuild]::EnsureTrailingSlash('$(TLogLocation)'))</_WslcTlogDir> |
| 101 | </PropertyGroup> |
| 102 | <Delete Files="$(_WslcTlogDir)wslc.%(WslcImage.Identity).read.1.tlog" |
| 103 | ContinueOnError="WarnAndContinue" /> |
| 104 | <Delete Files="$(_WslcTlogDir)wslc.%(WslcImage.Identity).write.1.tlog" |
| 105 | ContinueOnError="WarnAndContinue" /> |
| 106 | </Target> |
| 107 | |
| 108 | </Project> |