Skip to content

Commit

Permalink
Fix Deb/RPM package build
Browse files Browse the repository at this point in the history
This includes simplifying dotnet-deb-tool from a tool package to an ordinary project. This avoids two complications: tool packages used by DotNetCliToolReference can only target .NET Core 2.2 and below, and the Pack requirements are more involved with the new SDK.

Adds some new '<project> -> <artifact>' log lines. It was previously hard to tell what the build was producing; this output clarifies in the usual MSBuild project style.


Commit migrated from dotnet/core-setup@58efb31
  • Loading branch information
dagood committed Jul 2, 2019
1 parent 11236b8 commit 30bb688
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 88 deletions.
10 changes: 5 additions & 5 deletions src/installer/pkg/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@

<RpmTemplatesDir>$(MSBuildThisFileDirectory)packaging/rpm/templates/</RpmTemplatesDir>

<DebtoolConsumerProjectName>dotnet-deb-tool-consumer.csproj</DebtoolConsumerProjectName>
<DebtoolConsumerProjectFile>$(MSBuildThisFileDirectory)deps/$(DebtoolConsumerProjectName)</DebtoolConsumerProjectFile>
<!--
Intermediate dir the debtool project is copied to. Use this as the working directory for
"dotnet deb-tool" commands, after depending on InitializeDotnetDebTool target.
Intermediate dir the debtool project is copied to. Use DebtoolAssemblyFile for "dotnet
deb-tool" commands, after depending on InitializeDotnetDebTool target.
-->
<DebtoolConsumerDeployDir>$(IntermediateOutputRootPath)$(DebtoolConsumerProjectName)/</DebtoolConsumerDeployDir>
<DebToolBinDir>$(BinDir)dotnet-deb-tool\</DebToolBinDir>
<DebtoolAssemblyFile>$(DebToolBinDir)$(Configuration)\netcoreapp3.0\dotnet-deb-tool.dll</DebtoolAssemblyFile>
<DotnetDebToolSourceDir>$(ProjectDir)tools-local/setuptools/dotnet-deb-tool/</DotnetDebToolSourceDir>

<IsDebianBasedDistro
Condition="
Expand Down
22 changes: 14 additions & 8 deletions src/installer/pkg/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@
</PropertyGroup>
</Target>

<!-- Create deb tool package and set up the project that consumes it as a CLI tool. -->
<!-- Ensure the deb tool is built. -->
<Target Name="InitializeDotnetDebTool">
<!--
Build the deb tool and initialize the consumer project. Using an MSBuild task helps this
to only happen once if parallel projects depend on this target.
-->
<MSBuild Projects="$(MSBuildThisFileDirectory)deps\init-deb-tool-consumer.proj" />
<MSBuild
Projects="$(DotnetDebToolSourceDir)dotnet-deb-tool.csproj"
Targets="Restore;Build" />
</Target>

<!--
Expand All @@ -45,7 +43,11 @@
-->
<Target Name="TestDebuild">
<!-- run Debuild -->
<Exec Command="/usr/bin/env debuild -h" ContinueOnError="true">
<Exec
Command="/usr/bin/env debuild -h > /dev/null 2>&amp;1"
ContinueOnError="true"
IgnoreExitCode="true"
IgnoreStandardErrorWarningFormat="true">
<Output TaskParameter="ExitCode" PropertyName="DebuildExitCode" />
</Exec>

Expand All @@ -66,7 +68,11 @@
-->
<Target Name="TestFPMTool">
<!-- run FPM -->
<Exec Command="/usr/bin/env fpm -h" ContinueOnError="true">
<Exec
Command="/usr/bin/env fpm -h > /dev/null 2>&amp;1"
ContinueOnError="true"
IgnoreExitCode="true"
IgnoreStandardErrorWarningFormat="true">
<Output TaskParameter="ExitCode" PropertyName="FPMExitCode" />
</Exec>

