Skip to content
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
9 changes: 6 additions & 3 deletions UseLocalCompiler.Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
<FSharpPrefer64BitTools>True</FSharpPrefer64BitTools>
</PropertyGroup>

<!--
Copy link
Member

Choose a reason for hiding this comment

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

You wrote the comment, but you did not actually set the FSharpTargetsShim prop (under the LoadLocalFSharpBuild=branch)

@copilot

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FSharpTargetsShim is set on line 32 under the LoadLocalFSharpBuild=True condition:

<FSharpTargetsShim>$(LocalFSharpBuildBinPath)/Microsoft.FSharp.NetSdk.targets</FSharpTargetsShim>

This was already present before my changes (it's part of the original file). My changes only:

  1. Added a comment explaining how FSharpTargetsShim works
  2. Removed the redundant UsingTask overrides for FSharpEmbedResourceText and FSharpEmbedResXSource (since the targets file imports Microsoft.FSharp.Targets which registers them)

Use FSharpTargetsShim to redirect the SDK to use the locally built F# targets.
This replaces all the individual UsingTask overrides since Microsoft.FSharp.NetSdk.targets
imports Microsoft.FSharp.Targets which registers all the F# build tasks.
See: https://github.com/dotnet/sdk/blob/main/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FSharpTargetsShim.targets
-->
<PropertyGroup Condition="'$(LoadLocalFSharpBuild)' == 'True'">
<LocalFSharpBuildBinPath>$(LocalFSharpCompilerPath)/artifacts/bin/fsc/$(LocalFSharpCompilerConfiguration)/net10.0</LocalFSharpBuildBinPath>
<FSharpBuildAssemblyFile>$(LocalFSharpBuildBinPath)/FSharp.Build.dll</FSharpBuildAssemblyFile>
Expand All @@ -27,9 +33,6 @@
<FSharpOverridesTargetsShim>$(LocalFSharpBuildBinPath)/Microsoft.FSharp.Overrides.NetSdk.targets</FSharpOverridesTargetsShim>
</PropertyGroup>

<UsingTask Condition="'$(LoadLocalFSharpBuild)' == 'True'" TaskName="FSharpEmbedResourceText" AssemblyFile="$(FSharpBuildAssemblyFile)" Override="true" />
<UsingTask Condition="'$(LoadLocalFSharpBuild)' == 'True'" TaskName="FSharpEmbedResXSource" AssemblyFile="$(FSharpBuildAssemblyFile)" Override="true" />

<ItemGroup>
<Reference Include="$(LocalFSharpCompilerPath)/artifacts/bin/FSharp.Core/$(LocalFSharpCompilerConfiguration)/netstandard2.0/FSharp.Core.dll" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Build/Microsoft.FSharp.NetSdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
<GenerateILLinkSubstitutions
AssemblyName="$(AssemblyName)"
IntermediateOutputPath="$(IntermediateOutputPath)">
<Output TaskParameter="GeneratedItems" ItemName="Embed" />
<Output TaskParameter="GeneratedItems" ItemName="EmbeddedResource" />
</GenerateILLinkSubstitutions>
</Target>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,13 @@
<Fsc_DotNET_DotnetFscCompilerPath>$(LocalFSharpBuildBinPath)/fsc.dll</Fsc_DotNET_DotnetFscCompilerPath>
<FSharpPreferNetFrameworkTools>False</FSharpPreferNetFrameworkTools>
<FSharpPrefer64BitTools>True</FSharpPrefer64BitTools>
<!--
Use FSharpTargetsShim to redirect to the locally built targets file.
This is how the .NET SDK supports testing against local F# builds.
See https://github.com/dotnet/sdk/blob/main/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FSharpTargetsShim.targets
-->
<FSharpTargetsShim>$(LocalFSharpBuildBinPath)/Microsoft.FSharp.NetSdk.targets</FSharpTargetsShim>
</PropertyGroup>

<UsingTask TaskName="GenerateILLinkSubstitutions" AssemblyFile="$(FSharpBuildAssemblyFile)" Override="true" />

<Target Name="GenerateFSharpILLinkSubstitutions" BeforeTargets="AssignTargetPaths">
<GenerateILLinkSubstitutions
AssemblyName="$(AssemblyName)"
IntermediateOutputPath="$(IntermediateOutputPath)">
<Output TaskParameter="GeneratedItems" ItemName="EmbeddedResource" />
</GenerateILLinkSubstitutions>
</Target>

<ItemGroup>
<Compile Include="..\Program.fs" />
Expand Down
Loading