Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Linux installers for the aspnetcore targeting pack #7776

Merged
merged 12 commits into from
Feb 25, 2019
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

<Authors>Microsoft</Authors>
<Company>Microsoft Corporation.</Company>
<RpmPackageVendor>.NET Foundation</RpmPackageVendor>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<NeutralLanguage>en-US</NeutralLanguage>

Expand Down
4 changes: 2 additions & 2 deletions build/SharedFx.targets
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<FxProjectToBuild Include="$(UnitTestFxProject)" />
<FxProjectToBuild Condition=" '$(BuildRuntimeArchive)' != 'false' " Include="$(RepositoryRoot)src\Installers\Archive\*.*proj" />

<FxProjectToBuild Condition=" '$(TargetRuntimeIdentifier)' == 'linux-x64' AND '$(LinuxInstallerType)' == 'deb' " Include="$(RepositoryRoot)src\Installers\Debian\*.*proj" />
<FxProjectToBuild Condition=" '$(TargetRuntimeIdentifier)' == 'linux-x64' AND '$(LinuxInstallerType)' == 'rpm' " Include="$(RepositoryRoot)src\Installers\Rpm\*.*proj" />
<FxProjectToBuild Condition=" '$(TargetRuntimeIdentifier)' == 'linux-x64' AND '$(LinuxInstallerType)' == 'deb' " Include="$(RepositoryRoot)src\Installers\Debian\**\*.*proj" />
<FxProjectToBuild Condition=" '$(TargetRuntimeIdentifier)' == 'linux-x64' AND '$(LinuxInstallerType)' == 'rpm' " Include="$(RepositoryRoot)src\Installers\Rpm\**\*.*proj" />

<FxProjectToBuild Condition=" '$(BuildSiteExtensions)' == 'true' " Include="$(RepositoryRoot)src\SiteExtensions\Runtime\Microsoft.AspNetCore.Runtime.SiteExtension.pkgproj" />
<FxProjectToBuild Condition=" '$(BuildSiteExtensions)' == 'true' " Include="$(RepositoryRoot)src\SiteExtensions\LoggingBranch\LoggingBranch.csproj" />
Expand Down
16 changes: 16 additions & 0 deletions dockerbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ fi
dockerfile="$DIR/build/docker/$image.Dockerfile"
tagname="aspnetcore-build-$image"

# Use docker pull with retries to pre-pull the image need by the dockerfile
# docker build regularly fails with TLS handshake issues for unclear reasons.
base_imagename="$(grep -E -o 'FROM (.*)' $dockerfile | cut -c 6-)"
pull_retries=3
while [ $pull_retries -gt 0 ]; do
failed=false
docker pull $base_imagename || failed=true
if [ "$failed" = true ]; then
let pull_retries=pull_retries-1
echo -e "${YELLOW}Failed to pull $base_imagename Retries left: $pull_retries.${RESET}"
sleep 1
else
pull_retries=0
fi
done

docker build "$(dirname "$dockerfile")" \
--build-arg "USER=$(whoami)" \
--build-arg "USER_ID=$(id -u)" \
Expand Down
6 changes: 5 additions & 1 deletion eng/scripts/KillProcesses.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ _kill git.exe
_kill vctip.exe
_kill chrome.exe
_kill h2spec.exe
iisreset /restart
_kill WerFault.exe
if (Get-Command iisreset -ErrorAction ignore) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Fortunately, the command only writes to stdout when process lacks admin rights.

iisreset /restart
}
Stop-Service w3svc -NoWait -ErrorAction Ignore

exit 0
20 changes: 14 additions & 6 deletions src/Framework/ref/Microsoft.AspNetCore.App.Ref.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
<PropertyGroup>
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
<IsShippingPackage>true</IsShippingPackage>
<IsPackable>true</IsPackable>
<IsPackable Condition="'$(IsTargetingPackBuilding)' == 'false'">false</IsPackable>
<PackageId>$(TargetingPackName)</PackageId>
<PackageVersion>$(TargetingPackVersion)</PackageVersion>