Expand Down
8 changes: 0 additions & 8 deletions src/installer/pkg/deps/dotnet-deb-tool-consumer.csproj

This file was deleted.

41 changes: 0 additions & 41 deletions src/installer/pkg/deps/init-deb-tool-consumer.proj

This file was deleted.

17 changes: 14 additions & 3 deletions src/installer/pkg/packaging-tools/installer.targets
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@

<!-- Run deb tool in the directory of the consumer project. -->
<Exec
Command="$(DotNetTool) deb-tool $(DebToolArgs)"
WorkingDirectory="$(DebtoolConsumerDeployDir)" />
Command="$(DotNetTool) $(DebtoolAssemblyFile) $(DebToolArgs)"
WorkingDirectory="$(DebToolBinDir)"
IgnoreStandardErrorWarningFormat="true" />

<!-- Copy package to output. -->
<ItemGroup>
Expand All @@ -68,6 +69,8 @@
OverwriteReadOnlyFiles="True"
SkipUnchangedFiles="False"
UseHardlinksIfPossible="False" />

<Message Text="$(MSBuildProjectName) -> $(InstallerFile)" Importance="high" />
</Target>

<Target Name="GetDebInstallerJsonProperties"
Expand Down Expand Up @@ -131,6 +134,8 @@
OverwriteReadOnlyFiles="True"
SkipUnchangedFiles="False"
UseHardlinksIfPossible="False" />

<Message Text="$(MSBuildProjectName) -> $(InstallerFile)" Importance="high" />
</Target>

<Target Name="GetRpmInstallerJsonProperties"
Expand All @@ -149,7 +154,7 @@
DependsOnTargets="
GetInstallerProperties;
RunLightLinker">
<Message Text="Created '$(InstallerFile)'" Importance="High" />
<Message Text="$(MSBuildProjectName) -> $(InstallerFile)" Importance="high" />
</Target>

<Target Name="CreateCompressedArchive"
Expand All @@ -163,6 +168,8 @@
SourceDirectory="$(SharedFrameworkArchiveSourceDir)"
DestinationArchive="$(CompressedArchiveFile)"
OverwriteDestination="true" />

<Message Text="$(MSBuildProjectName) -> $(CompressedArchiveFile)" Importance="high" />
</Target>

<!--
Expand All @@ -182,6 +189,8 @@
</PropertyGroup>

<Exec Command="pkgbuild $(_pkgArgs)" />

<Message Text="$(MSBuildProjectName) -> $(InstallerFile)" Importance="high" />
</Target>

<!--
Expand Down Expand Up @@ -226,6 +235,8 @@

<Target Name="FixLayoutPermissions"
Condition="'$(OSGroup)' != 'Windows_NT'">
<Error Text="Layout '$(PackLayoutDir)' does not exist." Condition="!Exists('$(PackLayoutDir)')" />

<!-- Fix file permissions in the layout dir. -->
<!-- Reset everything to user readable/writeable and group and world readable. -->
<Exec Command='find "$(PackLayoutDir)" -type f -name "*" -exec chmod 644 {} \;' />
Expand Down
10 changes: 9 additions & 1 deletion src/installer/pkg/packaging-tools/packaging-tools.targets
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,15 @@
<SharedFrameworkArchiveSourceDir Condition="'$(SharedFrameworkArchiveSourceDir)' == ''">$(SharedFrameworkLayoutDir)shared/</SharedFrameworkArchiveSourceDir>
</PropertyGroup>

<!-- Use existing infra for non-Windows shared frameworks for now. -->
<!-- Only generate installers for packs and sfxproj. -->
<PropertyGroup Condition="'$(FrameworkPackType)' == '' and '$(GenerateSharedFramework)' != 'true'">
<GeneratePkg>false</GeneratePkg>
<BuildDebPackage>false</BuildDebPackage>
<BuildRpmPackage>false</BuildRpmPackage>
<GenerateMSI>false</GenerateMSI>
</PropertyGroup>

