WiP
This commit is contained in:
parent
578adf072c
commit
56d2153c08
4 changed files with 180 additions and 168 deletions
|
@ -12,4 +12,14 @@
|
||||||
<DebLayoutDocsDirName>docs</DebLayoutDocsDirName>
|
<DebLayoutDocsDirName>docs</DebLayoutDocsDirName>
|
||||||
<DebLayoutDebianFilesDirName>debian</DebLayoutDebianFilesDirName>
|
<DebLayoutDebianFilesDirName>debian</DebLayoutDebianFilesDirName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<DotnetDebToolProjectJsonLines Remove="*" />
|
||||||
|
<DotnetDebToolProjectJsonLines Include="{" />
|
||||||
|
<DotnetDebToolProjectJsonLines Include="%20%20%20%20"version": "1.0.0-*"," />
|
||||||
|
<DotnetDebToolProjectJsonLines Include="%20%20%20%20"name": "$(DotnetDebToolConsumerProjectName)"," />
|
||||||
|
<DotnetDebToolProjectJsonLines Include="%20%20%20%20"frameworks": { "netcoreapp1.0": {} }," />
|
||||||
|
<DotnetDebToolProjectJsonLines Include="%20%20%20%20"tools": {"$(DotnetDebToolPackageId)": "$(DotnetDebToolVersion)" }" />
|
||||||
|
<DotnetDebToolProjectJsonLines Include="}" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<Import Project="Microsoft.DotNet.Cli.Installer.DEB.props" />
|
<Import Project="Microsoft.DotNet.Cli.Installer.DEB.props" />
|
||||||
|
|
||||||
|
<Target Name="GenerateDebs"
|
||||||
|
DependsOnTargets="Init;
|
||||||
|
GenerateSdkDeb;
|
||||||
|
TestSdkDeb;"
|
||||||
|
Condition=" '$(OSName)' == 'ubuntu' " />
|
||||||
|
|
||||||
<Target Name="SetupGenerateDebInputsOutputs">
|
<Target Name="SetupGenerateDebInputsOutputs">
|
||||||
<Exec Command="/usr/bin/env debuild -h" ContinueOnError="true">
|
<Exec Command="/usr/bin/env debuild -h" ContinueOnError="true">
|
||||||
<Output TaskParameter="ExitCode" PropertyName="DebuildExitCode" />
|
<Output TaskParameter="ExitCode" PropertyName="DebuildExitCode" />
|
||||||
|
@ -12,84 +19,107 @@
|
||||||
Importance="High" />
|
Importance="High" />
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<DebuildPresent>false</DebuildPresent>
|
<DebuildPresent>false</DebuildPresent>
|
||||||
<DebuildPresent Condition=" '$(DebuildExitCode)' == '0' ">true</DebuildPresent>
|
<DebuildPresent Condition=" '$(DebuildExitCode)' == '0' ">true</DebuildPresent>
|
||||||
|
|
||||||
<DotnetDebToolVersion></DotnetDebToolVersion>
|
<DotnetDebToolDir></DotnetDebToolDir>
|
||||||
<DotnetDebToolPackageSource></DotnetDebToolPackageSource>
|
<DotnetDebToolVersion></DotnetDebToolVersion>
|
||||||
|
<DotnetDebToolPackageSource></DotnetDebToolPackageSource>
|
||||||
|
|
||||||
<DebianPackagingScript>$(RepoRoot)/scripts/package/package-debian.sh</DebianPackagingScript>
|
<DebianPackagingScript>$(RepoRoot)/scripts/package/package-debian.sh</DebianPackagingScript>
|
||||||
<ManpagesDirectory>$(RepoRoot)/Documentation/manpages</ManpagesDirectory>
|
<ManpagesDirectory>$(RepoRoot)/Documentation/manpages</ManpagesDirectory>
|
||||||
|
|
||||||
<InstallerOutputDirectory>$(PackagesDirectory)</InstallerOutputDirectory>
|
<InstallerOutputDirectory>$(PackagesDirectory)</InstallerOutputDirectory>
|
||||||
<SdkInstallerFile>$(InstallerOutputDirectory)/$(ArtifactNameWithVersionSdk)$(InstallerExtension)</SdkInstallerFile>
|
<SdkInstallerFile>$(InstallerOutputDirectory)/$(ArtifactNameWithVersionSdk)$(InstallerExtension)</SdkInstallerFile>
|
||||||
|
|
||||||
<SdkDebianPackageName>dotnet-dev-$(SdkVersion)</SdkDebianPackageName>
|
<SdkDebianPackageName>dotnet-dev-$(SdkVersion)</SdkDebianPackageName>
|
||||||
<SharedFrameworkDebianPackageName>dotnet-sharedframework-$(SharedFrameworkName)-$(SharedFrameworkVersion)</SharedFrameworkDebianPackageName>
|
<SharedFrameworkDebianPackageName>dotnet-sharedframework-$(SharedFrameworkName)-$(SharedFrameworkVersion)</SharedFrameworkDebianPackageName>
|
||||||
<SharedFrameworkDebianPackageName>$(SharedFrameworkDebianPackageName.ToLower())</SharedFrameworkDebianPackageName>
|
<SharedFrameworkDebianPackageName>$(SharedFrameworkDebianPackageName.ToLower())</SharedFrameworkDebianPackageName>
|
||||||
<HostFxrDebianPackageName>dotnet-hostfxr-$(HostFxrVersion)</HostFxrDebianPackageName>
|
<HostFxrDebianPackageName>dotnet-hostfxr-$(HostFxrVersion)</HostFxrDebianPackageName>
|
||||||
<HostFxrDebianPackageName>$(HostFxrDebianPackageName.ToLower())</HostFxrDebianPackageName>
|
<HostFxrDebianPackageName>$(HostFxrDebianPackageName.ToLower())</HostFxrDebianPackageName>
|
||||||
<SharedHostDebianPackageName>dotnet-host</SharedHostDebianPackageName>
|
<SharedHostDebianPackageName>dotnet-host</SharedHostDebianPackageName>
|
||||||
|
|
||||||
<SdkDebianIntermediateDirectory>$(IntermediateDirectory)/debian/sdk</SdkDebianIntermediateDirectory>
|
<SdkDebianIntermediateDirectory>$(IntermediateDirectory)/debian/sdk</SdkDebianIntermediateDirectory>
|
||||||
|
|
||||||
<DebianTestResultsXmlFile>$(SdkDebianIntermediateDirectory)/debian-testResults.xml</DebianTestResultsXmlFile>
|
<DebianTestResultsXmlFile>$(SdkDebianIntermediateDirectory)/debian-testResults.xml</DebianTestResultsXmlFile>
|
||||||
<DebianInstalledDirectory>/usr/share/dotnet</DebianInstalledDirectory>
|
<DebianInstalledDirectory>/usr/share/dotnet</DebianInstalledDirectory>
|
||||||
<EndToEndTestDirectory>$(RepoRoot)/test/EndToEnd</EndToEndTestDirectory>
|
<EndToEndTestDirectory>$(RepoRoot)/test/EndToEnd</EndToEndTestDirectory>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<TestSdkDebTaskEnvironmentVariables Include="PATH=$(DebianInstalledDirectory)$(PathListSeparator)$(PATH)" />
|
<TestSdkDebTaskEnvironmentVariables Include="PATH=$(DebianInstalledDirectory)$(PathListSeparator)$(PATH)" />
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Consumed By Publish -->
|
<SdkDebianPackageTemplateReplacement Include="SHARED_FRAMEWORK_DEBIAN_PACKAGE_NAME">
|
||||||
<ItemGroup>
|
<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)" />
|
<GeneratedInstallers Include="$(SdkInstallerFile)" />
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<SdkDebInputFiles Include="$(SdkLayoutOutputDirectory)/**/*" />
|
||||||
<SdkDebInputFiles Include="$(SdkLayoutOutputDirectory)/**/*" />
|
<SdkDebManPageFiles Include="$(ManpagesDirectory)/**/*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="GenerateSdkDeb"
|
<Target Name="GenerateSdkDeb"
|
||||||
Condition=" '$(OSName)' == 'ubuntu' and '$(DebuildPresent)' == 'true' "
|
Condition=" '$(OSName)' == 'ubuntu' and '$(DebuildPresent)' == 'true' "
|
||||||
Inputs="@(SdkDebInputFiles);"
|
DependsOnTargets="SetupGenerateDebInputsOutputs;
|
||||||
|
PrepareDotnetDebDirectories;
|
||||||
|
PrepareDotnetDebTool;"
|
||||||
|
Inputs="@(SdkDebInputFiles)"
|
||||||
Outputs="$(SdkInstallerFile)" >
|
Outputs="$(SdkInstallerFile)" >
|
||||||
|
|
||||||
<!-- Clean the workspace -->
|
|
||||||
<ItemGroup>
|
|
||||||
<SdkDebianFilesToClean Remove="*" />
|
|
||||||
<SdkDebianFilesToClean Include="$(SdkInstallerFile)" />
|
|
||||||
|
|
||||||
<SdkDebianDirectoriesToClean Remove="*" />
|
|
||||||
<SdkDebianDirectoriesToClean Include="$(SdkDebianIntermediateDirectory)" />
|
|
||||||
<SdkDebianDirectoriesToClean Include="$(SdkDebianLayoutOutputDirectory)" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<Delete Condition=" 'Exists(%(SdkDebianFilesToClean))' " Files="%(SdkDebianFilesToClean)" />
|
|
||||||
<RemoveDir Condition=" 'Exists(%(SdkDebianDirectoriesToClean))' " Directories="%(SdkDebianDirectoriesToClean)" />
|
|
||||||
<MakeDir Directories="@(SdkDebianDirectoriesToClean)" />
|
|
||||||
|
|
||||||
<!-- Install Packages -->
|
<!-- Install Packages -->
|
||||||
<Exec Command="sudo dpkg -i $(DownloadedSharedHostInstallerFile)" />
|
<Exec Command="sudo dpkg -i $(DownloadedSharedHostInstallerFile)" />
|
||||||
<Exec Command="sudo dpkg -i $(DownloadedHostFxrInstallerFile)" />
|
<Exec Command="sudo dpkg -i $(DownloadedHostFxrInstallerFile)" />
|
||||||
<Exec Command="sudo dpkg -i $(DownloadedSharedFrameworkInstallerFile)" />
|
<Exec Command="sudo dpkg -i $(DownloadedSharedFrameworkInstallerFile)" />
|
||||||
|
|
||||||
<!-- Create layout -->
|
<!-- 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="@(SourceFile->'$(DebLayoutDocsDir)/%(RecursiveDir)%(Filename)-$(SdkVersion)%(Extension)')"
|
||||||
|
OverwriteReadOnlyFiles="True"
|
||||||
|
SkipUnchangedFiles="False"
|
||||||
|
SourceFiles="@(SdkDebManPageFiles)"
|
||||||
|
UseHardlinksIfPossible="False">
|
||||||
|
</Copy>
|
||||||
|
|
||||||
<Exec Command="'$(DebianPackagingScript)'
|
<DotNetDebTool ToolPath="$(Stage2Directory)"
|
||||||
-v '$(SdkVersion)'
|
InputDir="$(SdkLayoutDirectory)"
|
||||||
-i '$(SdkLayoutOutputDirectory)'
|
OutputFile="$(SdkInstallerFile)"
|
||||||
-o '$(SdkInstallerFile)'
|
PackageName="$(SdkDebianPackageName)"
|
||||||
-p '$(SdkDebianPackageName)'
|
PackageVersion="$(SdkVersion)"
|
||||||
-b '$(SdkBrandName)'
|
WorkingDirectory="$(DotnetDebToolDir)" />
|
||||||
-m '$(ManpagesDirectory)'
|
|
||||||
--framework-debian-package-name '$(SharedFrameworkDebianPackageName)'
|
|
||||||
--framework-nuget-name '$(SharedFrameworkName)'
|
|
||||||
--framework-nuget-version '$(SharedFrameworkVersion)'
|
|
||||||
--obj-root '$(SdkDebianIntermediateDirectory)'" />
|
|
||||||
|
|
||||||
<!-- Remove Packages -->
|
<!-- Remove Packages -->
|
||||||
<Exec Command="sudo dpkg -r $(SdkDebianPackageName)" />
|
<Exec Command="sudo dpkg -r $(SdkDebianPackageName)" />
|
||||||
|
@ -106,7 +136,7 @@
|
||||||
$(SdkInstallerFile);"
|
$(SdkInstallerFile);"
|
||||||
Outputs="$(DebianTestResultsXmlFile)" >
|
Outputs="$(DebianTestResultsXmlFile)" >
|
||||||
|
|
||||||
<!-- Install Packages -->
|
<!-- Install v(N-1) Packages -->
|
||||||
<Exec Command="sudo dpkg -i $(DownloadedSharedHostInstallerFile)" />
|
<Exec Command="sudo dpkg -i $(DownloadedSharedHostInstallerFile)" />
|
||||||
<Exec Command="sudo dpkg -i $(DownloadedHostFxrInstallerFile)" />
|
<Exec Command="sudo dpkg -i $(DownloadedHostFxrInstallerFile)" />
|
||||||
<Exec Command="sudo dpkg -i $(DownloadedSharedFrameworkInstallerFile)" />
|
<Exec Command="sudo dpkg -i $(DownloadedSharedFrameworkInstallerFile)" />
|
||||||
|
@ -125,27 +155,50 @@
|
||||||
<Exec Command="sudo dpkg -r $(SharedHostDebianPackageName)" />
|
<Exec Command="sudo dpkg -r $(SharedHostDebianPackageName)" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="GenerateDebs"
|
<Target Name="PrepareDotnetDebDirectories">
|
||||||
DependsOnTargets="Init;
|
<PropertyGroup>
|
||||||
Layout;
|
<DebLayoutPackageRootDir>$(SdkDebianLayoutOutputDirectory)/$(DebLayoutPackageRootDirName)</DebLayoutPackageRootDirName>
|
||||||
SetupGenerateDebInputsOutputs;
|
<DebLayoutAbsolutePlacementDir>$(SdkDebianLayoutOutputDirectory)/$(DebLayoutAbsolutePlacementDirName)</DebLayoutAbsolutePlacementDir>
|
||||||
GenerateSdkDeb;
|
<DebLayoutSamplesDir>$(SdkDebianLayoutOutputDirectory)/$(DebLayoutSamplesDirName)</DebLayoutSamplesDir>
|
||||||
TestSdkDeb;"
|
<DebLayoutDocsDir>$(SdkDebianLayoutOutputDirectory)/$(DebLayoutDocsDirName)</DebLayoutDocsDir>
|
||||||
Condition=" '$(OSName)' == 'ubuntu' " />
|
<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"
|
<Target Name="PrepareDotnetDebTool"
|
||||||
DependsOnTargets="WriteDotnetDebToolProjectJson;">
|
DependsOnTargets="WriteDotnetDebToolProjectJson;">
|
||||||
|
|
||||||
|
<DotNetRestore FallbackSource="$(DotnetDebToolPackageSource)"
|
||||||
|
ToolPath="$(Stage2Directory)"
|
||||||
|
WorkingDirectory="$(DotnetDebToolDir)" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="WriteDotnetDebToolProjectJson" >
|
<Target Name="WriteDotnetDebToolProjectJson"
|
||||||
<ItemGroup>
|
Inputs="$(MSBuildThisFile);$(MSBuildThisFileDirectory)/Microsoft.DotNet.Cli.Installer.DEB.props"
|
||||||
<AssemblyInfoLines Include="{" />
|
Outputs="$(DotnetDebToolDir)/project.json">
|
||||||
<AssemblyInfoLines Include="%20%20%20%20"version": "1.0.0-*"," />
|
|
||||||
<AssemblyInfoLines Include="%20%20%20%20"name": "$(DotnetDebToolConsumerProjectName)"," />
|
<WriteLinesToFile File="$(DotnetDebToolDir)/project.json" Lines="@(DotnetDebToolProjectJsonLines)" />
|
||||||
<AssemblyInfoLines Include="%20%20%20%20"frameworks": { "netcoreapp1.0": {} }," />
|
|
||||||
<AssemblyInfoLines Include="%20%20%20%20"tools": {{"$(DotnetDebToolPackageId)": "$(DotnetDebToolVersion)" }}" />
|
|
||||||
<AssemblyInfoLines Include="}" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
50
build_projects/dotnet-cli-build/DotNetDebTool.cs
Normal file
50
build_projects/dotnet-cli-build/DotNetDebTool.cs
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Cli.Build
|
||||||
|
{
|
||||||
|
public class DotNetDebTool : DotNetTool
|
||||||
|
{
|
||||||
|
protected override string Command
|
||||||
|
{
|
||||||
|
get { return "deb-tool"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string Args
|
||||||
|
{
|
||||||
|
get { return $"{GetInputDir()} {GetOutputFile()} {GetPackageName()} {GetPackageVersion()}"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string InputDir { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string OutputFile { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string PackageName { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string PackageVersion { get; set; }
|
||||||
|
|
||||||
|
private string GetInputDir()
|
||||||
|
{
|
||||||
|
return $"-i {InputDir}";
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetOutputFile()
|
||||||
|
{
|
||||||
|
return $"-o {OutputFile}";
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetPackageName()
|
||||||
|
{
|
||||||
|
return $"-n {PackageName}";
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetPackageVersion()
|
||||||
|
{
|
||||||
|
return $"-v {PackageVersion}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,22 +11,6 @@ using Microsoft.DotNet.Cli.Build.Framework;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Build
|
namespace Microsoft.DotNet.Cli.Build
|
||||||
{
|
{
|
||||||
public class DebPackageCreator
|
|
||||||
{
|
|
||||||
private string _dotnet;
|
|
||||||
private string _intermediateDirectory;
|
|
||||||
private string _dotnetDebToolVersion;
|
|
||||||
private string _dotnetDebToolPackageSource;
|
|
||||||
private string _consumingProjectDirectory;
|
|
||||||
|
|
||||||
public DebPackageCreator(
|
|
||||||
string dotnet,
|
|
||||||
string intermediateDirectory,
|
|
||||||
string dotnetDebToolVersion,
|
|
||||||
string dotnetDebToolPackageSource = null)
|
|
||||||
{
|
|
||||||
InitializeDotnetDebTool();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateDeb(
|
public void CreateDeb(
|
||||||
string debianConfigJsonFile,
|
string debianConfigJsonFile,
|
||||||
|
@ -57,15 +41,6 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
CreateDebianPackage(debianLayoutDirectories, debIntermediatesDirectory, outputFile, packageName, packageVersion);
|
CreateDebianPackage(debianLayoutDirectories, debIntermediatesDirectory, outputFile, packageName, packageVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateEmptyDebianLayout(DebianLayoutDirectories layoutDirectories)
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(layoutDirectories.AbsolutePlacement);
|
|
||||||
Directory.CreateDirectory(layoutDirectories.PackageRoot);
|
|
||||||
Directory.CreateDirectory(layoutDirectories.Samples);
|
|
||||||
Directory.CreateDirectory(layoutDirectories.Docs);
|
|
||||||
Directory.CreateDirectory(layoutDirectories.DebianFiles);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CopyFilesToDebianLayout(
|
private void CopyFilesToDebianLayout(
|
||||||
DebianLayoutDirectories layoutDirectories,
|
DebianLayoutDirectories layoutDirectories,
|
||||||
string packageVersion,
|
string packageVersion,
|
||||||
|
@ -128,81 +103,5 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
|
|
||||||
File.WriteAllText(debianConfigFile, debianConfigFileContents);
|
File.WriteAllText(debianConfigFile, debianConfigFileContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateDebianPackage(
|
|
||||||
DebianLayoutDirectories debianLayoutDirectories,
|
|
||||||
string intermediatesOutputDirectory,
|
|
||||||
string outputFile,
|
|
||||||
string packageName,
|
|
||||||
string packageVersion)
|
|
||||||
{
|
|
||||||
_dotnet.Exec("deb-tool",
|
|
||||||
"-i", debianLayoutDirectories.LayoutDirectory,
|
|
||||||
"-o", intermediatesOutputDirectory,
|
|
||||||
"-n", packageName,
|
|
||||||
"-v", packageVersion)
|
|
||||||
.WorkingDirectory(_consumingProjectDirectory)
|
|
||||||
.Execute()
|
|
||||||
.EnsureSuccessful();
|
|
||||||
|
|
||||||
var debianFile = Directory.EnumerateFiles(intermediatesOutputDirectory, "*.deb").First();
|
|
||||||
File.Copy(debianFile, outputFile, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InitializeDotnetDebTool()
|
|
||||||
{
|
|
||||||
CreateAndRestoreToolConsumingProject();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CreateAndRestoreToolConsumingProject()
|
|
||||||
{
|
|
||||||
if (Directory.Exists(_consumingProjectDirectory))
|
|
||||||
{
|
|
||||||
FS.Rmdir(_consumingProjectDirectory);
|
|
||||||
}
|
|
||||||
FS.Mkdirp(_consumingProjectDirectory);
|
|
||||||
|
|
||||||
var projectJsonFile = Path.Combine(_consumingProjectDirectory, "project.json");
|
|
||||||
File.WriteAllText(projectJsonFile, GetDotnetDebProjectJsonContents());
|
|
||||||
|
|
||||||
Command restore = _dotnetDebToolPackageSource == null
|
|
||||||
? _dotnet.Restore()
|
|
||||||
: _dotnet.Restore("-f", $"{_dotnetDebToolPackageSource}");
|
|
||||||
|
|
||||||
restore
|
|
||||||
.WorkingDirectory(Path.GetDirectoryName(projectJsonFile))
|
|
||||||
.Execute()
|
|
||||||
.EnsureSuccessful();
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetDotnetDebProjectJsonContents()
|
|
||||||
{
|
|
||||||
var projectJson = new StringBuilder();
|
|
||||||
projectJson.Append("{");
|
|
||||||
projectJson.Append($" \"version\": \"1.0.0-*\",");
|
|
||||||
projectJson.Append($" \"name\": \"{s_toolConsumerProjectName}\",");
|
|
||||||
projectJson.Append(" \"frameworks\": { \"netcoreapp1.0\": { } },");
|
|
||||||
projectJson.Append($" \"tools\": {{ \"{s_dotnetDebToolPackageId}\": \"{_dotnetDebToolVersion}\" }},");
|
|
||||||
projectJson.Append("}");
|
|
||||||
|
|
||||||
return projectJson.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DebianLayoutDirectories
|
|
||||||
{
|
|
||||||
private string _layoutDirectory;
|
|
||||||
|
|
||||||
public DebianLayoutDirectories(string layoutDirectory)
|
|
||||||
{
|
|
||||||
_layoutDirectory = layoutDirectory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string LayoutDirectory => _layoutDirectory;
|
|
||||||
public string PackageRoot => Path.Combine(_layoutDirectory, "package_root");
|
|
||||||
public string AbsolutePlacement => Path.Combine(_layoutDirectory, "$");
|
|
||||||
public string Samples => Path.Combine(_layoutDirectory, "samples");
|
|
||||||
public string Docs => Path.Combine(_layoutDirectory, "docs");
|
|
||||||
public string DebianFiles => Path.Combine(_layoutDirectory, "debian");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue