dotnet-installer/build/package/Microsoft.DotNet.Cli.Installer.DEB.proj
Eric Erhardt 5227896d0f Fix Ubuntu16.10 BuildSdkDeb
We need to replace a string with string.Empty in the debian .json file. Fixing ReplaceFileContents to support this scenario.
2017-02-23 15:29:11 -06:00

191 lines
7.9 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="DotNetDebTool" AssemblyFile="$(CLIBuildDll)" />
<Import Project="Microsoft.DotNet.Cli.Installer.DEB.targets" />
<Target Name="GenerateDebs"
DependsOnTargets="SetupDebProps;
TestDebuild;
BuildSdkDeb;
TestSdkDeb;"
Condition=" '$(OSName)' == 'ubuntu' "
Outputs="@(GeneratedInstallers)"/>
<Target Name="BuildSdkDeb"
Condition=" '$(OSName)' == 'ubuntu' and '$(DebuildPresent)' == 'true' "
DependsOnTargets="PrepareDotnetDebDirectories;
PrepareDotnetDebTool;"
Inputs="@(CLISdkFiles)"
Outputs="$(SdkInstallerFile)" >
<!-- Install Shared Framework Packages -->
<Exec Command="sudo dpkg -i $(DownloadedSharedHostInstallerFile)" />
<Exec Command="sudo dpkg -i $(DownloadedHostFxrInstallerFile)" />
<Exec Command="sudo dpkg -i $(DownloadedSharedFrameworkInstallerFile)" />
<!-- Create layout: Binaries -->
<Copy
DestinationFiles="@(CLISdkFiles->'$(LayoutPackageRootDir)/sdk/%(RecursiveDir)%(Filename)%(Extension)')"
SourceFiles="@(CLISdkFiles)"
OverwriteReadOnlyFiles="True"
SkipUnchangedFiles="False"
UseHardlinksIfPossible="False" />
<!-- Create layout: Man Pages -->
<Copy
DestinationFiles="@(SdkDebManPageFiles->'$(LayoutDocsDir)/%(RecursiveDir)%(Filename)-$(SdkVersion)%(Extension)')"
SourceFiles="@(SdkDebManPageFiles)"
OverwriteReadOnlyFiles="True"
SkipUnchangedFiles="False"
UseHardlinksIfPossible="False" />
<!-- Create layout: Generate and Place debian_config.json -->
<ReplaceFileContents
InputFile="$(DebianConfigTemplateFile)"
DestinationFile="$(DebianConfigJsonFile)"
ReplacementItems="@(DebianConfigTokenValues)" />
<!-- Build SDK Deb package -->
<DotNetDebTool ToolPath="$(Stage0Directory)"
InputDirectory="$(LayoutDirectory)"
OutputDirectory="$(DotNetDebToolOutputDirectory)"
PackageName="$(SdkDebianPackageName)"
PackageVersion="$(SdkVersion)"
WorkingDirectory="$(DotnetDebToolDir)" />
<!-- Copy SDK 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 Shared Framework and Debian Packages -->
<Exec Command="sudo dpkg -r $(SdkDebianPackageName)" />
<Exec Command="sudo dpkg -r $(SharedFxDebianPackageName)" />
<Exec Command="sudo dpkg -r $(HostFxrDebianPackageName)" />
<Exec Command="sudo dpkg -r $(AdditionalSharedFxDebianPackageName)"
Condition="'$(IncludeAdditionalSharedFrameworks)' == 'true'" />
<Exec Command="sudo dpkg -r $(AdditionalHostFxrDebianPackageName)"
Condition="'$(IncludeAdditionalSharedFrameworks)' == 'true'" />
<Exec Command="sudo dpkg -r $(HostDebianPackageName)" />
</Target>
<Target Name="TestSdkDeb"
Condition=" '$(OSName)' == 'ubuntu' and '$(DebuildPresent)' == 'true' "
Inputs="$(DownloadedSharedHostInstallerFile);
$(DownloadedHostFxrInstallerFile);
$(DownloadedSharedFrameworkInstallerFile);
$(SdkInstallerFile);"
Outputs="$(DebianTestResultsXmlFile)" >
<!-- Install Dependencies and SDK Packages -->
<Exec Command="sudo dpkg -i $(AdditionalDownloadedSharedHostInstallerFile)"
Condition="'$(IncludeAdditionalSharedFrameworks)' == 'true'" />
<Exec Command="sudo dpkg -i $(AdditionalDownloadedHostFxrInstallerFile)"
Condition="'$(IncludeAdditionalSharedFrameworks)' == 'true'" />
<Exec Command="sudo dpkg -i $(AdditionalDownloadedSharedFrameworkInstallerFile)"
Condition="'$(IncludeAdditionalSharedFrameworks)' == 'true'" />
<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 -->
<DotNetRestore ProjectPath="$(EndToEndTestProject)"
ToolPath="$(DebianInstalledDirectory)" />
<DotNetTest ProjectPath="$(EndToEndTestProject)"
EnvironmentVariables="@(TestSdkDebTaskEnvironmentVariables)"
ToolPath="$(DebianInstalledDirectory)" />
<!-- Clean up Packages -->
<Exec Command="sudo dpkg -r $(SdkDebianPackageName)" />
<Exec Command="sudo dpkg -r $(SharedFxDebianPackageName)" />
<Exec Command="sudo dpkg -r $(HostFxrDebianPackageName)" />
<Exec Command="sudo dpkg -r $(AdditionalSharedFxDebianPackageName)"
Condition="'$(IncludeAdditionalSharedFrameworks)' == 'true'" />
<Exec Command="sudo dpkg -r $(AdditionalHostFxrDebianPackageName)"
Condition="'$(IncludeAdditionalSharedFrameworks)' == 'true'" />
<Exec Command="sudo dpkg -r $(HostDebianPackageName)" />
</Target>
<Target Name="PrepareDotnetDebDirectories">
<!-- Clean the workspace -->
<ItemGroup>
<FilesToClean Remove="*" />
<FilesToClean Include="$(SdkInstallerFile)" />
<WorkspaceDirectories Remove="*" />
<WorkspaceDirectories Include="$(SdkDebianIntermediateDirectory);
$(LayoutDirectory)" />
<LayoutSubDirectories Remove="*" />
<LayoutSubDirectories Include="$(LayoutPackageRootDir);
$(LayoutAbsolutePlacementDir);
$(LayoutSamplesDir);
$(LayoutDocsDir);
$(LayoutDebianFilesDir)" />
</ItemGroup>
<Delete Files="@(FilesToClean)" />
<RemoveDir Directories="@(WorkspaceDirectories)" />
<!-- Rebuild the workspace -->
<MakeDir Directories="@(WorkspaceDirectories)" />
<MakeDir Directories="@(LayoutSubDirectories)" />
<MakeDir Directories="$(DotNetDebToolOutputDirectory)" />
</Target>
<Target Name="PrepareDotnetDebTool"
DependsOnTargets="WriteDotnetDebToolProject">
<DotNetRestore ToolPath="$(Stage0Directory)"
WorkingDirectory="$(DotnetDebToolDir)" />
</Target>
<Target Name="WriteDotnetDebToolProject"
Inputs="$(MSBuildThisFileDirectory)/$(DotnetDebToolConsumerProjectName)"
Outputs="$(DotnetDebToolDir)/$(DotnetDebToolConsumerProjectName)">
<Copy SourceFiles="$(MSBuildThisFileDirectory)/$(DotnetDebToolConsumerProjectName)"
DestinationFiles="$(DotnetDebToolDir)/$(DotnetDebToolConsumerProjectName)" />
</Target>
<Target Name="TestDebuild">
<Message Text="Don't remove this" />
<!-- run Debuild -->
<Exec Command="/usr/bin/env debuild -h" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="DebuildExitCode" />
</Exec>
<!-- Check if it returned 0 -->
<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>