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

IDEA: build FSAC standalone binaries for each OS/Arch/TFM #1258

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ test/FsAutoComplete.Tests.Lsp/TestResults/
.tool-versions
BenchmarkDotNet.Artifacts/

*.sarif
*.sarif
artifacts
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<Title>FsAutoComplete</Title>
<Product>FsAutoComplete</Product>
<ArtifactsPath>$(MSBuildThisFileDirectory)artifacts</ArtifactsPath>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think if we go down this path, we should move to requiring .NET 8 and use the artifacts layout to simplify out outputs.

<PackageLicenseExpression Condition=" '$(PackAsTool)' != 'true' ">Apache-2.0</PackageLicenseExpression>
<NoWarn>$(NoWarn);3186,0042</NoWarn><!-- circumvent an error with the fake dependencymanager for
paket: https://github.com/dotnet/fsharp/issues/8678 -->
Expand Down
46 changes: 45 additions & 1 deletion src/FsAutoComplete/FsAutoComplete.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks Condition="'$(BuildNet7)' == 'true'">net6.0;net7.0</TargetFrameworks>
<TargetFrameworks Condition="'$(BuildNet8)' == 'true'">net6.0;net7.0;net8.0</TargetFrameworks>
Comment on lines 6 to 7
Copy link
Contributor Author

Choose a reason for hiding this comment

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

WIP: we could potentially remove all of the BuildNetX stuff if we built/tested standalone binaries.

<RuntimeIdentifiers>
win-x64;linux-x64;linux-arm64;osx-x64;osx-arm64;linux-musl-x64;linux-musl-arm64</RuntimeIdentifiers>
<AssemblyName>fsautocomplete</AssemblyName>
<ServerGarbageCollection>true</ServerGarbageCollection>
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
Expand All @@ -17,6 +19,10 @@
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<IsPackable>true</IsPackable>
<PackAsTool>true</PackAsTool>
<PublishSingleFile>true</PublishSingleFile>
<PublishSelfContained>true</PublishSelfContained>
<DebugType>embedded</DebugType>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>
<ItemGroup>
<None Include="../../README.md" Pack="true" PackagePath="\" />
Expand Down Expand Up @@ -64,6 +70,12 @@
<TargetsForTfmSpecificBuildOutput>
$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>

<ItemGroup Label="Trimming Settings">
<TrimmerRootAssembly Include="Serilog" />
<TrimmerRootAssembly Include="Ionide.ProjInfo.ProjectSystem" />
</ItemGroup>

<!-- workaround for not being able to have p2p dependencies in tool output dir
https://github.com/nuget/home/issues/3891#issuecomment-377319939 -->
<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences">
Expand All @@ -72,5 +84,37 @@
Include="@(ReferenceCopyLocalPaths -> WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
</ItemGroup>
</Target>

<Target Name="BuildAllStandloneApplications">
<ItemGroup>
<!-- Make MSBuild Items out of the RIDs so we can batch across them -->
<_RIDS Include="$(RuntimeIdentifiers)" />
<!-- Make MSBuild Items out of the TFMs so we can batch across them. Create NUM_RIDS items
per-TFM because we want to build each TFM for all supported platforms. -->
<_TFMS
Include="$(TargetFrameworks)"
RID="%(_RIDS.Identity)" />
<!-- Turn the _TFMS items into requests to build this project (fsautocomplete.fsproj) with
different parameters. This pattern is often used to to parallel builds of the same project in
MSBuild logic. -->
<_RIDSpecificFSACBuild
Include="$(MSBuildThisFile)"
AdditionalProperties="RuntimeIdentifier=%(_TFMS.RID);TargetFramework=%(_TFMS.Identity)" />
</ItemGroup>

<!-- Ask MSBuild to build all of the requests we just made. The MSBuild Task recognizes the
AdditionalProperties metadata and will apply that to each specific build, we can specify the things
that are common to all of the builds here. Unsetting RuntimeIdentifiers and TargetFrameworks
ensures that the SDK targets detect that these are single-RID/single-TFM builds accurately, and
since we're pretty certain there are no data dependencies here we can have the builds operate in
parallel. -->
<MSBuild
Projects="@(_RIDSpecificFSACBuild)"
Targets="Publish"
Properties="Configuration=Release;SelfContained=true"
RemoveProperties="RuntimeIdentifiers;TargetFrameworks"
BuildInParallel="true" />
</Target>

<Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>
Loading