<!-- Use existing infra for non-Windows shared framework installers. -->
<PropertyGroup Condition="'$(GenerateSharedFramework)' == 'true'">
<GeneratePkg>false</GeneratePkg>
<BuildDebPackage>false</BuildDebPackage>
Expand Down
3 changes: 0 additions & 3 deletions src/installer/pkg/packaging/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
<PropertyGroup>
<PackagingRoot>$(ProjectDir)src/pkg/packaging/</PackagingRoot>

<!-- Package prebuilt binaries -->
<UsePrebuiltPortableBinariesForInstallers>false</UsePrebuiltPortableBinariesForInstallers>

<!-- The runtime package is distro-independent. (Runtime-deps packages vary per distro.) -->
<BuildRuntimeDebs>$(BuildDistroIndependentInstallers)</BuildRuntimeDebs>
<BuildRuntimeRpms>$(BuildDistroIndependentInstallers)</BuildRuntimeRpms>
Expand Down
20 changes: 12 additions & 8 deletions src/installer/pkg/packaging/deb/package.targets
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@
DestinationFile="$(debLayoutDirectory)$(DebianConfigJsonName)"
ReplacementItems="@(SharedHostTokenValue)" />

<Exec Command="$(DotNetTool) deb-tool -i $(debLayoutDirectory) -o $(debIntermediatesDir) -n $(DebPackageName) -v $(DebPackageVersion)"
WorkingDirectory="$(DebtoolConsumerDeployDir)" />
<Exec Command="$(DotNetTool) $(DebtoolAssemblyFile) -i $(debLayoutDirectory) -o $(debIntermediatesDir) -n $(DebPackageName) -v $(DebPackageVersion)"
WorkingDirectory="$(DebToolBinDir)"
IgnoreStandardErrorWarningFormat="true" />

<!-- Copy package to output -->
<ItemGroup>
Expand Down Expand Up @@ -159,8 +160,9 @@
DestinationFile="$(debLayoutDirectory)$(DebianConfigJsonName)"
ReplacementItems="@(HostFxrTokenValue)" />

<Exec Command="$(DotNetTool) deb-tool -i $(debLayoutDirectory) -o $(debIntermediatesDir) -n $(DebPackageName) -v $(DebPackageVersion)"
WorkingDirectory="$(DebtoolConsumerDeployDir)" />
<Exec Command="$(DotNetTool) $(DebtoolAssemblyFile) -i $(debLayoutDirectory) -o $(debIntermediatesDir) -n $(DebPackageName) -v $(DebPackageVersion)"
WorkingDirectory="$(DebToolBinDir)"
IgnoreStandardErrorWarningFormat="true" />

<!-- Copy package to output -->
<ItemGroup>
Expand Down Expand Up @@ -252,8 +254,9 @@
DestinationFile="$(debLayoutDirectory)$(DebianConfigJsonName)"
ReplacementItems="@(SharedFrameworkTokenValue)" />

<Exec Command="$(DotNetTool) deb-tool -i $(debLayoutDirectory) -o $(debIntermediatesDir) -n $(DebPackageName) -v $(DebPackageVersion)"
WorkingDirectory="$(DebtoolConsumerDeployDir)" />
<Exec Command="$(DotNetTool) $(DebtoolAssemblyFile) -i $(debLayoutDirectory) -o $(debIntermediatesDir) -n $(DebPackageName) -v $(DebPackageVersion)"
WorkingDirectory="$(DebToolBinDir)"
IgnoreStandardErrorWarningFormat="true" />

<!-- Copy package to output -->
<ItemGroup>
Expand Down Expand Up @@ -333,8 +336,9 @@
DestinationFile="$(debLayoutDirectory)$(DebianConfigJsonName)"
ReplacementItems="@(SharedFrameworkTokenValue)" />

