206 lines
7.5 KiB
XML
206 lines
7.5 KiB
XML
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
|
|
<!--
|
|
Layout assumptions
|
|
|
|
This .targets file lives in:
|
|
{ExtensionPath}\Extension.Assemblies.targets
|
|
|
|
We want to copy to:
|
|
BasePackage\Assemblies\
|
|
→ {ExtensionPath}\BasePackage\Assemblies\
|
|
|
|
Root\InstalledPackages\Assemblies\{ExtensionId}\
|
|
→ {ExtensionPath}\..\Root\InstalledPackages\Assemblies\{ExtensionId}\
|
|
|
|
Properties:
|
|
- M42BasePackageAssembliesDir (can override in csproj)
|
|
- M42RootAssembliesDir (needs M42ExtensionId)
|
|
- M42AssemblyPattern (default: $(MSBuildProjectName)*.*)
|
|
- M42DefaultRids (default: win-x64;linux-x64)
|
|
- M42ExtensionId (set in csproj)
|
|
- M42EnableRidBuild (true for net8.0 w/ RIDs, false for netstandard)
|
|
-->
|
|
<PropertyGroup>
|
|
<!-- BasePackage under extension root -->
|
|
<M42BasePackageAssembliesDir Condition="'$(M42BasePackageAssembliesDir)' == ''">$(MSBuildThisFileDirectory)BasePackage\Assemblies\</M42BasePackageAssembliesDir>
|
|
|
|
<!-- Root one level above extension root -->
|
|
<M42RootAssembliesDir Condition="'$(M42RootAssembliesDir)' == '' AND '$(M42ExtensionId)' != ''">$(MSBuildThisFileDirectory)..\Root\InstalledPackages\Assemblies\$(M42ExtensionId)\</M42RootAssembliesDir>
|
|
|
|
<!-- Pattern & default RIDs -->
|
|
<M42AssemblyPattern Condition="'$(M42AssemblyPattern)' == ''">$(MSBuildProjectName)*.*</M42AssemblyPattern>
|
|
<M42DefaultRids Condition="'$(M42DefaultRids)' == ''">win-x64;linux-x64</M42DefaultRids>
|
|
|
|
<!-- Enable multi-RID builds per project; can be set to false in csproj -->
|
|
<M42EnableRidBuild Condition="'$(M42EnableRidBuild)' == ''">true</M42EnableRidBuild>
|
|
</PropertyGroup>
|
|
|
|
|
|
<!--
|
|
M42_BuildAllRids
|
|
|
|
Local only: if no RID was specified AND we're not in Azure DevOps,
|
|
build all default RIDs (M42DefaultRids) by re-invoking MSBuild
|
|
with RuntimeIdentifier and AppendRuntimeIdentifierToOutputPath=true.
|
|
|
|
This prevents the outer RID-less build by setting SkipBuild=true.
|
|
|
|
Skipped when M42EnableRidBuild=false (e.g. netstandard projects).
|
|
-->
|
|
<Target Name="M42_BuildAllRids"
|
|
BeforeTargets="Build"
|
|
Condition="'$(RuntimeIdentifier)' == ''
|
|
AND ( '$(TF_BUILD)' != 'True' OR '$(M42BuildAllRidsOnCI)' == 'true' )
|
|
AND '$(M42EnableRidBuild)' == 'true'">
|
|
|
|
<ItemGroup>
|
|
<_M42RidList Include="$(M42DefaultRids)" />
|
|
</ItemGroup>
|
|
|
|
<MSBuild Projects="$(MSBuildProjectFullPath)"
|
|
Targets="Restore;Build"
|
|
Properties="RuntimeIdentifier=%(_M42RidList.Identity);Configuration=$(Configuration);AppendRuntimeIdentifierToOutputPath=true"
|
|
BuildInParallel="true" />
|
|
|
|
<PropertyGroup>
|
|
<SkipBuild>true</SkipBuild>
|
|
</PropertyGroup>
|
|
</Target>
|
|
|
|
|
|
<!--
|
|
M42_PostBuild_CopyRidless
|
|
|
|
For RID-less builds (RuntimeIdentifier == ''), copy top-level output files
|
|
that match M42AssemblyPattern directly from $(TargetDir) to:
|
|
|
|
1) BasePackage\Assemblies\
|
|
2) Root\InstalledPackages\Assemblies\{ExtId}\ (if configured)
|
|
|
|
Useful for projects that don't support RID-specific builds (e.g. netstandard),
|
|
or when M42EnableRidBuild=false.
|
|
-->
|
|
<Target Name="M42_PostBuild_CopyRidless"
|
|
AfterTargets="Build"
|
|
Condition="'$(RuntimeIdentifier)' == ''">
|
|
|
|
<Message Text="M42: RID-less copy from $(TargetDir) → $(M42BasePackageAssembliesDir)" Importance="high" />
|
|
|
|
<ItemGroup>
|
|
<_M42FlatRootRidless Include="$(TargetDir)$(M42AssemblyPattern)" />
|
|
</ItemGroup>
|
|
|
|
<!-- BasePackage flat copy -->
|
|
<MakeDir Directories="$(M42BasePackageAssembliesDir)"
|
|
Condition="!Exists('$(M42BasePackageAssembliesDir)')" />
|
|
|
|
<Copy
|
|
SourceFiles="@(_M42FlatRootRidless)"
|
|
DestinationFolder="$(M42BasePackageAssembliesDir)"
|
|
SkipUnchangedFiles="true"
|
|
Condition="Exists('$(TargetDir)')" />
|
|
|
|
<!-- Root flat copy (if configured) -->
|
|
<Message Text="M42: RID-less copy to Root → $(M42RootAssembliesDir)" Importance="high"
|
|
Condition="'$(M42RootAssembliesDir)' != ''" />
|
|
|
|
<MakeDir Directories="$(M42RootAssembliesDir)"
|
|
Condition="'$(M42RootAssembliesDir)' != '' AND !Exists('$(M42RootAssembliesDir)')" />
|
|
|
|
<Copy
|
|
SourceFiles="@(_M42FlatRootRidless)"
|
|
DestinationFolder="$(M42RootAssembliesDir)"
|
|
SkipUnchangedFiles="true"
|
|
Condition="'$(M42RootAssembliesDir)' != '' AND Exists('$(TargetDir)')" />
|
|
|
|
</Target>
|
|
|
|
|
|
<!--
|
|
M42_PostBuild_CopyRID
|
|
|
|
After each RID-specific build, copy assemblies to:
|
|
|
|
1) BasePackage\Assemblies\ (FLAT, from RID-less bin\...\netX\)
|
|
2) BasePackage\Assemblies\<RID>\... (RECURSIVE, from current RID build)
|
|
|
|
And, if M42RootAssembliesDir is set:
|
|
|
|
3) Root\InstalledPackages\Assemblies\{ExtId}\ (FLAT)
|
|
4) Root\InstalledPackages\Assemblies\{ExtId}\<RID>\ (RECURSIVE)
|
|
-->
|
|
<Target Name="M42_PostBuild_CopyRID"
|
|
AfterTargets="Build"
|
|
Condition="'$(RuntimeIdentifier)' != ''">
|
|
|
|
<Message Text="M42: RID=$(RuntimeIdentifier) TargetDir=$(TargetDir)" Importance="high" />
|
|
|
|
<!-- Parent of ...\netX\<rid>\ -->
|
|
<PropertyGroup>
|
|
<M42_RidlessTargetDir>$([System.IO.Path]::GetFullPath('$(TargetDir)..\'))</M42_RidlessTargetDir>
|
|
</PropertyGroup>
|
|
|
|
<!-- 1) FLAT copy from rid-less netX to BasePackage\Assemblies -->
|
|
<Message Text="M42: flat copy from $(M42_RidlessTargetDir) → $(M42BasePackageAssembliesDir)" Importance="high" />
|
|
|
|
<ItemGroup>
|
|
<_M42FlatRoot Include="$(M42_RidlessTargetDir)$(M42AssemblyPattern)" />
|
|
</ItemGroup>
|
|
|
|
<MakeDir Directories="$(M42BasePackageAssembliesDir)"
|
|
Condition="!Exists('$(M42BasePackageAssembliesDir)')" />
|
|
|
|
<Copy
|
|
SourceFiles="@(_M42FlatRoot)"
|
|
DestinationFolder="$(M42BasePackageAssembliesDir)"
|
|
SkipUnchangedFiles="true"
|
|
Condition="Exists('$(M42_RidlessTargetDir)')" />
|
|
|
|
|
|
<!-- 1b) FLAT copy to Root if configured -->
|
|
<Message Text="M42: flat copy to Root → $(M42RootAssembliesDir)" Importance="high"
|
|
Condition="'$(M42RootAssembliesDir)' != ''" />
|
|
|
|
<MakeDir Directories="$(M42RootAssembliesDir)"
|
|
Condition="'$(M42RootAssembliesDir)' != '' AND !Exists('$(M42RootAssembliesDir)')" />
|
|
|
|
<Copy
|
|
SourceFiles="@(_M42FlatRoot)"
|
|
DestinationFolder="$(M42RootAssembliesDir)"
|
|
SkipUnchangedFiles="true"
|
|
Condition="'$(M42RootAssembliesDir)' != '' AND Exists('$(M42_RidlessTargetDir)')" />
|
|
|
|
|
|
<!-- 2) RID copy to BasePackage\Assemblies\<RID>\... -->
|
|
<Message Text="M42: RID copy → $(M42BasePackageAssembliesDir)$(RuntimeIdentifier)\" Importance="high" />
|
|
|
|
<ItemGroup>
|
|
<_M42Rid Include="$(TargetDir)**\$(M42AssemblyPattern)" />
|
|
</ItemGroup>
|
|
|
|
<MakeDir Directories="$(M42BasePackageAssembliesDir)$(RuntimeIdentifier)"
|
|
Condition="!Exists('$(M42BasePackageAssembliesDir)$(RuntimeIdentifier)')" />
|
|
|
|
<Copy
|
|
SourceFiles="@(_M42Rid)"
|
|
DestinationFolder="$(M42BasePackageAssembliesDir)$(RuntimeIdentifier)\%(RecursiveDir)"
|
|
SkipUnchangedFiles="true" />
|
|
|
|
|
|
<!-- 2b) RID copy to Root\...\<RID>\... -->
|
|
<Message Text="M42: RID copy to Root → $(M42RootAssembliesDir)$(RuntimeIdentifier)\" Importance="high"
|
|
Condition="'$(M42RootAssembliesDir)' != ''" />
|
|
|
|
<MakeDir Directories="$(M42RootAssembliesDir)$(RuntimeIdentifier)"
|
|
Condition="'$(M42RootAssembliesDir)' != '' AND !Exists('$(M42RootAssembliesDir)$(RuntimeIdentifier)')" />
|
|
|
|
<Copy
|
|
SourceFiles="@(_M42Rid)"
|
|
DestinationFolder="$(M42RootAssembliesDir)$(RuntimeIdentifier)\%(RecursiveDir)"
|
|
SkipUnchangedFiles="true"
|
|
Condition="'$(M42RootAssembliesDir)' != ''" />
|
|
|
|
</Target>
|
|
|
|
</Project> |