dotnet-installer/build/package/Microsoft.DotNet.Cli.Installer.DEB.targets
2016-08-25 13:19:22 -07:00

216 lines
10 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="Microsoft.DotNet.Cli.Installer.DEB.props" />
<Target Name="GenerateDebs"
DependsOnTargets="Init;
GenerateSdkDeb;
TestSdkDeb;"
Condition=" '$(OSName)' == 'ubuntu' " />
<Target Name="SetupGenerateDebInputsOutputs">
<Exec Command="/usr/bin/env debuild -h" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="DebuildExitCode" />
</Exec>
<!-- Workaround for Ubuntu16 Jenkins https://github.com/dotnet/core-setup/issues/167 -->
<Message Condition=" '$(DebuildPresent)' != 'true' "
Text="Debuild Not found, Debian packages will not be built."
Importance="High" />
<PropertyGroup>
<DebuildPresent>false</DebuildPresent>
<DebuildPresent Condition=" '$(DebuildExitCode)' == '0' ">true</DebuildPresent>
<DotnetDebToolDir></DotnetDebToolDir>
<DotnetDebToolVersion></DotnetDebToolVersion>
<DotnetDebToolPackageSource></DotnetDebToolPackageSource>
<DebianPackagingScript>$(RepoRoot)/scripts/package/package-debian.sh</DebianPackagingScript>
<ManpagesDirectory>$(RepoRoot)/Documentation/manpages</ManpagesDirectory>
<InstallerOutputDirectory>$(PackagesDirectory)</InstallerOutputDirectory>
<SdkInstallerFile>$(InstallerOutputDirectory)/$(ArtifactNameWithVersionSdk)$(InstallerExtension)</SdkInstallerFile>
<SdkDebianPackageName>dotnet-dev-$(SdkVersion)</SdkDebianPackageName>
<SharedFrameworkDebianPackageName>dotnet-sharedframework-$(SharedFrameworkName)-$(SharedFrameworkVersion)</SharedFrameworkDebianPackageName>
<SharedFrameworkDebianPackageName>$(SharedFrameworkDebianPackageName.ToLower())</SharedFrameworkDebianPackageName>
<HostFxrDebianPackageName>dotnet-hostfxr-$(HostFxrVersion)</HostFxrDebianPackageName>
<HostFxrDebianPackageName>$(HostFxrDebianPackageName.ToLower())</HostFxrDebianPackageName>
<SharedHostDebianPackageName>dotnet-host</SharedHostDebianPackageName>
<SdkDebianIntermediateDirectory>$(IntermediateDirectory)/debian/sdk</SdkDebianIntermediateDirectory>
<DebianTestResultsXmlFile>$(SdkDebianIntermediateDirectory)/debian-testResults.xml</DebianTestResultsXmlFile>
<DebianInstalledDirectory>/usr/share/dotnet</DebianInstalledDirectory>
<EndToEndTestDirectory>$(RepoRoot)/test/EndToEnd</EndToEndTestDirectory>
<DotnetDebToolConfigJsonFilePath>$(SdkDebianLayoutOutputDirectory)/$(DotnetDebToolConfigJsonFileName)</DotnetDebToolConfigJsonFilePath>
</PropertyGroup>
<ItemGroup>
<TestSdkDebTaskEnvironmentVariables Include="PATH=$(DebianInstalledDirectory)$(PathListSeparator)$(PATH)" />
<SdkDebianPackageTemplateReplacement Include="SHARED_FRAMEWORK_DEBIAN_PACKAGE_NAME">
<ReplacementString>$(SharedFrameworkDebianPackageName)</ReplacementString>
</SdkDebianPackageTemplateReplacement>
<SdkDebianPackageTemplateReplacement Include="SHARED_FRAMEWORK_NUGET_NAME">
<ReplacementString>$(SharedFrameworkName)</ReplacementString>
</SdkDebianPackageTemplateReplacement>
<SdkDebianPackageTemplateReplacement Include="SHARED_FRAMEWORK_NUGET_VERSION">
<ReplacementString>$(SharedFrameworkVersion)</ReplacementString>
</SdkDebianPackageTemplateReplacement>
<SdkDebianPackageTemplateReplacement Include="SHARED_FRAMEWORK_BRAND_NAME">
<ReplacementString>$(SharedFrameworkBrandName)</ReplacementString>
</SdkDebianPackageTemplateReplacement>
<SdkDebianPackageTemplateReplacement Include="SDK_NUGET_VERSION">
<ReplacementString>$(SdkVersion)</ReplacementString>
</SdkDebianPackageTemplateReplacement>
<SdkDebianPackageTemplateReplacement Include="CLI_SDK_BRAND_NAME">
<ReplacementString>$(SdkBrandName)</ReplacementString>
</SdkDebianPackageTemplateReplacement>
<!-- Consumed By Publish -->
<GeneratedInstallers Include="$(SdkInstallerFile)" />
<SdkDebInputFiles Include="$(SdkLayoutOutputDirectory)/**/*" />
<SdkDebManPageFiles Include="$(ManpagesDirectory)/**/*" />
</ItemGroup>
</Target>
<Target Name="GenerateSdkDeb"
Condition=" '$(OSName)' == 'ubuntu' and '$(DebuildPresent)' == 'true' "
DependsOnTargets="SetupGenerateDebInputsOutputs;
PrepareDotnetDebDirectories;
PrepareDotnetDebTool;"
Inputs="@(SdkDebInputFiles)"
Outputs="$(SdkInstallerFile)" >
<!-- Install Packages -->
<Exec Command="sudo dpkg -i $(DownloadedSharedHostInstallerFile)" />
<Exec Command="sudo dpkg -i $(DownloadedHostFxrInstallerFile)" />
<Exec Command="sudo dpkg -i $(DownloadedSharedFrameworkInstallerFile)" />
<!-- Create layout -->
<Copy
DestinationFiles="@(SourceFile->'$(DebLayoutPackageRootDirName)/%(RecursiveDir)%(Filename)%(Extension)')"
OverwriteReadOnlyFiles="True"
SkipUnchangedFiles="False"
SourceFiles="@(SdkLayoutOutputDirectory)"
UseHardlinksIfPossible="False">
</Copy>
<Copy
DestinationFiles="@(SourceFile->'$(DebLayoutDocsDir)/%(RecursiveDir)%(Filename)-$(SdkVersion)%(Extension)')"
OverwriteReadOnlyFiles="True"
SkipUnchangedFiles="False"
SourceFiles="@(SdkDebManPageFiles)"
UseHardlinksIfPossible="False">
</Copy>
<Copy
DestinationFiles="$(DotnetDebToolConfigJsonFilePath)"
OverwriteReadOnlyFiles="True"
SkipUnchangedFiles="False"
SourceFiles="$(DotnetDebToolConfigJsonFilePath)"
UseHardlinksIfPossible="False">
</Copy>
<DotNetDebTool ToolPath="$(Stage2Directory)"
InputDir="$(SdkLayoutDirectory)"
OutputFile="$(SdkInstallerFile)"
PackageName="$(SdkDebianPackageName)"
PackageVersion="$(SdkVersion)"
WorkingDirectory="$(DotnetDebToolDir)" />
<!-- Remove Packages -->
<Exec Command="sudo dpkg -r $(SdkDebianPackageName)" />
<Exec Command="sudo dpkg -r $(SharedFrameworkDebianPackageName)" />
<Exec Command="sudo dpkg -r $(HostFxrDebianPackageName)" />
<Exec Command="sudo dpkg -r $(SharedHostDebianPackageName)" />
</Target>
<Target Name="TestSdkDeb"
Condition=" '$(OSName)' == 'ubuntu' and '$(DebuildPresent)' == 'true' "
Inputs="$(DownloadedSharedHostInstallerFile);
$(DownloadedHostFxrInstallerFile);
$(DownloadedSharedFrameworkInstallerFile);
$(SdkInstallerFile);"
Outputs="$(DebianTestResultsXmlFile)" >
<!-- Install v(N-1) Packages -->
<Exec Command="sudo dpkg -i $(DownloadedSharedHostInstallerFile)" />
<Exec Command="sudo dpkg -i $(DownloadedHostFxrInstallerFile)" />
<Exec Command="sudo dpkg -i $(DownloadedSharedFrameworkInstallerFile)" />
<Exec Command="sudo dpkg -i $(SdkInstallerFile)" />
<!-- Run E2E -->
<DotNetTest WorkingDirectory="$(EndToEndTestDirectory)"
EnvironmentVariables="@(TestSdkDebTaskEnvironmentVariables)"
ToolPath="$(DebianInstalledDirectory)"
Xml="$(DebianTestResultsXmlFile)" />
<!-- Remove Packages -->
<Exec Command="sudo dpkg -r $(SdkDebianPackageName)" />
<Exec Command="sudo dpkg -r $(SharedFrameworkDebianPackageName)" />
<Exec Command="sudo dpkg -r $(HostFxrDebianPackageName)" />
<Exec Command="sudo dpkg -r $(SharedHostDebianPackageName)" />
</Target>
<Target Name="PrepareDotnetDebDirectories">
<PropertyGroup>
<DebLayoutPackageRootDir>$(SdkDebianLayoutOutputDirectory)/$(DebLayoutPackageRootDirName)</DebLayoutPackageRootDirName>
<DebLayoutAbsolutePlacementDir>$(SdkDebianLayoutOutputDirectory)/$(DebLayoutAbsolutePlacementDirName)</DebLayoutAbsolutePlacementDir>
<DebLayoutSamplesDir>$(SdkDebianLayoutOutputDirectory)/$(DebLayoutSamplesDirName)</DebLayoutSamplesDir>
<DebLayoutDocsDir>$(SdkDebianLayoutOutputDirectory)/$(DebLayoutDocsDirName)</DebLayoutDocsDir>
<DebLayoutDebianFilesDir>$(SdkDebianLayoutOutputDirectory)/$(DebLayoutDebianFilesDirName)</DebLayoutDebianFilesDir>
</PropertyGroup>
<!-- Clean the workspace -->
<ItemGroup>
<SdkDebianFilesToClean Remove="*" />
<SdkDebianFilesToClean Include="$(SdkInstallerFile)" />
<SdkDebianDirectoriesToClean Remove="*" />
<SdkDebianDirectoriesToClean Include="$(SdkDebianIntermediateDirectory);
$(SdkDebianLayoutOutputDirectory)" />
<SdkDebianLayoutSubDirectories Remove="*" />
<SdkDebianLayoutSubDirectories Include="$(DebLayoutPackageRootDir);
$(DebLayoutAbsolutePlacementDir);
$(DebLayoutSamplesDir);
$(DebLayoutDocsDir);
$(DebLayoutDebianFilesDir)" />
</ItemGroup>
<Delete Condition=" 'Exists(%(SdkDebianFilesToClean))' " Files="@(SdkDebianFilesToClean)" />
<RemoveDir Condition=" 'Exists(%(SdkDebianDirectoriesToClean))' " Directories="@(SdkDebianDirectoriesToClean)" />
<MakeDir Directories="@(SdkDebianDirectoriesToClean)" />
<MakeDir Directories="@(SdkDebianLayoutSubDirectories)" />
</Target>
<Target Name="PrepareDotnetDebTool"
DependsOnTargets="WriteDotnetDebToolProjectJson;">
<DotNetRestore FallbackSource="$(DotnetDebToolPackageSource)"
ToolPath="$(Stage2Directory)"
WorkingDirectory="$(DotnetDebToolDir)" />
</Target>
<Target Name="WriteDotnetDebToolProjectJson"
Inputs="$(MSBuildThisFile);$(MSBuildThisFileDirectory)/Microsoft.DotNet.Cli.Installer.DEB.props"
Outputs="$(DotnetDebToolDir)/project.json">
<WriteLinesToFile File="$(DotnetDebToolDir)/project.json" Lines="@(DotnetDebToolProjectJsonLines)" />
</Target>
<Target Name="UpdateDotnetDebConfigFile">
<ReplaceFileContents
InputFile="$(DotnetDebToolConfigJsonFilePath)"
DestinationFile="$(DotnetDebToolConfigJsonFilePath)"
ReplacementPatterns="@(SdkDebianPackageTemplateReplacement -> '%(Identity)')"
ReplacementStrings="@(SdkDebianPackageTemplateReplacement -> '%(ReplacementString)')" />
</Target>
</Project>