<Exec Command="$(DotNetTool) deb-tool -i $(debLayoutDirectory) -o $(debIntermediatesDir) -n $(DebPackageName) -v $(DebPackageVersion)"
WorkingDirectory="$(DebtoolConsumerDeployDir)" />
<Exec Command="$(DotNetTool) $(DebtoolAssemblyFile) -i $(debLayoutDirectory) -o $(debIntermediatesDir) -n $(DebPackageName) -v $(DebPackageVersion)"
WorkingDirectory="$(DebToolBinDir)"
IgnoreStandardErrorWarningFormat="true" />

<!-- Copy package to output -->
<ItemGroup>
Expand Down
22 changes: 17 additions & 5 deletions src/installer/pkg/packaging/installers.proj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
GenerateVersionBadge;
GenerateCompressedFiles;
GenerateInstallers;
GenerateProjectInstallers;
</PackageTargets>
</PropertyGroup>

Expand All @@ -20,14 +21,25 @@
To build installers, we need shared fx layouts to be built first. Call MSBuild on the
requirements so that parallel MSBuild does the ordering work.
-->
<Target Name="BuildDependencies">
<Target Name="BuildDependencies"
Condition="'$(UsePrebuiltPortableBinariesForInstallers)' != 'true'">
<ItemGroup>
<SharedFrameworkProject Include="$(SourceDir)pkg\projects\**\*.sfxproj" />
</ItemGroup>

<MSBuild
Projects="@(SharedFrameworkProject)"
Targets="Build"/>
Projects="
@(SharedFrameworkProject)"
Targets="Build" />
</Target>

<Target Name="GenerateProjectInstallers" Condition="'$(GenerateProjectInstallers)' == 'true'">
<ItemGroup>
<InstallerProject Include="$(SourceDir)pkg\projects\**\*.pkgproj" />
<InstallerProject Include="$(SourceDir)pkg\projects\**\*.sfxproj" />
</ItemGroup>

<MSBuild Projects="@(InstallerProject)" Targets="GenerateInstallers" />
</Target>

<Target Name="InitPackage">
Expand Down Expand Up @@ -71,7 +83,7 @@

<!-- Copy nethost -->
<PropertyGroup>
<_NetHostOutputDir>$(BaseOutputRootPath)corehost\</_NetHostOutputDir>
<_NetHostOutputDir>$(BinDir)$(InstallerSourceOSPlatformConfig)\corehost\</_NetHostOutputDir>
</PropertyGroup>
<ItemGroup>
<NetHostFiles Include="$(_NetHostOutputDir)nethost.h" />
Expand Down Expand Up @@ -130,7 +142,7 @@
GetInstallerLocations;
GenerateZip;
GenerateTarBall"
Condition="'$(UsePrebuiltPortableBinariesForInstallers)' == 'false'"/>
Condition="'$(UsePrebuiltPortableBinariesForInstallers)' != 'true'"/>

<UsingTask TaskName="ZipFileCreateFromDirectory" AssemblyFile="$(LocalBuildToolsTaskFile)"/>
<Target Name="GenerateZip"
Expand Down
10 changes: 4 additions & 6 deletions tools-local/setuptools/dotnet-deb-tool/dotnet-deb-tool.csproj
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<VersionPrefix>2.1.0</VersionPrefix>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>dotnet-deb-tool</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>dotnet-deb-tool</PackageId>
</PropertyGroup>

<ItemGroup>
<Compile Remove="tool\**\*" />
<Compile Include="..\..\..\src\test\TestUtils\ArgumentEscaper.cs" />

<Content Include="tool\**">
<Content Include="tool\**" CopyToOutputDirectory="PreserveNewest">
<PackagePath>lib/$(TargetFramework)/tool</PackagePath>
<Pack>true</Pack>
</Content>
<Content Include="prefercliruntime">
<Content Include="prefercliruntime" CopyToOutputDirectory="PreserveNewest">
<Pack>true</Pack>
<PackagePath></PackagePath>
</Content>
</ItemGroup>
</ItemGroup>

</Project>

0 comments on commit 30bb688

Please sign in to comment.