<PackageDescription>Provides a default set of APIs for building an ASP.NET Core application. Contains reference assemblies, documentation, and other design-time assets.

This package is an internal implementation of the .NET Core SDK and is not meant to be used as a normal PackageReference.</PackageDescription>
Expand All @@ -22,7 +25,8 @@ This package is an internal implementation of the .NET Core SDK and is not meant
<RefAssemblyPackagePath>ref/$(TargetFramework)/</RefAssemblyPackagePath>

<LayoutTargetDir>$(TargetingPackLayoutRoot)packs/Microsoft.AspNetCore.App.Ref/$(PackageVersion)/</LayoutTargetDir>
<ArchiveOutputFileName>aspnetcore-targeting-pack-$(PackageVersion).zip</ArchiveOutputFileName>
<ArchiveOutputFileName Condition="'$(TargetRuntimeIdentifier)' == 'win-x64'">aspnetcore-targeting-pack-$(PackageVersion).zip</ArchiveOutputFileName>
<ArchiveOutputFileName Condition="'$(TargetRuntimeIdentifier)' == 'linux-x64'">aspnetcore-targeting-pack-$(PackageVersion).tar.gz</ArchiveOutputFileName>
<ArchiveOutputPath>$(InstallersOutputPath)$(ArchiveOutputFileName)</ArchiveOutputPath>

<!-- There are no symbols for reference assemblies. -->
Expand Down Expand Up @@ -54,7 +58,8 @@ This package is an internal implementation of the .NET Core SDK and is not meant
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<BuildDependsOn>
<!-- If this project won't produce a package, don't bother building anything. -->
<BuildDependsOn Condition="'$(IsPackable)' != 'false'">
$(BuildDependsOn);
GeneratePackageConflictManifest;
_ResolveTargetingPackContent;
Expand Down Expand Up @@ -123,12 +128,15 @@ This package is an internal implementation of the .NET Core SDK and is not meant

<Target Name="_CreateTargetingPackArchive"
Inputs="@(RefPackContent)"
Outputs="$(ArchiveOutputPath)"
Condition="'$(IsPackable)' != 'false'">
Outputs="$(ArchiveOutputPath)">
<ZipDirectory
SourceDirectory="$(TargetingPackLayoutRoot)"
DestinationFile="$(ArchiveOutputPath)"
Overwrite="true" />
Overwrite="true"
Condition="'$(TargetRuntimeIdentifier)' == 'win-x64'" />
<Exec
Command="tar -czf $(ArchiveOutputPath) -C $(TargetingPackLayoutRoot) ."
Condition="'$(TargetRuntimeIdentifier)' == 'linux-x64'" />
</Target>

</Project>
1 change: 0 additions & 1 deletion src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<RuntimeIdentifier>$(TargetRuntimeIdentifier)</RuntimeIdentifier>
<!-- Even though RuntimeIdentifier is set, shared framework projects are not self-contained projects -->
<SelfContained>false</SelfContained>
<SharedFxName>Microsoft.AspNetCore.App</SharedFxName>
<PackageId>$(MSBuildProjectName).$(RuntimeIdentifier)</PackageId>
<IsShippingPackage>true</IsShippingPackage>
<HasReferenceAssembly>false</HasReferenceAssembly>
Expand Down
23 changes: 23 additions & 0 deletions src/Installers/Debian/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project>
<PropertyGroup>
<OutputInRepoRoot>true</OutputInRepoRoot>
</PropertyGroup>

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.props))\Directory.Build.props" />

<UsingTask Condition=" '$(BuildToolsTaskAssembly)' != '' AND Exists('$(BuildToolsTaskAssembly)') " TaskName="Microsoft.AspNetCore.BuildTools.GenerateFileFromTemplate" AssemblyFile="$(BuildToolsTaskAssembly)" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't this defined in some common location?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the Linux installer projects use these tasks directly.


