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 all 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
9 changes: 7 additions & 2 deletions .azure/pipelines/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,11 @@ jobs:
--arch x64 \
-e KOREBUILD_SKIP_INSTALL_NETFX=0 \
--no-restore \
--no-build-deps \
/t:BuildSharedFx \
/p:BuildRuntimeArchive=false \
/p:LinuxInstallerType=deb
/p:LinuxInstallerType=deb \
/bl:artifacts/logs/build.deb.binlog
displayName: Build Debian installers
- script: |
rm -rf .dotnet/
Expand All @@ -175,9 +177,12 @@ jobs:
--ci --pack --all --no-build-nodejs --no-build-java \
--arch x64 \
-e KOREBUILD_SKIP_INSTALL_NETFX=0 \
--no-restore \
--no-build-deps \
/t:BuildSharedFx \
/p:BuildRuntimeArchive=false \
/p:LinuxInstallerType=rpm
/p:LinuxInstallerType=rpm \
/bl:artifacts/logs/build.rpm.binlog
displayName: Build RPM installers
afterBuild:
# Remove packages that are not rid-specific.
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ StyleCop.Cache
node_modules/
*.snk
.nuget
.packages/
.r
.w
.deps
Expand Down
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
27 changes: 18 additions & 9 deletions src/Framework/ref/Microsoft.AspNetCore.App.Ref.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<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 +26,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 +59,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 All @@ -65,9 +71,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant

<!-- Override the default MSBuild targets so that nothing is returned from the project since it represents a collection of assemblies. -->
<Target Name="GetTargetPath" />
<Target Name="Build" DependsOnTargets="$(BuildDependsOn)">
<Message Importance="High" Text="$(MSBuildProjectName) -> $(TargetDir)" />
</Target>
<Target Name="Build" DependsOnTargets="$(BuildDependsOn)" />

<!-- This project doesn't compile anything. -->
<Target Name="CoreCompile" />
Expand Down Expand Up @@ -115,20 +119,25 @@ This package is an internal implementation of the .NET Core SDK and is not meant
DependsOnTargets="_ResolveTargetingPackContent"
Inputs="@(RefPackContent)"
Outputs="@(RefPackContent->'$(LayoutTargetDir)%(PackagePath)%(FileName)%(Extension)')">

<Copy SourceFiles="@(RefPackContent)"
DestinationFiles="@(RefPackContent->'$(LayoutTargetDir)%(PackagePath)%(FileName)%(Extension)')"
UseHardlinksIfPossible="true" />
<Message Importance="High" Text="$(MSBuildProjectName) -> $(LayoutTargetDir)" />
</Target>

<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) ."
WorkingDirectory="$(TargetingPackLayoutRoot)"
Condition="'$(TargetRuntimeIdentifier)' == 'linux-x64'" />
<Message Importance="High" Text="$(MSBuildProjectName) -> $(ArchiveOutputPath)" />
</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.

Loading