dotnet-installer/build/MSBuildExtensions.targets

118 lines
6.3 KiB
XML

<Project>
<Target Name="GenerateMSBuildExtensions"
DependsOnTargets="GenerateBundledVersionsProps;RestoreMSBuildExtensionsPackages">
<ItemGroup>
<MSBuildExtensionsContent Include="$(GeneratedMSBuildExtensionsDirectory)/**/*" />
<!-- We want to include the tasks and targets from the Microsoft.NET.Build.Extensions package, but we don't want to include the DLLs
from that package under the net461, net462, etc folders. That is because they come from the NETStandard.Library.NETFramework
package, and we want to insert them directly into the CLI from CoreFx instead of having to do a two-hop insertion (CoreFX -> SDK -> CLI)
if we need to update them.
https://github.com/dotnet/sdk/issues/1324 has been filed to exclude these from the Microsoft.NET.Build.Extensions package when
we generate it.
-->
<MSBuildExtensionsContent Include="$(MSBuildExtensionsNuPkgPath)\msbuildExtensions\**\*.*"
Exclude="$(MSBuildExtensionsNuPkgPath)\msbuildExtensions\Microsoft.NET.Build.Extensions\net*\**" />
<MSBuildExtensionsContent Include="$(MSBuildExtensionsNuPkgPath)\msbuildExtensions-ver\**\*.*"
DeploymentSubpath="$(MSBuildExtensionsVersionSubfolder)/" />
<MSBuildExtensionsContent Include="$(NETStandardLibraryNETFrameworkNuPkgPath)\build\**\*.*"
Exclude="$(NETStandardLibraryNETFrameworkNuPkgPath)\build\**\*.props;$(NETStandardLibraryNETFrameworkNuPkgPath)\build\**\*.targets"
DeploymentSubpath="Microsoft.NET.Build.Extensions/" />
</ItemGroup>
</Target>
<Target Name="PrepareMSBuildExtensionsProps">
<PropertyGroup>
<MSBuildExtensionsPackageName>Microsoft.NET.Build.Extensions</MSBuildExtensionsPackageName>
<MSBuildExtensionsVersionSubfolder>15.0</MSBuildExtensionsVersionSubfolder>
<MSBuildExtensionsNuPkgPath>$(NuGetPackagesDir)/$(MSBuildExtensionsPackageName.ToLower())/$(CLI_MSBuildExtensions_Version.ToLower())</MSBuildExtensionsNuPkgPath>
<NETStandardLibraryNETFrameworkPackageName>NETStandard.Library.NETFramework</NETStandardLibraryNETFrameworkPackageName>
<NETStandardLibraryNETFrameworkNuPkgPath>$(NuGetPackagesDir)/$(NETStandardLibraryNETFrameworkPackageName.ToLower())/$(CLI_NETStandardLibraryNETFrameworkVersion.ToLower())</NETStandardLibraryNETFrameworkNuPkgPath>
</PropertyGroup>
</Target>
<Target Name="RestoreMSBuildExtensionsPackages"
DependsOnTargets="PrepareMSBuildExtensionsProps">
<ItemGroup>
<ExtensionPackageToRestore Include="$(MSBuildExtensionsPackageName)" Version="$(CLI_MSBuildExtensions_Version)"/>
<ExtensionPackageToRestore Include="$(NETStandardLibraryNETFrameworkPackageName)" Version="$(CLI_NETStandardLibraryNETFrameworkVersion)"/>
<ExtensionRestore Include="$(RepoRoot)/build/RestoreDependency.proj">
<Properties>
CLIBuildDll=$(CLIBuildDll);
NuGetPackagesDir=$(NuGetPackagesDir);
DependencyPackageName=%(ExtensionPackageToRestore.Identity);
DependencyPackageVersion=%(ExtensionPackageToRestore.Version);
Stage0Directory=$(Stage0Directory)
</Properties>
</ExtensionRestore>
</ItemGroup>
<MSBuild
BuildInParallel="False"
Projects="@(ExtensionRestore)">
</MSBuild>
</Target>
<Target Name="GenerateBundledVersionsProps">
<PropertyGroup>
<BundledVersionsPropsFileName>Microsoft.NETCoreSdk.BundledVersions.props</BundledVersionsPropsFileName>
</PropertyGroup>
<!--
The bundled version of Microsoft.NETCore.App is determined statically from DependencyVersions.props whereas the bundled version
of NETStandard.Library is defined by what Microsoft.NETCore.App pulls in. This digs in to the package resolution items of
of our build against Microsoft.NETCore.App to find the correct NETStandard.Library version
-->
<ItemGroup>
<_NETStandardLibraryVersions Include="@(PackageDefinitions->'%(Version)')"
Condition="%(PackageDefinitions.Name) == 'NetStandard.Library'" />
</ItemGroup>
<Error Condition="@(_NETStandardLibraryVersions->Distinct()->Count()) != 1"
Text="Failed to determine the NETStandard.Library version pulled in Microsoft.NETCore.App" />
<PropertyGroup>
<_NETCoreAppPackageVersion>$(CLI_SharedFrameworkVersion)</_NETCoreAppPackageVersion>
<_NETStandardPackageVersion>@(_NETStandardLibraryVersions->Distinct())</_NETStandardPackageVersion>
<!-- Use only major and minor in target framework version -->
<_NETCoreAppTargetFrameworkVersion>$(_NETCoreAppPackageVersion.Split('.')[0]).$(_NETCoreAppPackageVersion.Split('.')[1])</_NETCoreAppTargetFrameworkVersion>
<_NETStandardTargetFrameworkVersion>$(_NETStandardPackageVersion.Split('.')[0]).$(_NETStandardPackageVersion.Split('.')[1])</_NETStandardTargetFrameworkVersion>
<BundledVersionsPropsContent>
<![CDATA[
<!--
***********************************************************************************************
$(BundledVersionsPropsFileName)
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.
Copyright (c) .NET Foundation. All rights reserved.
***********************************************************************************************
-->
<Project>
<PropertyGroup>
<BundledNETCoreAppTargetFrameworkVersion>$(_NETCoreAppTargetFrameworkVersion)</BundledNETCoreAppTargetFrameworkVersion>
<BundledNETCoreAppPackageVersion>$(_NETCoreAppPackageVersion)</BundledNETCoreAppPackageVersion>
<BundledNETStandardTargetFrameworkVersion>$(_NETStandardTargetFrameworkVersion)</BundledNETStandardTargetFrameworkVersion>
<BundledNETStandardPackageVersion>$(_NETStandardPackageVersion)</BundledNETStandardPackageVersion>
</PropertyGroup>
</Project>
]]>
</BundledVersionsPropsContent>
</PropertyGroup>
<MakeDir Directories="$(GeneratedMSBuildExtensionsDirectory)" />
<WriteLinesToFile File="$(GeneratedMSBuildExtensionsDirectory)/$(BundledVersionsPropsFileName)"
Lines="$(BundledVersionsPropsContent)"
Overwrite="true" />
</Target>
</Project>