Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize the installer targets to provide a better/cleaner UX and integrate better with the SharedFX SDK #15239

Merged
merged 7 commits into from
Nov 12, 2024
20 changes: 15 additions & 5 deletions src/Microsoft.DotNet.Build.Tasks.Installers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ There are a few common properties used by all of the installer types and the bun
- The name of the installer file without an extension..
- `ProductBrandPrefix`
- The branding name of this component, such as "Microsoft Windows Desktop"
- `PackageBrandNameSuffix` (`ToolPack` installers only)
- The type of package, for example "Shared Host" or "AppHost Pack". This is set automatically for any non-ToolPack package types.
- `PackageBrandNameSuffix`
- The type of package, for example "Shared Host" or "AppHost Pack". This is set automatically for any non-ToolPack packages produced by the Shared Framework SDK.

For correct branding and versioning, this SDK has a dependency on Arcade's versioning setup, including the `MajorVersion`, `MinorVersion`, `PreReleaseVersionLabel`, `PreReleaseVersionIteration` and `DotNetFinalVersionKind` properties.

Expand All @@ -29,19 +29,29 @@ To control the order in which an older product is removed during an upgrade, set

To add package dependencies for linux packages, add a `LinuxPackageDependency` item with the version in the `Version` metadata.

To add package conflicts, add a `LinuxPackageConflict` item for the package.

To add symlinks that should be installed on the system, add a `LinuxPackageSymlink` item with the `LinkTarget` metadata pointing to the target of the symlink.

> [!NOTE]
> Symlinks added with `LinuxPackageSymlink` are relative to the filesystem root, not to the `LinuxInstallRoot` property.
> As the vast majority of symlinks in a package are from system locations to the install root, this provides an easier UX for defining symlinks.

#### Deb package configuration

To add additional properties for the deb package tool, add items to the `DebJsonProperty` item group.
To add additional properties for the deb control file, add `DebControlProperty` items with the value of the field in the `Value` metadata.

#### Rpm package configuration

To add additional properties for the deb package tool, add items to the `RpmJsonProperty` item group.
To specify directories owned by the package, add `RpmOwnedDirectory` items for each directory. These are provided automatically for any non-ToolPack packages produced by the Shared Framework SDK.

### MacOS Pkg configuration

To specify a directory where `pkgbuild` should look for scripts, set the `MacOSScriptsDirectory` to the path to the scripts.

If you are building a `ToolPack` pack, you need to specify the `MacOSComponentNamePackType` property to create the component name for the `.pkg` package. If you want the component name to not include the version (for example you are building the shared host), you can set the `IncludeVersionInMacOSComponentName` property to false.
You need to specify the `MacOSComponentNamePackType` to create the component name for the `.pkg` package. This is set automatically for any non-ToolPack packages produced by the Shared Framework SDK.

If you want the component name to not include the version (for example you are building the shared host), you can set the `IncludeVersionInMacOSComponentName` property to false.

If your `pkg` is later going to be bundled in a macOS `pkg` bundle created by `productbuild`, you should also specify the `MacOSPackageDescription` property, which will set the package description in the bundle distribution file.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
<Project>

<Import Project="$(MSBuildThisFileDirectory)installer.targetos.targets" />

<Target Name="GetBundleGenerationFlags" DependsOnTargets="_GetTargetOSArchInfo" Condition="'$(SkipInstallerBuild)' != 'true'">
<Error
Text="Unable to build a bundle installer for a non-Windows, non-macOS platform."
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project>
<PropertyGroup>
<TargetRuntimeOS>$(InstallerRuntimeIdentifier.Substring(0, $(InstallerRuntimeIdentifier.LastIndexOf('-'))))</TargetRuntimeOS>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd prefer if we don't invent a new property here that is only used by the installer targets when we already have many other similar properties. I know this is preexisting so feel free to address later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll address this in a future PR.

<TargetArchitecture Condition="'$(TargetArchitecture)' == ''">$(InstallerRuntimeIdentifier.Substring($(InstallerRuntimeIdentifier.LastIndexOf('-'))).TrimStart('-'))</TargetArchitecture>
</PropertyGroup>

