dotnet-installer/src/redist/targets/GeneratePKG.targets
2018-11-06 14:29:00 -08:00

175 lines
10 KiB
XML

<Project>
<Target Name="SetupPKGProps" DependsOnTargets="SetSdkVersionInfo;GetCurrentRuntimeInformation;SetupFileExtensions">
<PropertyGroup>
<PkgIntermediateDirectory>$(IntermediateOutputPath)pkgs/$(SdkVersion)</PkgIntermediateDirectory>
<!-- Properties for pkg build -->
<SharedHostComponentId>com.microsoft.dotnet.sharedhost.$(SharedHostVersion).component.osx.x64</SharedHostComponentId>
<HostFxrComponentId>com.microsoft.dotnet.hostfxr.$(HostFxrVersion).component.osx.x64</HostFxrComponentId>
<SharedFrameworkComponentId>com.microsoft.dotnet.sharedframework.$(SharedFrameworkNugetName).$(MicrosoftNETCoreAppPackageVersion).component.osx.x64</SharedFrameworkComponentId>
<SdkComponentId>com.microsoft.dotnet.dev.$(SdkVersion).component.osx.x64</SdkComponentId>
<SdkProductArchiveId>com.microsoft.dotnet.dev.$(SdkVersion).osx.x64</SdkProductArchiveId>
<PkgInstallDirectory>/usr/local/share/dotnet</PkgInstallDirectory>
<SdkPkgSourcesRootDirectory>$(MSBuildThisFileDirectory)packaging/osx/clisdk</SdkPkgSourcesRootDirectory>
<SdkPkgScriptsDirectory>$(SdkPkgSourcesRootDirectory)/scripts</SdkPkgScriptsDirectory>
<SdkPkgScriptTemplateFile>$(SdkPkgScriptsDirectory)/postinstall</SdkPkgScriptTemplateFile>
<SdkPkgDestinationScriptsDirectory>$(PkgIntermediateDirectory)/scripts</SdkPkgDestinationScriptsDirectory>
<SdkPkgScriptFile>$(SdkPkgDestinationScriptsDirectory)/postinstall</SdkPkgScriptFile>
<SdkProductArchiveResourcesDirectory>$(PkgIntermediateDirectory)/resources</SdkProductArchiveResourcesDirectory>
<SdkProductArchiveDistributionTemplateFile>$(SdkPkgSourcesRootDirectory)/Distribution-Template</SdkProductArchiveDistributionTemplateFile>
<SdkProductArchiveDistributionFile>$(PkgIntermediateDirectory)/CLI-SDK-Formatted-Distribution-Template.xml</SdkProductArchiveDistributionFile>
<SdkPkgIntermediatePath>$(PkgIntermediateDirectory)/$(SdkComponentId).pkg</SdkPkgIntermediatePath>
<SharedFrameworkPkgIntermediatePath>$(PkgIntermediateDirectory)/$(SharedFrameworkComponentId).pkg</SharedFrameworkPkgIntermediatePath>
<SharedHostPkgIntermediatePath>$(PkgIntermediateDirectory)/$(SharedHostComponentId).pkg</SharedHostPkgIntermediatePath>
<HostFxrPkgIntermediatePath>$(PkgIntermediateDirectory)/$(HostFxrComponentId).pkg</HostFxrPkgIntermediatePath>
<SdkPKGInstallerFile>$(ArtifactsShippingPackagesDir)$(ArtifactNameWithVersionSdk)$(InstallerExtension)</SdkPKGInstallerFile>
<CombinedFrameworkSdkHostPKGInstallerFile>$(ArtifactsShippingPackagesDir)$(ArtifactNameWithVersionCombinedHostHostFxrFrameworkSdk)$(BundleExtension)</CombinedFrameworkSdkHostPKGInstallerFile>
</PropertyGroup>
</Target>
<Target Name="SetupPkgInputsOutputs" DependsOnTargets="SetupPKGProps;SetSdkBrandingInfo">
<ItemGroup>
<DistributionTemplateReplacement Include="{SharedFxComponentId}">
<ReplacementString>$(SharedFrameworkComponentId)</ReplacementString>
</DistributionTemplateReplacement>
<DistributionTemplateReplacement Include="{SharedHostComponentId}">
<ReplacementString>$(SharedHostComponentId)</ReplacementString>
</DistributionTemplateReplacement>
<DistributionTemplateReplacement Include="{HostFxrComponentId}">
<ReplacementString>$(HostFxrComponentId)</ReplacementString>
</DistributionTemplateReplacement>
<DistributionTemplateReplacement Include="{CLISdkComponentId}">
<ReplacementString>$(SdkComponentId)</ReplacementString>
</DistributionTemplateReplacement>
<DistributionTemplateReplacement Include="{CLISdkNugetVersion}">
<ReplacementString>$(SdkVersion)</ReplacementString>
</DistributionTemplateReplacement>
<DistributionTemplateReplacement Include="{CLISdkBrandName}">
<ReplacementString>$(SdkBrandName)</ReplacementString>
</DistributionTemplateReplacement>
<DistributionTemplateReplacement Include="{SharedFxBrandName}">
<ReplacementString>$(SharedFrameworkBrandName)</ReplacementString>
</DistributionTemplateReplacement>
<DistributionTemplateReplacement Include="{SharedHostBrandName}">
<ReplacementString>$(SharedHostBrandName)</ReplacementString>
</DistributionTemplateReplacement>
<DistributionTemplateReplacement Include="{HostFxrBrandName}">
<ReplacementString>$(HostFxrBrandName)</ReplacementString>
</DistributionTemplateReplacement>
<PostInstallScriptReplacement Include="%SDK_VERSION%">
<ReplacementString>$(SdkVersion)</ReplacementString>
</PostInstallScriptReplacement>
<ResourcesReplacement Include="{DOTNETSDKVERSION}">
<ReplacementString>$(SdkVersion)</ReplacementString>
</ResourcesReplacement>
<ResourcesReplacement Include="{DOTNETRUNTIMEVERSION}">
<ReplacementString>$(MicrosoftNETCoreAppPackageVersion)</ReplacementString>
</ResourcesReplacement>
<ResourcesReplacement Include="{ASPNETCOREVERSION}">
<ReplacementString>$(AspNetCoreVersion)</ReplacementString>
</ResourcesReplacement>
</ItemGroup>
<!-- Consumed By Publish -->
<ItemGroup>
<GeneratedInstallers Include="$(SdkPKGInstallerFile);$(CombinedFrameworkSdkHostPKGInstallerFile)" />
</ItemGroup>
<ItemGroup>
<SdkProductArchiveResourcesTemplateFiles Include="$(SdkPkgSourcesRootDirectory)/resources/**/*" />
<GenerateSdkPkgInputs Include="$(SdkInternalLayoutPath)/**/*" />
<GenerateSdkPkgInputs Include="$(SdkPkgScriptsDirectory)/**/*" />
<GenerateSdkProductArchiveInputs Include="$(SdkPKGInstallerFile)" />
<GenerateSdkProductArchiveInputs Include="$(DownloadedSharedFrameworkInstallerFile)" />
<GenerateSdkProductArchiveInputs Include="$(DownloadedHostFxrInstallerFile)" />
<GenerateSdkProductArchiveInputs Include="$(DownloadedSharedHostInstallerFile)" />
<GenerateSdkProductArchiveInputs Include="$(SdkProductArchiveDistributionTemplateFile)" />
<GenerateSdkProductArchiveInputs Include="@(SdkProductArchiveResourcesTemplateFiles)" />
</ItemGroup>
</Target>
<Target Name="GenerateSdkPkg"
Inputs="@(GenerateSdkPkgInputs)"
Outputs="$(SdkPKGInstallerFile)"
DependsOnTargets="GenerateLayout;SetupPkgInputsOutputs"
Condition=" '$(OSName)' == 'osx' ">
<!-- Copy ASP.NET runtime to internal layout, as we don't currently chain that in with a pkg dependency -->
<ExtractArchiveToDirectory SourceArchive="$(DownloadsFolder)$(AspNetCoreSharedFxArchiveFileName)"
DestinationDirectory="$(SdkInternalLayoutPath)" />
<ReplaceFileContents
InputFiles="$(SdkPkgScriptTemplateFile)"
DestinationFiles="$(SdkPkgScriptFile)"
ReplacementPatterns="@(PostInstallScriptReplacement -> '%(Identity)')"
ReplacementStrings="@(PostInstallScriptReplacement -> '%(ReplacementString)')" />
<ReplaceFileContents
InputFiles="@(SdkProductArchiveResourcesTemplateFiles)"
DestinationFiles="@(SdkProductArchiveResourcesTemplateFiles -> '$(SdkProductArchiveResourcesDirectory)/%(RecursiveDir)%(Filename)%(Extension)')"
ReplacementPatterns="@(ResourcesReplacement -> '%(Identity)')"
ReplacementStrings="@(ResourcesReplacement -> '%(ReplacementString)')" />
<Chmod
Glob="$(SdkPkgScriptFile)"
Mode="ugo+x" />
<Exec Command="pkgbuild \
--root '$(SdkInternalLayoutPath)' \
--identifier '$(SdkComponentId)' \
--version '$(SdkVersion)' \
--install-location '$(PkgInstallDirectory)' \
--scripts '$(SdkPkgDestinationScriptsDirectory)' \
'$(SdkPKGInstallerFile)'" />
</Target>
<Target Name="GenerateSdkProductArchive"
Inputs="@(GenerateSdkProductArchiveInputs)"
Outputs="$(CombinedFrameworkSdkHostPKGInstallerFile)"
DependsOnTargets="GenerateSdkPkg"
Condition=" '$(OSName)' == 'osx' ">
<ItemGroup>
<PkgComponentsSourceFiles Include="$(SdkPKGInstallerFile);
$(DownloadsFolder)$(DownloadedSharedFrameworkInstallerFileName);
$(DownloadsFolder)$(DownloadedHostFxrInstallerFileName);
$(DownloadsFolder)$(DownloadedSharedHostInstallerFileName)" />
<PkgComponentsDestinationFiles Include="$(SdkPkgIntermediatePath);
$(SharedFrameworkPkgIntermediatePath);
$(HostFxrPkgIntermediatePath);
$(SharedHostPkgIntermediatePath)" />
</ItemGroup>
<!-- Move ProductArchive pkg components into place with component ids in the filenames -->
<Copy SourceFiles="@(PkgComponentsSourceFiles)" DestinationFiles="@(PkgComponentsDestinationFiles)" />
<!-- Fill out parameters in the Distribution Template -->
<ReplaceFileContents
InputFiles="$(SdkProductArchiveDistributionTemplateFile)"
DestinationFiles="$(SdkProductArchiveDistributionFile)"
ReplacementPatterns="@(DistributionTemplateReplacement -> '%(Identity)')"
ReplacementStrings="@(DistributionTemplateReplacement -> '%(ReplacementString)')" />
<Exec Command="productbuild \
--version '$(SdkVersion)' \
--identifier '$(SdkProductArchiveId)' \
--package-path '$(PkgIntermediateDirectory)' \
--resources '$(SdkProductArchiveResourcesDirectory)' \
--distribution '$(SdkProductArchiveDistributionFile)' \
'$(CombinedFrameworkSdkHostPKGInstallerFile)'" />
</Target>
<Target Name="GeneratePkgs"
DependsOnTargets="GetCurrentRuntimeInformation;
GenerateSdkPkg;
GenerateSdkProductArchive"/>
</Project>