dotnet-installer/build/package/Microsoft.DotNet.Cli.Installer.DEB.proj
2016-08-27 15:57:14 -07:00

173 lines
7.3 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
DefaultTarget="GenerateDebs">
<PropertyGroup>
<CLIBuildDll Condition=" '!Exists($(CLIBuildDll))' ">$([MSBuild]::Unescape($(CLIBuildDll)))</CLIBuildDll>
</PropertyGroup>
<UsingTask TaskName="DotNetRestore" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="ReplaceFileContents" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="DotNetDebTool" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="DotNetTest" AssemblyFile="$(CLIBuildDll)" />
<Import Project="Microsoft.DotNet.Cli.Installer.DEB.props" />
<Target Name="GenerateDebs"
DependsOnTargets="TestDebuild;
GenerateSdkDeb;
TestSdkDeb;"
Condition=" '$(OSName)' == 'ubuntu' " />
<Target Name="GenerateSdkDeb"
Condition=" '$(OSName)' == 'ubuntu' and '$(DebuildPresent)' == 'true' "
DependsOnTargets="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="@(SdkDebInputFiles->'$(DebLayoutPackageRootDir)/sdk/%(RecursiveDir)%(Filename)%(Extension)')"
SourceFiles="@(SdkDebInputFiles)"
OverwriteReadOnlyFiles="True"
SkipUnchangedFiles="False"
UseHardlinksIfPossible="False">
</Copy>
<Copy
DestinationFiles="@(SdkDebManPageFiles->'$(DebLayoutDocsDir)/%(RecursiveDir)%(Filename)-$(SdkVersion)%(Extension)')"
SourceFiles="@(SdkDebManPageFiles)"
OverwriteReadOnlyFiles="True"
SkipUnchangedFiles="False"
UseHardlinksIfPossible="False">
</Copy>
<ReplaceFileContents
InputFile="$(DebianConfigTemplateFile)"
DestinationFile="$(DebianConfigJsonFile)"
ReplacementPatterns="@(SdkDebianPackageTemplateReplacement -> '%(Identity)')"
ReplacementStrings="@(SdkDebianPackageTemplateReplacement -> '%(ReplacementString)')" />
<MakeDir Directories="$(DotNetDebToolOutputDirectory)" />
<DotNetDebTool ToolPath="$(ToolPath)"
InputDir="$(SdkDebianLayoutOutputDirectory)"
OutputFile="$(DotNetDebToolOutputDirectory)"
PackageName="$(SdkDebianPackageName)"
PackageVersion="$(SdkVersion)"
WorkingDirectory="$(DotnetDebToolDir)" />
<!-- Copy package to output -->
<ItemGroup>
<GeneratedDebFiles Include="$(DotNetDebToolOutputDirectory)/*.deb" />
</ItemGroup>
<Error Text="@(GeneratedDebFiles->Count()) .deb files generated." Condition="'@(GeneratedDebFiles->Count())' != 1" />
<Copy
DestinationFiles="$(SdkInstallerFile)"
SourceFiles="@(GeneratedDebFiles)"
OverwriteReadOnlyFiles="True"
SkipUnchangedFiles="False"
UseHardlinksIfPossible="False" />
<!-- 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">
<!-- 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 Files="@(SdkDebianFilesToClean)" />
<RemoveDir Directories="@(SdkDebianDirectoriesToClean)" />
<MakeDir Directories="@(SdkDebianDirectoriesToClean)" />
<MakeDir Directories="@(SdkDebianLayoutSubDirectories)" />
</Target>
<Target Name="PrepareDotnetDebTool"
DependsOnTargets="WriteDotnetDebToolProjectJson;">
<DotNetRestore FallbackSource="$(DotnetDebToolPackageSource)"
ToolPath="$(ToolPath)"
WorkingDirectory="$(DotnetDebToolDir)" />
</Target>
<Target Name="WriteDotnetDebToolProjectJson"
Inputs="$(MSBuildThisFile);$(MSBuildThisFileDirectory)/Microsoft.DotNet.Cli.Installer.DEB.props"
Outputs="$(DotnetDebToolDir)/project.json">
<MakeDir Condition=" !Exists($(DotnetDebToolDir)) " Directories="$(DotnetDebToolDir)" />
<WriteLinesToFile File="$(DotnetDebToolDir)/project.json"
Lines="@(DotnetDebToolProjectJsonLines)"
Overwrite="True" />
</Target>
<Target Name="TestDebuild">
<Exec Command="/usr/bin/env debuild -h" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="DebuildExitCode" />
</Exec>
<!-- Debuild -->
<PropertyGroup>
<DebuildPresent>false</DebuildPresent>
<DebuildPresent Condition=" '$(DebuildExitCode)' == '0' ">true</DebuildPresent>
</PropertyGroup>
<!-- 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" />
</Target>
</Project>