<Target Name="_GetTargetOSArchInfo">
<Error Condition="'$(InstallerRuntimeIdentifier)' == ''"
Text="An InstallerRuntimeIdentifier must be specified when building installers." />
<ItemGroup>
<CrossArchMsiToBuild Include="@(CrossArchSdkMsiInstallerArch)" Exclude="$(TargetArchitecture)" />
</ItemGroup>
<PropertyGroup>
<_osSupportsWixBasedInstallers Condition="$([MSBuild]::IsOsPlatform(Windows)) and '$(TargetRuntimeOS)' == 'win'">true</_osSupportsWixBasedInstallers>

<_osArchSupportsWixBasedInstallers>$(_osSupportsWixBasedInstallers)</_osArchSupportsWixBasedInstallers>
<_osArchSupportsWixBasedInstallers Condition="'$(TargetArchitecture)' == 'arm'">false</_osArchSupportsWixBasedInstallers>
</PropertyGroup>
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -75,34 +75,14 @@
ComponentMsiFile;
InstallerRuntimeIdentifier;
InstallerTargetArchitecture;
CrossArchContentsArch
CrossArchContentsArch;
_IsIndividualInstallerBuild
</_GlobalPropertiesToRemoveForPublish>
</PropertyGroup>

<ItemGroup>
<_GlobalPropertiesToRemoveForPublish Include="$(_GlobalPropertiesToRemoveForPublish)" />
</ItemGroup>

<Target Name="_GetTargetOSArchInfo">
<Error Condition="'$(InstallerRuntimeIdentifier)' == ''"
Text="An InstallerRuntimeIdentifier must be specified when building installers." />
<PropertyGroup>
<TargetRuntimeOS>$(InstallerRuntimeIdentifier.Substring(0, $(InstallerRuntimeIdentifier.LastIndexOf('-'))))</TargetRuntimeOS>
<TargetArchitecture Condition="'$(TargetArchitecture)' == ''">$(InstallerRuntimeIdentifier.Substring($(InstallerRuntimeIdentifier.LastIndexOf('-'))).TrimStart('-'))</TargetArchitecture>
<_TargetArch>$(TargetArchitecture)</_TargetArch>
<_TargetArch Condition="'$(BuildRpmPackage)' == 'true' and '$(TargetArchitecture)' == 'arm64'">aarch64</_TargetArch>
<InstallerTargetArchitecture Condition="'$(InstallerTargetArchitecture)' == ''">$(_TargetArch)</InstallerTargetArchitecture>
</PropertyGroup>
<ItemGroup>
<CrossArchMsiToBuild Include="@(CrossArchSdkMsiInstallerArch)" Exclude="$(TargetArchitecture)" />
</ItemGroup>
<PropertyGroup>
<_osSupportsWixBasedInstallers Condition="$([MSBuild]::IsOsPlatform(Windows)) and '$(TargetRuntimeOS)' == 'win'">true</_osSupportsWixBasedInstallers>

<_osArchSupportsWixBasedInstallers>$(_osSupportsWixBasedInstallers)</_osArchSupportsWixBasedInstallers>
<_osArchSupportsWixBasedInstallers Condition="'$(TargetArchitecture)' == 'arm'">false</_osArchSupportsWixBasedInstallers>
</PropertyGroup>
</Target>

<Target Name="_GetVersionInfo">
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public override bool Execute()
"x86" => Architecture.X86,
"x64" => Architecture.X64,
"arm" => Architecture.Arm,
"aarch64" => Architecture.Arm64,
"arm64" => Architecture.Arm64,
#if NET
"armv6" => Architecture.Armv6,
"s390x" => Architecture.S390x,
Expand Down
12 changes: 7 additions & 5 deletions src/Microsoft.DotNet.SharedFramework.Sdk/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Microsoft.DotNet.SharedFramework.Sdk

This package provides a common set of tools for authoring framework packs, shared frameworks, and packages and installers for packs and frameworks.
This package provides a common set of tools for authoring framework packs, shared frameworks, apphost packs, and other packs that can be installed into or downloaded by the .NET SDK.

It also integrates with `Microsoft.DotNet.Build.Tasks.Installers` and `Microsoft.DotNet.Build.Tasks.Archives` to provide an easy mechanism to produce installers and archives for these components.

## Building Framework Packs

Expand All @@ -13,15 +15,15 @@ An example project is included below:
<Sdk Name="Microsoft.DotNet.SharedFramework.Sdk" />
<PropertyGroup>
<!-- Required properties -->
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SharedFrameworkName>Microsoft.Banana.App</SharedFrameworkName>
<PlatformPackageType>RuntimePack</PlatformPackageType>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.NETCore.App" RuntimeFrameworkVersion="3.0.0" />
<FrameworkReference Include="Microsoft.NETCore.App" RuntimeFrameworkVersion="10.0.0" />