<PropertyGroup>
<OutputPath>$(InstallersOutputPath)</OutputPath>
<IntermediateOutputPath>$(IntermediateOutputPath)$(TargetRuntimeIdentifier)\</IntermediateOutputPath>
<!-- Must be named "package_root/". This is expected by the build.sh script in the tools folder. -->
<IntermediatePackageRoot>$(IntermediateOutputPath)package_root\</IntermediatePackageRoot>

<!-- Installer settings -->
<DebianPackageInstallRoot>/usr/share/dotnet</DebianPackageInstallRoot>

<DebianPackageArch Condition=" '$(TargetArchitecture)' == 'x64' ">amd64</DebianPackageArch>

<DebianBuildScript>$(MSBuildThisFileDirectory)tools/build.sh</DebianBuildScript>
</PropertyGroup>
</Project>
58 changes: 58 additions & 0 deletions src/Installers/Debian/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<Project>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.targets))\Directory.Build.targets" />

<PropertyGroup>
<TargetPath>$(OutputPath)$(TargetFileName)</TargetPath>
<DebBuildDependsOn>
$(DebBuildDependsOn);
PrepareForBuild;
ResolveProjectReferences;
GetTargetPath;
</DebBuildDependsOn>
</PropertyGroup>

<Target Name="PrepareForBuild">
<Error Text="Currently only linux-x64 is supported by Debian installers." Condition=" '$(TargetRuntimeIdentifier)' != 'linux-x64' " />

<MakeDir Directories="$(IntermediateOutputPath);$(IntermediatePackageRoot);$(OutputPath)" />
</Target>

<Target Name="GetTargetPath" Returns="$(TargetPath)" />

<Target Name="Build" DependsOnTargets="DebBuild" />

<Target Name="DebBuild" DependsOnTargets="$(DebBuildDependsOn)">
<!-- Generate debian_config.json. We can't simply use WriteLinesToFile because of https://github.com/Microsoft/msbuild/issues/1622. Use our custom GenerateFileFromTemplate task instead -->
<PropertyGroup>
<DebianConfigProperties>
$(DebianConfigProperties);
AspNetCoreMajorVersion=$(AspNetCoreMajorVersion);
AspNetCoreMinorVersion=$(AspNetCoreMinorVersion);
Authors=$(Authors);
DebianPackageInstallRoot=$(DebianPackageInstallRoot);
MaintainerEmail=$(MaintainerEmail);
PackageId=$(PackageId);
PackageLicenseType=$(PackageLicenseType);
PackageProjectUrl=$(PackageProjectUrl);
PackageRevision=$(PackageRevision);
PackageVersion=$(PackageVersion);
PackageSummary=$(PackageSummary);
PackageDescription=$(PackageDescription);
</DebianConfigProperties>
</PropertyGroup>

<GenerateFileFromTemplate TemplateFile="debian_config.json.in"
Properties="$(DebianConfigProperties)"
OutputPath="$(IntermediateOutputPath)debian_config.json" />

<!-- Build SharedFx Bundle Deb package -->

<Exec Command="$(DebianBuildScript) -i '$(IntermediateOutputPath)' -o '$(IntermediateOutputPath)out/'" />

<PropertyGroup>
<BuildScriptOutputFileName>$(PackageId)_$(PackageVersion)-$(PackageRevision)_$(DebianPackageArch).deb</BuildScriptOutputFileName>
</PropertyGroup>

<Copy SourceFiles="$(IntermediateOutputPath)out/$(BuildScriptOutputFileName)" DestinationFiles="$(TargetPath)" />
</Target>
</Project>
105 changes: 0 additions & 105 deletions src/Installers/Debian/Runtime.debproj

This file was deleted.

56 changes: 56 additions & 0 deletions src/Installers/Debian/Runtime/Debian.Runtime.debproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!--
This project produces a debian installer for Linux x64 platforms only.
-->
<Project DefaultTargets="Build">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />

