Skip to content

Commit

Permalink
Fix package build (#15264)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinRansom authored Jun 2, 2023
1 parent 4c10418 commit 289ab1c
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 24 deletions.
13 changes: 8 additions & 5 deletions eng/Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,9 @@ function Update-Arguments() {
}
}

function BuildSolution([string] $solutionName) {
Write-Host "${solutionName}:"

function BuildSolution([string] $solutionName, $nopack) {
Write-Host "${solutionName}:"

$bl = if ($binaryLog) { "/bl:" + (Join-Path $LogDir "Build.$solutionName.binlog") } else { "" }

Expand All @@ -256,6 +257,8 @@ function BuildSolution([string] $solutionName) {

$env:BUILDING_USING_DOTNET="false"

$pack = if ($nopack -eq $False) {""} else {$pack}

MSBuild $toolsetBuildProj `
$bl `
/p:Configuration=$configuration `
Expand Down Expand Up @@ -536,17 +539,17 @@ try {
$script:BuildMessage = "Failure building product"
if ($restore -or $build -or $rebuild -or $pack -or $sign -or $publish -and -not $skipBuild) {
if ($noVisualStudio) {
BuildSolution "FSharp.sln"
BuildSolution "FSharp.sln" $False
}
else {
BuildSolution "VisualFSharp.sln"
BuildSolution "VisualFSharp.sln" $False
}
}

if ($pack) {
$properties_storage = $properties
$properties += "/p:GenerateSbom=false"
BuildSolution "Microsoft.FSharp.Compiler.sln"
BuildSolution "Microsoft.FSharp.Compiler.sln" $True
$properties = $properties_storage
}
if ($build) {
Expand Down
40 changes: 35 additions & 5 deletions src/Microsoft.FSharp.Compiler/Microsoft.FSharp.Compiler.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
</ItemGroup>

<ItemGroup>
<DependentProjects Include="$(MSBuildThisFileDirectory)..\FSharp.Core\FSharp.Core.fsproj">
<AdditionalProperties>TargetFrameworks=netstandard2.1;netstandard2.0</AdditionalProperties>
</DependentProjects>
<DependentProjects Include="$(MSBuildThisFileDirectory)..\FSharp.Build\FSharp.Build.fsproj">
<AdditionalProperties>TargetFrameworks=netstandard2.0</AdditionalProperties>
</DependentProjects>
Expand All @@ -55,6 +52,9 @@
<DependentProjects Include="$(MSBuildThisFileDirectory)..\FSharp.DependencyManager.Nuget\FSharp.DependencyManager.Nuget.fsproj">
<AdditionalProperties>TargetFrameworks=netstandard2.0</AdditionalProperties>
</DependentProjects>
<DependentProjects Include="$(MSBuildThisFileDirectory)..\FSharp.Core\FSharp.Core.fsproj">
<AdditionalProperties>TargetFrameworks=netstandard2.1;netstandard2.0</AdditionalProperties>
</DependentProjects>
<DependentProjects Include="$(MSBuildThisFileDirectory)..\Compiler\FSharp.Compiler.Service.fsproj">
<AdditionalProperties>TargetFrameworks=netstandard2.0</AdditionalProperties>
</DependentProjects>
Expand All @@ -64,13 +64,43 @@
<Compile Include="Program.fs" />
</ItemGroup>

<!--
The targets below manages Arcade Release/Shipping nuget package manahement.
This is particularly tricky because we generate fsharp.core and fsharp.compiler.service
nupkgs and embedd both the shipping and release nuget packages inside the final
microsoft.fsharp.compiler.nupkg which we insert into the dotnet sdk
-->
<Target Name="PackageReleaseDependentPackages" AfterTargets="Pack" Condition="'$(DotNetFinalVersionKind)' == ''">
<Message Text="Building release versions of NuGet packages" Importance="high" />

<Error Text="PreReleaseVersionLabel must be non-empty when using NuGet Repack tool." Condition="'$(PreReleaseVersionLabel)' == ''" />

<ItemGroup>
<_BuiltPackages Include="$(DependentPackagesDir)Shipping\*.nupkg" />
</ItemGroup>

<!-- Force references among packages to use exact versions (see https://github.com/NuGet/Home/issues/7213) -->
<Microsoft.DotNet.Tools.UpdatePackageVersionTask VersionKind="release" Packages="@(_BuiltPackages)" OutputDirectory="$(DependentPackagesDir)Release" AllowPreReleaseDependencies="true" ExactVersions="true" />

<!-- Rewrite the version ranges of per-build pre-release packages (see https://github.com/NuGet/Home/issues/7213) -->
<Microsoft.DotNet.Tools.UpdatePackageVersionTask Packages="@(_BuiltPackages)" OutputDirectory="$(DependentPackagesDir)Shipping" ExactVersions="true"/>
</Target>

<Target Name="PackageReleasePackages" AfterTargets="Pack" Condition="'$(DotNetFinalVersionKind)' == ''">
<!-- override sdk PackageReleasePackages to do nothing. -->
</Target>


<Target Name="PackDependentProjectsCore">
<MSBuild Projects="@(DependentProjects)" Targets="Pack" Properties="Restore=true;Pack=true;BUILD_PUBLICSIGN=$(BUILD_PUBLICSIGN)" />
<PropertyGroup>
<DependentPackagesDir>$([MSBuild]::NormalizeDirectory( '$(ArtifactsDir)', 'packages', '$(Configuration)', 'Dependency' ))</DependentPackagesDir>
</PropertyGroup>
<MSBuild Projects="@(DependentProjects)" Targets="Pack" Properties="Restore=true;BUILD_PUBLICSIGN=$(BUILD_PUBLICSIGN);ArtifactsPackagesDir=$(DependentPackagesDir)" />
</Target>

<Target Name="PackDependentProjects"
BeforeTargets="Build"
DependsOnTargets="PackDependentProjectsCore;PackageReleasePackages">
DependsOnTargets="PackDependentProjectsCore;PackageReleaseDependentPackages">
</Target>

</Project>
27 changes: 14 additions & 13 deletions src/Microsoft.FSharp.Compiler/Microsoft.FSharp.Compiler.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
<file src="FSharp.Compiler.Service\ReleaseCompressed\netstandard2.0\FSharp.Compiler.Service.dll" target="lib\net7.0" />
<file src="FSharp.Build\ReleaseCompressed\netstandard2.0\FSharp.Build.dll" target="lib\net7.0" />
<file src="FSharp.DependencyManager.Nuget\ReleaseCompressed\netstandard2.0\FSharp.DependencyManager.Nuget.dll"
target="lib\net7.0" />
target="lib\net7.0" />
<file src="FSharp.Compiler.Interactive.Settings\ReleaseCompressed\netstandard2.0\FSharp.Compiler.Interactive.Settings.dll"
target="lib\net7.0" />
target="lib\net7.0" />

<!-- additional files -->
<file src="FSharp.Compiler.Service\ReleaseCompressed\netstandard2.0\default.win32manifest" target="contentFiles\any\any" />
Expand All @@ -48,21 +48,22 @@
<!-- resources -->
<file src="FSharp.Core\ReleaseCompressed\netstandard2.0\**\FSharp.Core.resources.dll" target="lib\net7.0" />
<file src="FSharp.Compiler.Service\ReleaseCompressed\netstandard2.0\**\FSharp.Compiler.Service.resources.dll"
target="lib\net7.0" />
target="lib\net7.0" />
<file src="FSharp.Compiler.Interactive.Settings\ReleaseCompressed\netstandard2.0\**\FSharp.Compiler.Interactive.Settings.resources.dll"
target="lib\net7.0" />
target="lib\net7.0" />
<file src="FSharp.Build\ReleaseCompressed\netstandard2.0\**\FSharp.Build.resources.dll" target="lib\net7.0" />
<file src="FSharp.DependencyManager.Nuget\ReleaseCompressed\netstandard2.0\**\FSharp.DependencyManager.Nuget.resources.dll"
target="lib\net7.0" />
<file src="$artifactsPackagesDir$Shipping\FSharp.Core.$fSharpCorePreviewPackageVersion$*nupkg" target="contentFiles\Shipping" />
<file src="$artifactsPackagesDir$Release\FSharp.Core.$fSharpCorePackageVersion$*nupkg" target="contentFiles\Release" />
<file src="$artifactsPackagesDir$Shipping\FSharp.Compiler.Service.$fSharpCompilerServicePreviewPackageVersion$*nupkg"
target="contentFiles\Shipping" />
<file src="$artifactsPackagesDir$Release\FSharp.Compiler.Service.$fSharpCompilerServicePackageVersion$*nupkg"
target="contentFiles\Release" />
target="lib\net7.0" />
<file src="$artifactsPackagesDir$Dependency\Shipping\FSharp.Core.$fSharpCorePreviewPackageVersion$*nupkg"
target="contentFiles\Shipping" />
<file src="$artifactsPackagesDir$Dependency\Release\FSharp.Core.$fSharpCorePackageVersion$*nupkg" target="contentFiles\Release" />
<file src="$artifactsPackagesDir$Dependency\Shipping\FSharp.Compiler.Service.$fSharpCompilerServicePreviewPackageVersion$*nupkg"
target="contentFiles\Shipping" />
<file src="$artifactsPackagesDir$Dependency\Release\FSharp.Compiler.Service.$fSharpCompilerServicePackageVersion$*nupkg"
target="contentFiles\Release" />
<file src="FSharp.Build\ReleaseCompressed\netstandard2.0\Shipping\Microsoft.FSharp.Core.NetSdk.props"
target="contentFiles\Shipping" />
target="contentFiles\Shipping" />
<file src="FSharp.Build\ReleaseCompressed\netstandard2.0\Release\Microsoft.FSharp.Core.NetSdk.props"
target="contentFiles\Release" />
target="contentFiles\Release" />
</files>
</package>
2 changes: 1 addition & 1 deletion tests/AheadOfTime/NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</solution>
<packageSources>
<clear />
<add key="localPackages" value="../../artifacts/packages/Release/Shipping"/>
<add key="localPackages" value="../../artifacts/packages/Release/Dependency/Release"/>
<add key="remote" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" />
</packageSources>
<disabledPackageSources>
Expand Down

0 comments on commit 289ab1c

Please sign in to comment.