<ProjectReference Include="..\..\MyAssembly1\MyAssembly1.csproj" />
<ProjectReference Include="..\..\MyAssembly2\MyAssembly2.csproj" />
Expand All @@ -38,7 +40,7 @@ This example project shows some of the basic options provided by the SDK. The `S
- `RuntimePack`: RID-specific runtime packages
- `TargetingPack`: Packs of reference assemblies
- `AppHostPack`: Pack containing the app hosts
- `ToolPack`: This pack option allows you to have completely custom scripting for what files are included where in your pack. It also enables creating installer-only projects with this SDK.
- `ToolPack`: This pack option allows you to have completely custom scripting for what files are included where in your pack.

This SDK uses the standard mechanisms in the .NET SDK for referencing packages, projects, and other frameworks to resolve its dependencies and collect the files that are a part of the pack. To include native files, add them to the `NativeRuntimeAsset` item group.

Expand Down Expand Up @@ -139,6 +141,6 @@ This SDK provides a custom target named `PublishToDisk` that publishes the gener

## Build Skip Support for Unsupported Platforms and Servicing

This SDK also supports automatically skipping builds on unsupported platforms or in servicing releases. If a project with a list of provided RIDs in `RuntimeIdentifiers` is built with the `RuntimeIdentifier` property set to a RID that is not in the `RuntimeIdentifiers` list, the build will be skipped. This enables cleanly skipping optional packs, installers, or bundles that only exist on specific platforms.
This SDK also supports automatically skipping builds on unsupported platforms or in servicing releases. If a project with a list of provided RIDs in `RuntimeIdentifiers` is built with the `RuntimeIdentifier` property set to a RID that is not in the `RuntimeIdentifiers` list, the build will be skipped. This enables cleanly skipping optional packs that only exist on specific platforms.

Additionally, if a `ProjectServicingConfiguration` item is provided with the identity of the project name and the `PatchVersion` metadata on the item is not equal to the current `PatchVersion`, the build will be skipped. This support enables a repository to disable building targeting packs in servicing releases if that is desired.
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,58 @@
<PackageId Condition="'$(OverridePackageId)' != ''">$(OverridePackageId)</PackageId>
</PropertyGroup>

<PropertyGroup Condition="'$(PlatformPackageType)' == 'TargetingPack'">
<PackageId Condition="'$(OverridePackageId)' == ''">$(SharedFrameworkName).Ref</PackageId>
<PackageBrandNameSuffix>Targeting Pack</PackageBrandNameSuffix>
<MacOSComponentNamePackType>pack.targeting</MacOSComponentNamePackType>
</PropertyGroup>
<PropertyGroup Condition="'$(PlatformPackageType)' == 'RuntimePack'">
<PackageId Condition="'$(OverridePackageId)' == ''">$(SharedFrameworkName).Runtime.$(RuntimeIdentifier)</PackageId>
<PackageBrandNameSuffix>Runtime</PackageBrandNameSuffix>
<MacOSComponentNamePackType>sharedframework.$(SharedFrameworkName)</MacOSComponentNamePackType>
</PropertyGroup>
<PropertyGroup Condition="'$(PlatformPackageType)' == 'AppHostPack'">
<PackageId Condition="'$(OverridePackageId)' == ''">$(SharedFrameworkName).Host.$(RuntimeIdentifier)</PackageId>
<PackageBrandNameSuffix>AppHost Pack</PackageBrandNameSuffix>
<MacOSComponentNamePackType>pack.apphost</MacOSComponentNamePackType>
</PropertyGroup>
<PropertyGroup>
<PackageId Condition="'$(OverridePackageId)' == '' and '$(PackageId)' == ''">$(SharedFrameworkName)</PackageId>
<MacOSComponentNamePackType Condition="'$(MacOSComponentNamePackType)' == ''">pack.$(PlatformPackageType.ToLower())</MacOSComponentNamePackType>
</PropertyGroup>
<!--
Set the NuGet package ID and set various properties to integrate with
Microsoft.DotNet.Build.Tasks.Installers for building installer packages.
-->
<Choose>
<When Condition="'$(PlatformPackageType)' == 'TargetingPack'">
<PropertyGroup>
<PackageId Condition="'$(OverridePackageId)' == ''">$(SharedFrameworkName).Ref</PackageId>
<PackageBrandNameSuffix>Targeting Pack</PackageBrandNameSuffix>
<MacOSComponentNamePackType>pack.targeting</MacOSComponentNamePackType>
</PropertyGroup>
<ItemGroup>
<RpmOwnedDirectory Include="$(LinuxInstallRoot)/packs/$(PackageId)" />
<RpmOwnedDirectory Include="$(LinuxInstallRoot)/packs/$(PackageId)/$(Version)" />
<RpmOwnedDirectory Include="$(LinuxInstallRoot)/packs/$(PackageId)/$(Version)/data" />
<RpmOwnedDirectory Include="$(LinuxInstallRoot)/packs/$(PackageId)/$(Version)/analyzers" />
<RpmOwnedDirectory Include="$(LinuxInstallRoot)/packs/$(PackageId)/$(Version)/ref" />
<RpmOwnedDirectory Include="$(LinuxInstallRoot)/packs/$(PackageId)/$(Version)/ref/$(TargetFramework)" />
</ItemGroup>
</When>
<When Condition="'$(PlatformPackageType)' == 'RuntimePack'">
<PropertyGroup>
<PackageId Condition="'$(OverridePackageId)' == ''">$(SharedFrameworkName).Runtime.$(RuntimeIdentifier)</PackageId>
<PackageBrandNameSuffix>Runtime</PackageBrandNameSuffix>
<MacOSComponentNamePackType>sharedframework.$(SharedFrameworkName)</MacOSComponentNamePackType>
</PropertyGroup>
<ItemGroup>
<RpmOwnedDirectory Include="$(LinuxInstallRoot)/shared/$(SharedFrameworkName)" />
<RpmOwnedDirectory Include="$(LinuxInstallRoot)/shared/$(SharedFrameworkName)/$(Version)" />
</ItemGroup>
</When>
<When Condition="'$(PlatformPackageType)' == 'AppHostPack'">
<PropertyGroup>
<PackageId Condition="'$(OverridePackageId)' == ''">$(SharedFrameworkName).Host.$(RuntimeIdentifier)</PackageId>
<PackageBrandNameSuffix>AppHost Pack</PackageBrandNameSuffix>
<MacOSComponentNamePackType>pack.apphost</MacOSComponentNamePackType>
</PropertyGroup>
<ItemGroup>
<RpmOwnedDirectory Include="$(LinuxInstallRoot)/packs/$(PackageId)" />
<RpmOwnedDirectory Include="$(LinuxInstallRoot)/packs/$(PackageId)/$(Version)" />
<RpmOwnedDirectory Include="$(LinuxInstallRoot)/packs/$(PackageId)/$(Version)/runtimes" />
<RpmOwnedDirectory Include="$(LinuxInstallRoot)/packs/$(PackageId)/$(Version)/runtimes/$(RuntimeIdentifier)" />
<RpmOwnedDirectory Include="$(LinuxInstallRoot)/packs/$(PackageId)/$(Version)/runtimes/$(RuntimeIdentifier)/native" />
</ItemGroup>
</When>
<Otherwise>
<PropertyGroup>
<PackageId Condition="'$(OverridePackageId)' == '' and '$(PackageId)' == ''">$(SharedFrameworkName)</PackageId>
<MacOSComponentNamePackType Condition="'$(MacOSComponentNamePackType)' == ''">pack.$(PlatformPackageType.ToLower())</MacOSComponentNamePackType>
</PropertyGroup>
</Otherwise>
</Choose>

<Import Project="$(MSBuildThisFileDirectory)sharedfx.targets" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,11 @@
Condition="'%(_PackagedFilesToPublish.TargetPath)' != ''"
TargetPath="packs/$(PackageId)/$(Version)/%(_PackagedFilesToPublish.TargetPath)/"/>
</ItemGroup>
<ItemGroup Conditoin="'$(PlatformPackageType)' == 'ToolPack'">
<FilesToPublish Include="@(_PackagedFilesToPublish)"
Condition="$([System.String]::new('%(_PackagedFilesToPublish.TargetPath)').StartsWith('tools/')) or '%(_PackagedFilesToPublish.PublishOnly)' == 'true'"
TargetPath="" />
</ItemGroup>
</Target>

<Target Name="PublishToDisk"
Expand Down
Loading