<PropertyGroup>
<TargetFileName>$(RuntimeInstallerBaseName)-$(SharedFxVersion)-x64.deb</TargetFileName>

<!-- CLI would take a dependency such as 'aspnetcore-runtime-M.N >= M.N.P'. Here M.N is part of the id and M.N.P is the PackageVersion -->
<PackageId>$(RuntimeInstallerBaseName)-$(AspNetCoreMajorVersion).$(AspNetCoreMinorVersion)</PackageId>

<!-- PackageVersion does not match the ASP.NET Core runtime verison. -->
<PackageVersion>$(AspNetCoreMajorVersion).$(AspNetCoreMinorVersion).$(AspNetCorePatchVersion)</PackageVersion>
<!-- Deb installers are versioned as M.N.P~PreReleaseLabel-Build following the core-setup convention -->
<PackageVersion Condition="'$(IncludePreReleaseLabelInPackageVersion)' == 'true'">$(PackageVersion)~$(VersionSuffix)</PackageVersion>
<PackageRevision>1</PackageRevision>

<!-- Needed some creativity to convert the PackageVersion M.N.P-PreReleaseLabel-Build to the installer version M.N.P~PreReleaseLabel-Build, The conditional handles stabilized builds -->
<DotnetRuntimeDependencyVersion>$(MicrosoftNETCoreAppPackageVersion)</DotnetRuntimeDependencyVersion>
<DotnetRuntimeDependencyVersion Condition="$(DotnetRuntimeDependencyVersion.Contains('-'))">$(DotnetRuntimeDependencyVersion.Substring(0, $(DotnetRuntimeDependencyVersion.IndexOf('-'))))~$(DotnetRuntimeDependencyVersion.Substring($([MSBuild]::Add($(DotnetRuntimeDependencyVersion.IndexOf('-')), 1))))</DotnetRuntimeDependencyVersion>

<PackageSummary>$(SharedFxProductName)</PackageSummary>
<PackageDescription>$(SharedFxDescription)</PackageDescription>
<DebianConfigProperties>
DotnetRuntimeDependencyVersion=$(DotnetRuntimeDependencyVersion);
</DebianConfigProperties>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Framework\src\Microsoft.AspNetCore.App.shfxproj">
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
<OutputItemType>_ResolvedFxProjects</OutputItemType>
</ProjectReference>
</ItemGroup>

<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />

<PropertyGroup>
<DebBuildDependsOn>$(DebBuildDependsOn);LayoutSharedFramework</DebBuildDependsOn>
</PropertyGroup>

<Target Name="LayoutSharedFramework" DependsOnTargets="PrepareForBuild;ResolveProjectReferences">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is completely duplicated in between both installer projects. Worth to move to common targets?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Figured it wasn't worth de-duplicating because it will be deleted in #7832 anyways.

<!-- Layout files in package_root/ for the build.sh script. -->
<ItemGroup>
<SharedFxAssetFolder Include="%(_ResolvedFxProjects.InstallerAssetPaths)" SharedFxName="%(_ResolvedFxProjects.SharedFxName)" />
<PackageFiles Include="%(SharedFxAssetFolder.Identity)\**\*" Condition="'%(SharedFxAssetFolder.Identity)' != ''">
<DestinationDir>$(IntermediatePackageRoot)shared\%(SharedFxAssetFolder.SharedFxName)\$(SharedFxVersion)\</DestinationDir>
</PackageFiles>
</ItemGroup>

<Copy SourceFiles="@(PackageFiles)"
DestinationFiles="@(PackageFiles->'%(DestinationDir)%(RecursiveDir)%(FileName)%(Extension)')"
UseHardlinksIfPossible="true" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"package_name": "${PackageId}",
"install_root": "${DebianPackageInstallRoot}",

"short_description": "${SharedFxProductName}",
"long_description": "${SharedFxDescription}",
"short_description": "${PackageSummary}",
"long_description": "${PackageDescription}",
"homepage": "${PackageProjectUrl}",

"release":{
Expand Down
Loading